Skip to content

Instantly share code, notes, and snippets.

@trey
Last active December 27, 2015 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trey/7365937 to your computer and use it in GitHub Desktop.
Save trey/7365937 to your computer and use it in GitHub Desktop.
Basic PostgreSQL Commands

Basic PostgreSQL Commands

Create a database.

$ createdb [database]

Drop a database.

$ dropdb [database]

Dump a database.

$ pg_dump [database] > [database].sql

Load a database dump.

$ pg_restore -d [database] [database].sql

List all tables.

\dt

Connect to a database.

\c [database]

Delete rows in a table (leave the WHERE clause off to delete all rows).

DELETE FROM [TABLE] WHERE ...;

Source

@trey
Copy link
Author

trey commented Nov 8, 2013

This is a Solutions Log post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment