![]() ![]() routines (aggregate functions, functions, procedures).constraints on tables (FK, PK, CHECK, UNIQUE).you can put it between BEGIN and either ROLLBACK to just test it out or COMMIT to actually do the deed) and cleans up “all” database objects… well, all those used in the database our application uses or I could sensibly add, which is: truncating all tables, Endre Both has provided a similarily well-executed (direct execution) statement a month later.įor the cases where you can’t just DROP SCHEMA public CASCADE, DROP OWNED BY current_user or something, here’s a stand-alone SQL script I wrote, which is transaction-safe (i.e. Note: my answer is about really deleting the tables and other database objects for deleting all data in the tables, i.e. ![]() I just need help on the "deleting data on staging db" part. Will automate "dumping data from production db", then "deleting data on staging db", and then "restoring data to staging db". I will have to remove all data and just insert only, so whatever it takes to find how to do this, am willing to go for it but need help obviously to start with. I don't have the option to drop and create the database for several reasons. I just want to remove data and insert new data that is all. I want to delete all data only so I don't have to drop and create the database and all that stuff. How do I delete all data in the staging server database first, before restoring the data from the production dump? pg_dump -h localhost -U adminuser -data-only -column-inserts maindb > maindb.sql I have created a fresh db dump from a production server with the -data-only and -column-inserts flags, so I only have a bunch of insert statements to insert data when performing a restore on a staging server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |