psql -U username -d dbname
\l
\dt
\d table_name
CREATE DATABASE dbname;
DROP DATABASE dbname;
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);
DROP TABLE table_name;
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
SELECT * FROM table_name;
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
DELETE FROM table_name WHERE condition;
COPY table_name TO 'file_path' DELIMITER ',' CSV HEADER;
COPY table_name FROM 'file_path' DELIMITER ',' CSV HEADER;
pg_dump dbname > backup.sql
psql -d dbname -f backup.sql
pg_ctl stop -D /path/to/data/directory
pg_ctl start -D /path/to/data/directory