PostgreSQL - Psql commands Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report PostgreSQL, or Postgres, is an object-relational database management system that utilizes the SQL language. PSQL is a powerful interactive terminal for working with the PostgreSQL database. It enables users to execute queries efficiently and manage databases effectively.Here, we highlight some of the most frequently used PSQL commands, detailing their functionalities to enhance your PostgreSQL experience.Top PSQL Commands in PostgreSQLHere are the top 22 PSQL commands that are frequently used when querying a PostgreSQL database:Serial No.CommandDescription1psql -d database -U user -WConnects to a database under a specific user2psql -h host -d database -U user -WConnect to a database that resides on another host3psql -U user -h host "dbname=db sslmode=require"Use SSL mode for the connection4\c dbnameSwitch connection to a new database5\lList available databases6\dtList available tables7\d table_nameDescribe a table such as a column, type, modifiers of columns, etc.8\dnList all schemes of the currently connected database9\dfList available functions in the current database10\dvList available views in the current database11\duList all users and their assign roles12SELECT version();Retrieve the current version of PostgreSQL server13\gExecute the last command again14\sDisplay command history15\s filenameSave the command history to a file16\i filenameExecute psql commands from a file17\?Know all available psql commands18\hGet help19\eEdit command in your own editor20\aSwitch from aligned to non-aligned column output21\HSwitch the output to HTML format22\qExit psql shellAdditional Information:The -d option in psql commands is used to state the database name.The -U option specifies the database user.The -h option indicates the host on which the database server resides.The \h ALTER TABLE can be used to get detailed information on the ALTER TABLE statement.Conclusion Understanding and utilizing Psql commands can significantly enhance your efficiency when working with PostgreSQL. Here we provided an overview of essential commands to help you manage your databases more effectively. These commands are vital tools for any PostgreSQL user.The psql interface is powerful and allows you to do many things, including running SQL statements. If you want to get started with PostgreSQL or deepen your knowledge, check out our PostgreSQL Tutorial. You can also check out the Postgre articles on our blog. Comment More info R rajukumar19 Follow Improve Article Tags : PostgreSQL postgreSQL-basics Explore BasicsPostgreSQL Tutorial8 min readWhat is PostgreSQL - Introduction2 min readInstall PostgreSQL on Windows2 min readInstall PostgreSQL on Mac3 min readDatabase OperationsPostgreSQL - Create Database5 min readPostgreSQL - Loading a Database3 min readPostgreSQL ALTER DATABASE3 min readPostgreSQL - Rename Database4 min readPostgreSQL - Show Databases3 min readData TypesPostgreSQL - Data Types5 min readPostgreSQL - Boolean Data Type4 min readPostgreSQL - CHAR Data Type5 min readPostgreSQL - VARCHAR Data Type3 min readPostgreSQL - NUMERIC Data Type5 min readPostgreSQL - Date Data Type4 min readPostgreSQL - TIME Data Type4 min readPostgreSQL - JSON Data Type4 min readPostgreSQL - CREATE DOMAIN3 min readQuerying TablesPostgreSQL - SELECT3 min readPostgreSQL - ORDER BY clause2 min readPostgreSQL - WHERE clause6 min readPostgreSQL FETCH Clause4 min readPostgreSQL - IN operator4 min readPostgreSQL - HAVING clause4 min readPostgreSQL - GROUP BY clause4 min readPostgreSQL - LIKE operator5 min readPostgreSQL - BETWEEN Operator3 min readTable OperationsPostgreSQL - CREATE TABLE5 min readPostgreSQL - SELECT INTO4 min readPostgreSQL - CREATE SEQUENCE4 min readPostgreSQL - ALTER TABLE6 min readPostgreSQL - ADD COLUMN4 min readPostgreSQL - DROP COLUMN2 min readPostgreSQL - Rename Table2 min readPostgreSQL - DROP TABLE5 min readPostgreSQL - TRUNCATE TABLE4 min readPostgreSQL - Copy a Table3 min readPostgreSQL - Comparing Tables3 min readPostgreSQL - Show Tables4 min readModifying DataPostgreSQL - INSERT4 min readPostgreSQL - Insert Multiple Values in Various Rows3 min readPostgreSQL UPDATE Statement5 min readPostgreSQL - DELETE4 min readPostgreSQL - Upsert4 min readConditionalsPostgreSQL - CASE3 min readPostgreSQL COALESCE5 min readPostgreSQL - NULLIF() Function4 min readPostgreSQL - CAST3 min readControl FlowPostgreSQL - IF Statement5 min readPostgreSQL - CASE Statement4 min readPostgreSQL - Loop Statement3 min readPostgreSQL - While Loops4 min readPostgreSQL - Exit Statement3 min readPostgreSQL - Continue3 min readTransactions & ConstraintsPostgreSQL - Transactions4 min readPostgreSQL - COMMIT4 min readPostgreSQL - Primary Key4 min readPostgreSQL - Foreign Key5 min readPostgreSQL - CHECK Constraint2 min readPostgreSQL - UNIQUE Constraint3 min readPostgreSQL - NOT NULL Constraint3 min readJOINS & SchemasPostgreSQL - Joins5 min readPostgreSQL - LEFT JOIN5 min readPostgreSQL - INNER JOIN2 min readPostgreSQL - FULL OUTER JOIN4 min readPostgreSQL - SELF JOIN4 min readPostgreSQL - Schema5 min readPostgreSQL - CREATE SCHEMA5 min readPostgreSQL - DROP SCHEMA4 min readPostgreSQL - ALTER SCHEMA3 min read Like