I had a table from which I wanted to delete a lot of rows but that was failing because of memory constraints. I saw a suggestion to "simply" copy all the rows that I don't want to delete into a new table, drop the old table, then rename the new table to the old table's name. That would be fine except for other objects that depend on the original table. From what I can tell that means I'd have to drop cascade and then recreate everything that depends on the original table.
Is there a way to either script everything that depends on the original table so I can easily recreate them in pgadmin or psql?
Alternatively, is there a way to ignore the dependency long enough to delete the old table and rename the new table to the old table's name?
I believe this is how pg_repack works so there must be a way.