-
-
Save shilovk/748466a23bc2a146d60d8b2f5ea7370e to your computer and use it in GitHub Desktop.
Dropping tables in a PostgreSQL database by table owner
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
# first, login with psql | |
psql -U user_name -W -d database_name -h ip_address | |
# set output for all queries | |
\o file_name.sql | |
# run this query | |
select 'drop table if exist "'|| tablename ||'" cascade;' from pg_tables where tableowner='user_name' and schemaname='public'; | |
# logout from psql | |
\q | |
# run sql script from commandline | |
psql -U user_name -W -d database_name -f file_name.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment