Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Created December 10, 2013 19:25
Show Gist options
  • Save greyaperez/7896571 to your computer and use it in GitHub Desktop.
Save greyaperez/7896571 to your computer and use it in GitHub Desktop.
Common/Important PostgreSQL Commands
# Common/Important Commands
# See Cheatsheet - http://www.postgresonline.com/downloads/special_feature/postgresql83_cheatsheet.pdf
# Admin
psql
\list lists all databases
\dt lists all tables in the current database
\q quit
# Import SQL File
\i {sql file}
CREATE DATABASE "store"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8';
CREATE TABLE orders(
order_id serial NOT NULL,
order_addeddt timestamp without time zone,
order_rating rating,
CONSTRAINT pk_orders_order_id PRIMARY KEY (order_id)
)
WITH (OIDS=FALSE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment