Remove all tables in Postgres
Got access to psql console on remote server and want to remove tables to import something else?
> DROP TABLE stuff;
ERROR: cannot drop table stuff because other objects depend on it
DETAIL: table other_stuff depends on table stuff.
Whops. Let's try - remove it with all tables that reference stuff
:
> DROP TABLE stuff CASCADE;
drop cascades to table other_stuff
DROP TABLE
This was the shotgun way. Now nuclear option:
> DROP SCHEMA public CASCADE;
drop cascades to table stuff
drop cascades to table other_stuf
drop cascades to table even_more_stuff;
DROP SCHEMA
Written by Wojtek Kruszewski
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Postgresql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#