# PostgreSQL Commands: Complete Cheat Sheet With Examples

PostgreSQL Commands: Complete Cheat Sheet With Examples
=======================================================

PostgreSQL commands fall into two distinct categories: `psql` meta-commands (processed locally by the terminal client, starting with a backslash \\) and standard PostgreSQL SQL Commands (processed by the server and ending with a semicolon ;).

 [Talk to a consultant](/contact-us/) 

 

 

 

    - [ What Are PostgreSQL Commands? ](#sec-0)
- [ How to Connect to PostgreSQL ](#sec-1)
- [ Understanding PostgreSQL Commands ](#sec-2)
- [ Tips from the expert ](#sec-3)
- [ Common PostgreSQL Command Examples ](#sec-4)
- [ PostgreSQL Commands Best Practices ](#sec-5)
- [ Running PostgreSQL in Production with NetApp Instaclustr ](#sec-6)
 
      What Are PostgreSQL Commands?   How to Connect to PostgreSQL   Understanding PostgreSQL Commands   Tips from the expert   Common PostgreSQL Command Examples   PostgreSQL Commands Best Practices   Running PostgreSQL in Production with NetApp Instaclustr   

 What Are PostgreSQL Commands? 
------------------------------

[PostgreSQL](https://www.instaclustr.com/education/postgresql/complete-guide-to-postgresql-features-use-cases-and-tutorial/) commands fall into two distinct categories: `psql` meta-commands (processed locally by the terminal client, starting with a backslash `\`) and standard PostgreSQL SQL Commands (processed by the server and ending with a semicolon `;`).

These commands allow users to manage databases, tables, users, roles, and the data itself. They include both SQL statements like `SELECT`, `INSERT`, `UPDATE`, and `DELETE`, and meta-commands in the `psql` command-line interface (such as `\dt` for listing tables).

PostgreSQL commands are fundamental for database creation, modification, data retrieval, security, and maintenance.  
This structured reference guide highlights the most frequently used commands for database administration, navigation, and data manipulation.

This structured reference guide highlights the most frequently used commands for database administration, navigation, and data manipulation.

 

 

How to Connect to PostgreSQL 
-----------------------------

To connect to a PostgreSQL database, you typically use the psql command-line client. **The basic syntax is**:

  























PgSQL





psql -U app\_user -d company\_db

   1



  psql -U app_user -d company_db



   

 

 **For example:**

  























PgSQL





psql --username=app\_user --dbname=company\_db

   1



  psql --username=app\_user --dbname=company\_db



   

 

 **If the database is running on a different server, specify the host and port:**

  























PgSQL





psql -h db.example.com -p 5432 -U app\_user -d company\_db

   1



  psql -h db.example.com -p 5432 -U app_user -d company_db



   

 

 After running the command, PostgreSQL prompts you for a password if authentication is required. Once connected, you can execute SQL statements and psql meta-commands directly from the terminal.

**You can also connect using a connection string:**

  























PgSQL





psql "postgresql://app\_user:StrongPassword123@localhost:5432/company\_db"

   1



  psql "postgresql://app\_user:StrongPassword123@localhost:5432/company\_db"



   

 

 After a successful connection, the `psql` prompt appears:

  























PgSQL





mydatabase=#

   1



  mydatabase=#



   

 

 From there, you can start managing databases, creating tables, querying data, and running administrative commands. To exit the session, use:

  























PgSQL





\\q

   1



  \q



   

 

  

 

Understanding PostgreSQL Commands 
----------------------------------

### Basic psql Commands

The `psql` client includes meta-commands that help you navigate and manage PostgreSQL databases. These commands begin with a backslash (`\`) and are executed directly by `psql`, not by the PostgreSQL server.

**List available databases:**

  























PgSQL





\\l

   1



  \l



   

 

 **Connect to a different database:**

  























PgSQL





\\c db\_name

   1



  \c db_name



   

 

 **List all tables in the current database:**

  























PgSQL





\\dt

   1



  \dt



   

 

 **Describe the structure of a table:**

  























PgSQL





\\d your\_table

   1



  \d your_table



   

 

 **List schemas:**

  























PgSQL





\\dn

   1



  \dn



   

 

 **Display available commands:**

  























PgSQL





\\?

   1



  \?



   

 

 **Get help for SQL commands:**

  























PgSQL





\\h

   1



  \h



   

 

 **Exit the psql session:**

  























PgSQL





\\q

   1



  \q



   

 

 These commands are useful for exploring database objects and managing sessions without writing SQL queries.

### PostgreSQL Database Commands

Database commands are used to create, modify, and remove databases.

**Create a new database:**

  























PgSQL





CREATE DATABASE my\_store\_db;

   1



  CREATE DATABASE my_store_db;



   

 

 **List all databases:**

  























PgSQL





\\l

   1



  \l



   

 

 **Connect to a database:**

  























PgSQL





\\c my\_store\_db;

   1



  \c my_store_db;



   

 

 **Rename a database:**

  























PgSQL





ALTER DATABASE my\_store\_db RENAME TO newdatabase;

   1



  ALTER DATABASE my_store_db RENAME TO newdatabase;



   

 

 **Delete a database:**

  























PgSQL





DROP DATABASE my\_store\_db;

   1



  DROP DATABASE my_store_db;



   

 

 **View information about the current connection:**

  























PgSQL





\\conninfo

   1



  \conninfo



   

 

 These commands help administrators organize and manage multiple databases on a PostgreSQL server.

### PostgreSQL Table Commands

Table commands are used to create and manage database tables.

**Create a table:**

  























PgSQL





CREATE TABLE team\_members ( member\_id SERIAL PRIMARY KEY, full\_name VARCHAR(120), role\_name VARCHAR(80) );

   1

2

3

4

5



  CREATE TABLE team_members (

member_id SERIAL PRIMARY KEY,

full_name VARCHAR(120),

role_name VARCHAR(80)

);



   

 

 **View table definitions:**

  























PgSQL





\\d team\_members;

   1



  \d team_members;



   

 

 **Add a column:**

  























PgSQL





ALTER TABLE team\_members ADD COLUMN work\_email VARCHAR(255);

   1

2



  ALTER TABLE team_members

ADD COLUMN work_email VARCHAR(255);



   

 

 **Rename a table:**

  























PgSQL





ALTER TABLE team\_members RENAME TO company\_staff;

   1

2



  ALTER TABLE team_members

RENAME TO company_staff;



   

 

 **Remove a column:**

  























PgSQL





ALTER TABLE company\_staff DROP COLUMN work\_email;

   1

2



  ALTER TABLE company_staff

DROP COLUMN work_email;



   

 

 **Delete a table:**

  























PgSQL





DROP TABLE company\_staff;

   1



  DROP TABLE company_staff;



   

 

 These commands define how data is structured and stored within a database.

### PostgreSQL Data Query Commands

Data query commands retrieve information from tables.

**Retrieve all rows:**

  























PgSQL





SELECT \* FROM staff\_members;

   1

2



  SELECT *

FROM staff_members;



   

 

 **Retrieve specific columns:**

  























PgSQL





SELECT full\_name, team\_name FROM staff\_members;

   1

2



  SELECT full_name, team_name

FROM staff_members;



   

 

 **Filter results:**

  























PgSQL





SELECT \* FROM staff\_members WHERE team\_name = 'Marketing';

   1

2

3



  SELECT *

FROM staff_members

WHERE team_name = 'Marketing';



   

 

 **Sort results:**

  























PgSQL





SELECT \* FROM staff\_members ORDER BY full\_name ASC;

   1

2

3



  SELECT *

FROM staff_members

ORDER BY full_name ASC;



   

 

 **Limit returned rows:**

  























PgSQL





SELECT \* FROM staff\_members LIMIT 5;

   1

2

3



  SELECT *

FROM staff_members

LIMIT 5;



   

 

 **Aggregate data:**

  























PgSQL





SELECT team\_name, COUNT(\*) AS total\_staff FROM staff\_members GROUP BY team\_name;

   1

2

3



  SELECT team_name, COUNT(*) AS total_staff

FROM staff_members

GROUP BY team_name;



   

 

 These commands are used to search, analyze, and report on stored data.

### PostgreSQL Data Modification Commands

Data modification commands add, update, and remove records.

**Insert a new row:**

  























PgSQL





INSERT INTO staff\_members (full\_name, team\_name) VALUES ('Jane Doe', 'Operations');

   1

2



  INSERT INTO staff_members (full_name, team_name)

VALUES ('Jane Doe', 'Operations');



   

 

 **Update existing data:**

  























PgSQL





UPDATE staff\_members SET team\_name = 'Finance' WHERE member\_id = 3;

   1

2

3



  UPDATE staff_members

SET team_name = 'Finance'

WHERE member_id = 3;



   

 

 **Delete rows:**

  























PgSQL





DELETE FROM staff\_members WHERE member\_id = 3;

   1

2



  DELETE FROM staff_members

WHERE member_id = 3;



   

 

 **Remove all rows from a table:**

  























PgSQL





TRUNCATE TABLE staff\_members;

   1



  TRUNCATE TABLE staff_members;



   

 

 **Insert data returned by a query:**

  























PgSQL





INSERT INTO archived\_staff\_members SELECT \* FROM staff\_members WHERE team\_name = 'Operations';

   1

2

3

4



  INSERT INTO archived_staff_members

SELECT *

FROM staff_members

WHERE team_name = 'Operations';



   

 

 These commands allow users to maintain accurate and up-to-date information within PostgreSQL databases.

### PostgreSQL User and Role Commands

PostgreSQL uses roles to manage authentication and permissions. A role can function as a user, a group, or both.

**Create a new role:**

  























PgSQL





CREATE ROLE reporting\_team;

   1



  CREATE ROLE reporting_team;



   

 

 **Create a user with a password:**

  























PgSQL





CREATE USER dashboard\_user WITH PASSWORD 'StrongPass\_2026';

   1

2



  CREATE USER dashboard_user

WITH PASSWORD 'StrongPass\_2026';



   

 

 **Grant privileges on a database:**

  























PgSQL





GRANT CONNECT ON DATABASE company\_db TO dashboard\_user;

   1

2

3



  GRANT CONNECT

ON DATABASE company_db

TO dashboard_user;



   

 

 **Grant privileges on a table:**

  























PgSQL





GRANT SELECT, UPDATE ON staff\_members TO dashboard\_user;

   1

2

3



  GRANT SELECT, UPDATE

ON staff_members

TO dashboard_user;



   

 

 **Assign a role to another user:**

  























PgSQL





GRANT reporting\_team TO dashboard\_user;

   1



  GRANT reporting_team TO dashboard_user;



   

 

 **Change a user’s password:**

  























PgSQL





ALTER USER dashboard\_user WITH PASSWORD 'UpdatedPass\_2026';

   1

2



  ALTER USER dashboard_user

WITH PASSWORD 'UpdatedPass\_2026';



   

 

 **Remove a role or user:**

  























PgSQL





DROP ROLE dashboard\_user;

   1



  DROP ROLE dashboard_user;



   

 

 **List roles:**

  























PgSQL





\\du

   1



  \du



   

 

 These commands help control access to database resources and enforce security policies.

### PostgreSQL Index Commands

Indexes improve query performance by allowing PostgreSQL to locate data more efficiently.

**Create an index:**

  























PgSQL





CREATE INDEX idx\_staff\_full\_name ON staff\_members(full\_name);

   1

2



  CREATE INDEX idx_staff_full_name

ON staff_members(full_name);



   

 

 **Create a unique index:**

  























PgSQL





CREATE UNIQUE INDEX idx\_staff\_work\_email ON staff\_members(work\_email);

   1

2



  CREATE UNIQUE INDEX idx_staff_work_email

ON staff_members(work_email);



   

 

 **View indexes for a table:**

  























PgSQL





\\d staff\_members;

   1



  \d staff_members;



   

 

 **Remove an index:**

  























PgSQL





DROP INDEX idx\_staff\_full\_name;

   1



  DROP INDEX idx_staff_full_name;



   

 

 **Create a multi-column index:**

  























PgSQL





CREATE INDEX idx\_staff\_team\_name ON staff\_members(team\_name, full\_name);

   1

2



  CREATE INDEX idx_staff_team_name

ON staff_members(team_name, full_name);



   

 

 **Rebuild an index:**

  























PgSQL





REINDEX INDEX idx\_staff\_full\_name;

   1



  REINDEX INDEX idx_staff_full_name;



   

 

 Indexes can significantly speed up searches, joins, and sorting operations, but they also require storage and maintenance during data updates.

### PostgreSQL Schema Commands

Schemas organize database objects into logical namespaces. They help separate applications, users, or environments within the same database.

**Create a schema:**

  























PgSQL





CREATE SCHEMA reporting;

   1



  CREATE SCHEMA reporting;



   

 

 **List schemas:**

  























PgSQL





\\dn

   1



  \dn



   

 

 **Create a table in a schema:**

  























PgSQL





CREATE TABLE reporting.monthly\_reports ( report\_id SERIAL PRIMARY KEY, created\_on DATE );

   1

2

3

4



  CREATE TABLE reporting.monthly_reports (

report_id SERIAL PRIMARY KEY,

created_on DATE

);



   

 

 **Set the default schema:**

  























PgSQL





SET search\_path TO reporting;

   1



  SET search_path TO reporting;



   

 

 **Rename a schema:**

  























PgSQL





ALTER SCHEMA reporting RENAME TO reporting\_archive;

   1

2



  ALTER SCHEMA reporting

RENAME TO reporting_archive;



   

 

 **Delete a schema:**

  























PgSQL





DROP SCHEMA reporting;

   1



  DROP SCHEMA reporting;



   

 

 **Delete a schema and all its objects:**

  























PgSQL





DROP SCHEMA reporting\_archive CASCADE;

   1



  DROP SCHEMA reporting_archive CASCADE;



   

 

 Schemas provide a way to group related database objects and avoid naming conflicts.

### PostgreSQL Backup and Restore Commands

PostgreSQL provides command-line utilities for creating backups and restoring databases.

**Create a backup using `pg_dump`:**

  























PgSQL





pg\_dump --username=db\_admin --dbname=company\_db --file=company\_db\_backup.sql

   1



  pg_dump --username=db\_admin --dbname=company\_db --file=company\_db\_backup.sql



   

 

 **Create a compressed custom-format backup:**

  























PgSQL





pg\_dump -U db\_admin -Fc company\_db &gt; company\_db.dump

   1



  pg_dump -U db_admin -Fc company_db &gt; company_db.dump



   

 

 **Restore a SQL backup:**

  























PgSQL





psql --username=db\_admin --dbname=company\_db --file=company\_db\_backup.sql

   1



  psql --username=db\_admin --dbname=company\_db --file=company\_db\_backup.sql



   

 

 **Restore a custom-format backup:**

  























PgSQL





pg\_restore --username=db\_admin --dbname=company\_db company\_db.dump

   1



  pg_restore --username=db\_admin --dbname=company\_db company\_db.dump



   

 

 **Back up all databases:**

  























PgSQL





pg\_dumpall --username=db\_admin --file=cluster\_backup.sql

   1



  pg_dumpall --username=db\_admin --file=cluster\_backup.sql



   

 

 **Restore all databases:**

  























PgSQL





psql --username=db\_admin --file=cluster\_backup.sql

   1



  psql --username=db\_admin --file=cluster\_backup.sql



   

 

 Regular backups are essential for disaster recovery, migration, and protecting against data loss.

### PostgreSQL Transaction Commands

Transactions allow multiple operations to be executed as a single unit of work. They help maintain data consistency and integrity.

**Start a transaction:**

  























PgSQL





BEGIN;

   1



  BEGIN;



   

 

 **Execute one or more statements:**

  























PgSQL





UPDATE wallet\_accounts SET current\_balance = current\_balance - 250 WHERE account\_id = 101; UPDATE wallet\_accounts SET current\_balance = current\_balance + 250 WHERE account\_id = 202; COMMIT;

   1

2

3

4

5

6

7

8

9



  UPDATE wallet_accounts

SET current_balance = current_balance - 250

WHERE account_id = 101;



UPDATE wallet_accounts

SET current_balance = current_balance + 250

WHERE account_id = 202;



COMMIT;



   

 

 **Cancel all changes made during the transaction:**

  























PgSQL





ROLLBACK;

   1



  ROLLBACK;



   

 

 **Create a savepoint:**

  























PgSQL





SAVEPOINT payment\_checkpoint;

   1



  SAVEPOINT payment_checkpoint;



   

 

 **Roll back to a savepoint:**

  























PgSQL





ROLLBACK TO SAVEPOINT payment\_checkpoint;

   1



  ROLLBACK TO SAVEPOINT payment_checkpoint;



   

 

 Transactions ensure that operations either complete successfully as a group or leave the database unchanged if an error occurs.

 

 

Tips from the expert
--------------------

 

 ![Perry Clark]()Perry Clark

Professional Services Consultant

 

 

Perry Clark is a seasoned open source consultant with NetApp. Perry is passionate about delivering high-quality solutions and has a strong background in various open source technologies and methodologies, making him a valuable asset to any project.

 

In my experience, here are tips that can help you better manage and use PostgreSQL commands:

1. **Use `\x auto` for wide query results:** Large rows containing JSON, arrays, or many columns become much easier to read. Keep this enabled in your `psql` profile to improve day-to-day troubleshooting.
2. **Master `\gexec` for dynamic administration:** Generate SQL with a query and execute the results immediately. This is extremely useful for bulk maintenance tasks across multiple tables or schemas.
3. **Use `RETURNING` to reduce round trips:** Many developers run an `INSERT` followed by a `SELECT` to retrieve generated values. `INSERT ... RETURNING` eliminates the extra query and reduces application latency.
4. **Create indexes concurrently in production:** Standard `CREATE INDEX` can block writes. Use `CREATE INDEX CONCURRENTLY` when adding indexes to busy production tables to avoid service interruptions.
5. **Use `\watch` as a lightweight monitoring tool:** Any query can become a real-time dashboard. This is invaluable during deployments, incident investigations, and performance tuning sessions.

 

 

 

 

 

 

Common PostgreSQL Command Examples 
-----------------------------------

### Create a Database, Table, and Insert Data

The following example creates a database, creates a table, and inserts a record.

**1. Create a database:**

  























PgSQL





CREATE DATABASE project\_db;

   1



  CREATE DATABASE project_db;



   

 

 **2. Connect to the database:**

  























PgSQL





\\c project\_db;

   1



  \c project_db;



   

 

 **3. Create a table:**

  























PgSQL





CREATE TABLE staff\_records ( staff\_id SERIAL PRIMARY KEY, full\_name VARCHAR(120), team\_name VARCHAR(60) );

   1

2

3

4

5



  CREATE TABLE staff_records (

 staff_id SERIAL PRIMARY KEY,

 full_name VARCHAR(120),

 team_name VARCHAR(60)

);



   

 

 **4. Insert data:**

  























PgSQL





INSERT INTO staff\_records (full\_name, team\_name) VALUES ('John Smith', 'Technology');

   1

2



  INSERT INTO staff_records (full_name, team_name)

VALUES ('John Smith', 'Technology');



   

 

 **5. Verify the inserted record:**

  























PgSQL





SELECT \* FROM staff\_records;

   1

2



  SELECT *

FROM staff_records;



   

 

 This workflow demonstrates the basic steps required to start working with a new PostgreSQL database.

### Query and Update Records

Once data exists in a table, you can retrieve and modify it using `SELECT` and `UPDATE` statements.

**1. Query all records:**

  























PgSQL





SELECT \* FROM team\_members;

   1

2



  SELECT *

FROM team_members;



   

 

 **2. Filter records with a condition:**

  























PgSQL





SELECT \* FROM team\_members WHERE team = 'Product';

   1

2

3



  SELECT *

FROM team_members

WHERE team = 'Product';



   

 

 **3. Update a record:**

  























PgSQL





UPDATE team\_members SET team = 'Operations' WHERE full\_name = 'John McCain';

   1

2

3



  UPDATE team_members

SET team = 'Operations'

WHERE full_name = 'John McCain';



   

 

 **4. Verify the update:**

SELECT \*  
FROM team\_members  
WHERE full\_name = ‘John McCain’;

Using a `WHERE` clause is important because it limits the update to specific rows.

### Delete Records Safely

When deleting data, always review the affected rows before running a `DELETE` statement.

**1. Check which records will be removed:**

  























PgSQL





SELECT \* FROM team\_members WHERE member\_id = 5;

   1

2

3



  SELECT *

FROM team_members

WHERE member_id = 5;



   

 

 **2. Delete a specific record:**

  























PgSQL





DELETE FROM team\_members WHERE member\_id = 5;

   1

2



  DELETE FROM team_members

WHERE member_id = 5;



   

 

 **3. Confirm the deletion:**

  























PgSQL





SELECT \* FROM team\_members WHERE member\_id = 5;

   1

2

3



  SELECT *

FROM team_members

WHERE member_id = 5;



   

 

 You can also run the deletion inside a transaction to verify the results before committing:

  























PgSQL





BEGIN; DELETE FROM team\_members WHERE member\_id = 5; SELECT \* FROM team\_members; ROLLBACK;

   1

2

3

4

5

6

7

8

9



  BEGIN;



DELETE FROM team_members

WHERE member_id = 5;



SELECT *

FROM team_members;



ROLLBACK;



   

 

 Using transactions and precise `WHERE` clauses helps prevent accidental data loss.

 

 

PostgreSQL Commands Best Practices 
-----------------------------------

Here are some of the ways to improve your use of PostgreSQL commands.

**1. Always Use `WHERE` with `UPDATE` and `DELETE`**

The `UPDATE` and `DELETE` commands affect every row in a table when a `WHERE` clause is omitted. This can lead to accidental data loss or large-scale changes that are difficult to reverse.

*Unsafe example:*

  























PgSQL





UPDATE staff\_records SET team\_name = 'Operations';

   1

2



  UPDATE staff_records

SET team_name = 'Operations';



   

 

 **Safer approach:**

  























PgSQL





UPDATE staff\_records SET team\_name = 'Operations' WHERE staff\_id = 25;

   1

2

3



  UPDATE staff_records

SET team_name = 'Operations'

WHERE staff_id = 25;



   

 

 Before running an `UPDATE` or `DELETE`, execute a `SELECT` statement with the same `WHERE` condition to verify which rows will be affected.

**2. Use Transactions for Risky Changes**

Transactions allow you to group multiple operations and either commit them together or roll them back if something goes wrong. This is especially useful when modifying large amounts of data.

**Example:**

  























PgSQL





BEGIN; UPDATE staff\_records SET team\_name = 'Customer Success' WHERE team\_name = 'Operations'; COMMIT;

   1

2

3

4

5

6

7



  BEGIN;



UPDATE staff_records

SET team_name = 'Customer Success'

WHERE team_name = 'Operations';



COMMIT;



   

 

 If the results are not what you expected, you can cancel the changes before committing:

  























PgSQL





ROLLBACK;

   1



  ROLLBACK;



   

 

 Using transactions reduces the risk of accidental changes and helps maintain data consistency.

**3. Use `EXPLAIN` Before Optimizing Queries**

The `EXPLAIN` command shows how PostgreSQL plans to execute a query. It helps identify slow operations such as sequential scans, expensive joins, or inefficient sorting.

**Example:**

  























PgSQL





EXPLAIN SELECT \* FROM staff\_records WHERE team\_name = 'Technology';

   1

2

3

4



  EXPLAIN

SELECT *

FROM staff_records

WHERE team_name = 'Technology';



   

 

 To view estimated execution costs and actual execution statistics, use:

  























PgSQL





EXPLAIN ANALYZE SELECT \* FROM staff\_records WHERE team\_name = 'Technology';

   1

2

3

4



  EXPLAIN ANALYZE

SELECT *

FROM staff_records

WHERE team_name = 'Technology';



   

 

 Reviewing execution plans before making changes helps ensure optimization efforts are focused on real performance bottlenecks.

**4. Use Indexes on Frequently Filtered Columns**

Indexes improve query performance by reducing the amount of data PostgreSQL must scan. They are most effective on columns that are frequently used in `WHERE`, `JOIN`, and `ORDER BY` clauses.

**Create an index:**

  























PgSQL





CREATE INDEX idx\_staff\_records\_team\_name ON staff\_records(team\_name);

   1

2



  CREATE INDEX idx_staff_records_team_name

ON staff_records(team_name);



   

 

 For example, if queries often filter by department, an index can significantly reduce query execution time. However, indexes are not free. Each index consumes storage space and adds overhead to `INSERT`, `UPDATE`, and `DELETE` operations. Create indexes only when they provide measurable benefits.

**5. Avoid Using the postgres Superuser for Applications**

The default postgres account has unrestricted access to the entire PostgreSQL server. Using it for applications increases the risk of accidental changes and security issues.

Instead, create a dedicated user with only the permissions required by the application:

  























PgSQL





CREATE USER reporting\_user WITH PASSWORD 'StrongPassword\_2026';

   1

2



  CREATE USER reporting_user

WITH PASSWORD 'StrongPassword\_2026';



   

 

 Grant only the necessary privileges:

  























PgSQL





GRANT SELECT, INSERT, UPDATE, DELETE ON staff\_records TO reporting\_user;

   1

2

3



  GRANT SELECT, INSERT, UPDATE, DELETE

ON staff_records

TO reporting_user;



   

 

 Following the principle of least privilege limits potential damage if application credentials are compromised and improves overall database security.

 

 

Running PostgreSQL in Production with NetApp Instaclustr
--------------------------------------------------------

The commands in this guide cover the day-to-day work of creating databases, querying and modifying data, managing roles, and maintaining your environment, but running PostgreSQL reliably in production also means handling provisioning, monitoring, high availability, backups, and version upgrades. NetApp Instaclustr offers a fully hosted and managed PostgreSQL service that runs in the cloud or on-premises and delivers a production-ready PostgreSQL cluster backed by 24×7 expert support, letting your teams focus on building applications instead of administering database infrastructure.

**Key capabilities of Instaclustr for PostgreSQL:**

- **Fully managed and 100% open source:** Instaclustr customizes and optimizes PostgreSQL on all major cloud providers and on-premises data centers, with no proprietary features or lock-in, running in your cloud account or theirs.
- **Industry-leading 99.99% SLA:** Instaclustr’s availability SLAs for PostgreSQL set the service apart and are backed by continuous maintenance and version upgrades.
- **Multi-region replication:** Read replicas can be created in secondary regions for high availability, minimizing latency and maximizing uptime.
- **PGBouncer connection pooling:** A lightweight connection pooler enhances database performance and scalability through efficient connection management and resource optimization.
- **DevOps-friendly provisioning and monitoring:** Provision via console, REST API, or Terraform, and monitor through built-in dashboards or the Prometheus API and other integrations.
- **Enterprise-grade security and compliance:** The platform is SOC2, ISO27001, and ISO27018 certified, meets GDPR requirements, and offers PCI-compliant solutions.
- **pgvector for AI workloads:** Instaclustr supports the pgvector extension, enabling efficient storage and similarity search of high-dimensional vector data so you can power RAG and other AI applications directly within PostgreSQL.

Ready to run PostgreSQL without the operational overhead?[ Explore Instaclustr’s fully managed PostgreSQL service](https://www.instaclustr.com/platform/managed-postgresql/) and spin up a production-ready cluster in minutes.

 

 



 

 ### Related content

 [4 ways to get Postgres support in 2026](https://www.instaclustr.com/education/postgresql/4-ways-to-get-postgres-support-in-2026/) [Best Managed PostgreSQL Database Services: Top 13 in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-database-services-top-13/) [Best managed PostgreSQL options: Top 6 solutions in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-options-top-6-solutions-in-2026/) [Best managed PostgreSQL platforms: Top 7 providers in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-platforms-top-5-providers-in-2025/) [Best managed PostgreSQL services: Top 8 in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-services-top-5-in-2026/) [Best managed PostgreSQL solutions for developers: Top 6 in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-solutions-for-developers-top-5-in-2026/) [Best managed PostgreSQL solutions: Top 5 in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-solutions-top-5-in-2026/) [Best managed PostgreSQL tools: Top 6 options in 2026](https://www.instaclustr.com/education/postgresql/best-managed-postgresql-tools-top-5-options-in-2026/) [ClickHouse vs. Postgres: 5 key differences and how to choose](https://www.instaclustr.com/education/clickhouse/clickhouse-vs-postgres-5-key-differences-and-how-to-choose/) [Complete guide to PostgreSQL: Features, use cases, and tutorial](https://www.instaclustr.com/education/postgresql/complete-guide-to-postgresql-features-use-cases-and-tutorial/) [Managed PostgreSQL® services: What you need to know](https://www.instaclustr.com/education/managed-database/managed-postgresql-services-what-you-need-to-know/) [PostgreSQL Timestamp: Data Types, Functions, and Best Practices](https://www.instaclustr.com/education/postgresql/postgresql-timestamp-data-types-functions-and-best-practices/) [PostgreSQL cluster hands-on guide: Setup, optimization, and monitoring](https://www.instaclustr.com/education/postgresql/postgresql-cluster-hands-on-guide-setup-optimization-and-monitoring/) [PostgreSQL management: 7 key tasks and 8 tools that can help](https://www.instaclustr.com/education/postgresql/postgresql-management-7-key-tasks-and-7-tools-that-can-help/) [Postgres Versions: Supported Releases, EOL Dates &amp; Upgrades](https://www.instaclustr.com/education/postgresql/postgres-versions-supported-releases-eol-dates-upgrades/) [Postgres hosting: 5 deployment options and how to choose](https://www.instaclustr.com/education/postgresql/postgres-hosting-5-deployment-options-and-how-to-choose/) [Postgres vs MSSQL: 10 Key Differences and How to Choose](https://www.instaclustr.com/education/postgresql/postgres-vs-mssql-10-key-differences-and-how-to-choose/) [Postgres vs MongoDB: 10 Key Differences and How to Choose](https://www.instaclustr.com/education/postgresql/postgres-vs-mongodb-10-key-differences-and-how-to-choose/) [PostgreSQL tuning: 10 things you can do to improve DB performance](https://www.instaclustr.com/education/postgresql/postgresql-tuning-10-things-you-can-do-to-improve-db-performance/) [PostgreSQL vs SQL Server: 14 key differences and how to choose](https://www.instaclustr.com/education/postgresql/postgresql-vs-sql-server-14-key-differences-and-how-to-choose/) [PostgreSQL® vs. MySQL™: 10 key differences and how to choose](https://www.instaclustr.com/education/postgresql/postgresql-vs-mysql-10-key-differences-and-how-to-choose/) [PostgreSQL® high availability: Methods, topologies and tips](https://www.instaclustr.com/education/postgresql/postgresql-high-availability-methods-topologies-and-tips/) [PostgreSQL® performance factors and 7 ways to supercharge performance](https://www.instaclustr.com/education/postgresql/postgresql-performance-factors-and-7-ways-to-supercharge-performance/) [PostgreSQL® tutorial: Get started with PostgreSQL in 4 easy steps](https://www.instaclustr.com/education/postgresql/postgresql-tutorial-get-started-with-postgresql-in-4-easy-steps/) [Scaling PostgreSQL®: Challenges, tools, and best practices](https://www.instaclustr.com/education/postgresql/scaling-postgresql-challenges-tools-and-best-practices/) [Top 15 PostgreSQL® best practices for 2026](https://www.instaclustr.com/education/postgresql/top-10-postgresql-best-practices-for-2025/) 

  

 

  ### Related content

 [ What is vector similarity search? Pros, cons, and 5 tips for success 

 

 Vector similarity search is an information retrieval technique that matches data on semantic meaning rather than exact keyword ... 

 

 

 

 

 

 

 ](https://www.instaclustr.com/education/vector-database/what-is-vector-similarity-search-pros-cons-and-5-tips-for-success/) 

 [ What are managed database services and 7 key capabilities 

 

 A managed database service (MDS) allows organizations to outsource the maintenance and management of database systems to a third-... 

 

 

 

 

 

 

 ](https://www.instaclustr.com/education/data-architecture/what-are-managed-database-services-and-7-key-capabilities/) 

 [ Vector search vs semantic search: 4 key differences and how to choose 

 

 Vector search finds items in a dataset using vectors. Semantic search boosts accuracy by grasping searcher intent and term context... 

 

 

 

 

 

 

 ](https://www.instaclustr.com/education/vector-database/vector-search-vs-semantic-search-4-key-differences-and-how-to-choose/) 

 

  Spin up a cluster  
In minutes
------------------------------

 

 [ Check it out ](/platform/)
