Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Best way to drop / recreate a table that has dependent views?

$
0
0

Problem


PostgreSQL does not have logical column reordering, at least not in 9.2

If columns need to be added in the middle of a large table and order is important, the best way is to drop and recreate the table. However, if there are external dependencies, such as views, this is not possible without DROP CASCADE.

If there are lots of views built on this table, it seems like a lot of work. Is there any way to accomplish this without having to drop/recreate the views?

Hopeful


My hope is that you can do something like DROP CASCADE DEFERRED in a transaction. So that the dependencies only drop if the original table doesn’t exist at the end of the commit, but giving you the ability to drop the table, create the table, and commit without losing changes.


Viewing all articles
Browse latest Browse all 1138

Trending Articles