-- Load data to Database
copy [table_name]from'/path/to/data/[data_name].csv'withDELIMITERAS E'\t';-- Load data from Database
copy [table_name]to'/path/to/data/[data_name].csv'DELIMITER',' CSV HEADER;
Explore table
-- see column name of tableselect column_name from information_schema.columnswhere table_name='[table_name]';-- see cardinality of a table satisfy predicatesselectcount(*)from[table_name]where[predicate];-- get 10 random tuples from tableselect*from[table_name]orderby random()limit10;-- get 10 top tuples from tableselect*from[table_name]limit10;
Role
-- see all roles
\du
-- see what role are you and what database are you in
\c
-- create new rolecreate role [new_user];-- set password for rolealter role [new_user]with password [your password];