I use postgresql and I need to drop all the tables which are present in the schema. How can I delete from command prompt.
Postgresql – postgres how to drop all the table in a schema through command
postgresqlpostgresql-9.4
Related Question
- PostgreSQL – How to Drop All Functions
- Postgresql how to compare the tables which are present in different database
- Postgresql – Command to add column to all tables in a schema
- PostgreSQL – How to Delete All Data in a Database
- PostgreSQL – Copy Table Functions to Another Database Schema
- Postgresql – Generate table of all databases and schema with a single psql command
Best Answer
You want to use the
CASCADE
option ofDROP SCHEMA
. From the documentation:BE CAREFUL - emphasis above mine.
Obviously you'll need to recreate the schema afterwards.
To just drop all tables in the current schema, you can use this script:
Change
WHERE schemaname = current_schema()
if you want to drop all of the tables in a different schema.