We're refactoring the structure of our tables and views and one of the improvements is changing one table (which is updated "manually" from a java class) to a continuous view.
The name of the view has to be the same with the old table and the old data has to be kept, so I think these steps would be logical:
- ALTER TABLE old_table RENAME TO old_table_temp
- Create the new continuous view
- INSERT INTO new_continuous_view SELECT * FROM old_table_temp
- DROP old_table_temp
The problem that I have right now is that when renaming the table, all the dependent views will still be depending on the newly named table so I can not drop it. The error looks like this:
analytics=> drop table renamed_table;
ERROR: cannot drop table renamed_table because other objects depend on it
DETAIL: continuous view cview1 depends on table renamed_table
continuous view cview2 depends on table renamed_table
continuous view cview3 depends on table renamed_table
continuous view cview4 depends on table renamed_table
Any idea would be appreciated, even if it's a different approach.