Search Postgresql Archives

preventing ALTER TABLE RENAME from changing view definitions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently "ALTER TABLE ... RENAME TO ..." results in all views that
refer to the table to be rewritten with the new table name. This is a
good thing in the general case, but there are also situations where it
is not (e.g. temporarily renaming tables for data reorg reasons). I
can't seem to find a clean way to only rename the table without causing
change to the view. The ONLY keyword does not work in this case.
Anything I am missing (short of re-creating all views). I am on 8.1.

test=> create table a (col int);
CREATE TABLE
test=> create view v_a as select col from a;
CREATE VIEW
test=> \d v_a
      View "public.v_a"
 Column |  Type   | Modifiers 
--------+---------+-----------
 col    | integer | 
View definition:
 SELECT a.col
   FROM a;

test=> alter table a rename to b;
ALTER TABLE
test=> \d v_a
      View "public.v_a"
 Column |  Type   | Modifiers 
--------+---------+-----------
 col    | integer | 
View definition:
 SELECT a.col
   FROM b a;


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux