Skip to content

Instantly share code, notes, and snippets.

@developer88
Last active March 2, 2017 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save developer88/2d0626dc0fe8b2f7e2eb to your computer and use it in GitHub Desktop.
Save developer88/2d0626dc0fe8b2f7e2eb to your computer and use it in GitHub Desktop.
Some PostgreSQL snippets
alias 'pg_sql_restore'='PGPASSWORD=SOMEPASSWORD psql -cO -U username -d dbname -h localhost -f ' # + set path to backup file
alias 'pg_tar_restore'='PGPASSWORD=SOMEPASSWORD pg_restore -cO -U username -d dbname -h localhost ' # + set path to backup file
-- Create statements to delete all tables from current DB
SELECT CONCAT( 'DROP TABLE ', table_name , ' CASCADE;' ) FROM information_schema.tables where table_schema = 'public';
-- Show all tables in current DB
SELECT table_schema,table_name FROM information_schema.tables where table_schema = 'public';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment