Skip site navigation (1) Skip section navigation (2)

preventing ALTER TABLE RENAME from changing view definitions?

From: "George Pavlov" <gpavlov(at)mynewplace(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: preventing ALTER TABLE RENAME from changing view definitions?
Date: 2007-02-26 23:13:18
Message-ID: 8C5B026B51B6854CBE88121DBF097A868C4D14@ehost010-33.exch010.intermedia.net (view raw or flat)
Thread:
Lists: pgsql-general
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;

In response to

Responses

pgsql-general by date

Next:From: D. Dante LorensoDate: 2007-02-26 23:15:10
Subject: Re: Most efficient report of number of records in all tables?
Previous:From: Dann CorbitDate: 2007-02-26 23:01:04
Subject: Re: Most efficient report of number of records in all tables?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group