Last active
March 2, 2017 14:24
-
-
Save developer88/2d0626dc0fe8b2f7e2eb to your computer and use it in GitHub Desktop.
Some PostgreSQL snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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