A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/postgresql/postgresql-psql-commands/ below:

PostgreSQL - Psql commands - GeeksforGeeks

PostgreSQL - Psql commands

Last Updated : 12 Jul, 2025

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 PostgreSQL

Here are the top 22 PSQL commands that are frequently used when querying a PostgreSQL database:

Serial No. Command Description 1 psql -d database -U user -W Connects to a database under a specific user 2 psql -h host -d database -U user -W Connect to a database that resides on another host 3 psql -U user -h host "dbname=db sslmode=require" Use SSL mode for the connection 4 \c dbname Switch connection to a new database 5 \l List available databases 6 \dt List available tables 7 \d table_name Describe a table such as a column, type, modifiers of columns, etc. 8 \dn List all schemes of the currently connected database 9 \df List available functions in the current database 10 \dv List available views in the current database 11 \du List all users and their assign roles 12 SELECT version(); Retrieve the current version of PostgreSQL server 13 \g Execute the last command again 14 \s Display command history 15 \s filename Save the command history to a file 16 \i filename Execute psql commands from a file 17 \? Know all available psql commands 18 \h Get help 19 \e Edit command in your own editor 20 \a Switch from aligned to non-aligned column output 21 \H Switch the output to HTML format 22 \q Exit psql shell Additional Information:
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.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4