0% found this document useful (0 votes)
14 views2 pages

Complément 2 - Commandes PSQL

The document provides commands for interacting with PostgreSQL databases using psql including connecting, listing databases and schemas, and managing databases by creating and deleting them.

Uploaded by

Aïcha BOUCHRAÂ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Complément 2 - Commandes PSQL

The document provides commands for interacting with PostgreSQL databases using psql including connecting, listing databases and schemas, and managing databases by creating and deleting them.

Uploaded by

Aïcha BOUCHRAÂ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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;

You might also like