Principales commandes pour PSQL
Lien : https://www.postgresqltutorial.com/postgresql-cheat-sheet/
Access the PostgreSQL server from psql with a specific user :
psql -U [username];
For example, the following command uses the postgres user to access
the PostgreSQL database server :
psql -U postgres
Connect to a specific database :
\c database_name;
For example, the following command connects to
the dvdrental database :
\c dvdrental;
To quit the psql :
\q
List all databases in the PostgreSQL database server
\l
List all schemas :
\dn
List all views :
\dv
Lists all tables in a current database :
\dt
Or to get more information on tables in the current database :
\dt+
Get detailed information on a specific table :
\d+ table_name
Managing databases
Create a new database :
CREATE DATABASE [IF NOT EXISTS] db_name;
Delete a database permanently :
DROP DATABASE [IF EXISTS] db_name;