How to empty a SQL database? -
I am looking for a simple way to delete all data from a database and to structure (table, connection, etc.) ..). I am using postgreSQL but I think if there is a command to do this then it is not specific to postgrads.
Thank you,
Dump the database schema (-s tag) into one file: Delete the database: make it happy: Reinstall the schema only: This should work on PostgreSQL; For this, other DBMSs can have their own devices Edit: For the following comments, you can use the At this point, you have full database on DB-NAME, and there is a blank schema on DB-New-NAME. After you are sure everything is okay, use pg_dump code>. Drop the database, recreate it and load the schema.
pg_dump -s -f db.dump db-NAME
dropdb DB-NAME
createdb DB-NAME
pg_restore db.dump & gt; Psql DB-NAME
dropdb
command, And just create another database with the dump schema if everything went well, then you can leave the old database:
pg_dump -s -f db.dump db-NAME Created DB-New-name pg_restore db.dump & gt; Psql DB-NEW-NAME
dropdb DB-NAME
.
Comments
Post a Comment