psql: The Command-Line Client
Connecting, describing tables, expanded output and the backslash commands you will use every day.
psql is PostgreSQL's interactive terminal. Besides running SQL, it has backslash meta-commands that describe the database without writing queries against the system catalogs. It is available everywhere PostgreSQL is, and many engineers prefer it to graphical tools for day-to-day work.
Meta-commands worth memorizing
SELECT * FROM employees -- and nothing happens SELECT * FROM employees;
psql sends a statement only when it sees the semicolon. Without it the prompt changes to -# and waits for more input.
Which psql command shows the indexes and constraints of the table projects?
How do you see how long a query takes in psql?
Turn on \timing; psql then prints 'Time: ... ms' after every statement. For a breakdown use EXPLAIN ANALYZE.