I accidentally ran and committed drop schema information_schema cascade on postgres 15.4 as a DBA.
How to recreate the said schema?
1 Answer 1
Create a new database, take a pg_dump of the database where you dropped information_schema and restore it to the new database.
Then you can drop the broken database and rename the new copy, and you have got the information_schema back.
answered Nov 1, 2024 at 6:51
Laurenz Albe
258k22 gold badges314 silver badges391 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-sql
pg_dump -d otherdb_name -n information_schema -U postgres -f info_sch.sqland thenpsql -d db_name -U postgres -f info_sch.sql. You want to make sure the other db is the same major version as the one you want to restore to as the information_schema contains views over the Postgres system catalogs and they can change between major versions.CREATE DATABASE dummy_dband then use thepg_dumpcommand I provided previously against that database. Per Frank Heikens , make sure you do a backup of your current database before making any changes.