Skip to content

Instantly share code, notes, and snippets.

@rainly
Forked from developer88/.profile
Created March 2, 2017 14:24
Show Gist options
  • Save rainly/34a7691cfe272d63cf598b6605f66ab9 to your computer and use it in GitHub Desktop.
Save rainly/34a7691cfe272d63cf598b6605f66ab9 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