Thread: Adding a column to a VIEW which has dependent objects.

Adding a column to a VIEW which has dependent objects.

From
Rajesh Kumar Mallah
Date:
Dear PostgreSQL gurus,


How do people extend a parent view which has
lot of dependent views?

The parent view cannot be dropped because that will
require recreating a dozen of dependent views.

Is there any workaround.

Also is there an easy way of dumping the definitions
of all the dependent views of a given object. Does information_schema
helps here.


Regds
mallah.




Re: Adding a column to a VIEW which has dependent objects.

From
Tom Lane
Date:
Rajesh Kumar Mallah <mallah@trade-india.com> writes:
> How do people extend a parent view which has
> lot of dependent views?
> The parent view cannot be dropped because that will
> require recreating a dozen of dependent views.

You're out of luck, you'll have to drop and remake them all.
In future we could think about some kind of ALTER VIEW ADD COLUMN
operation, but it ain't there now.

(I suppose if you were really desperate you could think about manually
hacking the system catalogs, but this would be pretty risky on a
production database.)

> Also is there an easy way of dumping the definitions
> of all the dependent views of a given object.

You can chase the links in pg_depend to see what the dependent objects
are, but extracting their definitions would be a tad harder ...
        regards, tom lane


Re: Adding a column to a VIEW which has dependent objects.

From
"scott.marlowe"
Date:
On Sat, 10 Jan 2004, Tom Lane wrote:

> Rajesh Kumar Mallah <mallah@trade-india.com> writes:
> > How do people extend a parent view which has
> > lot of dependent views?
> > The parent view cannot be dropped because that will
> > require recreating a dozen of dependent views.
> 
> You're out of luck, you'll have to drop and remake them all.
> In future we could think about some kind of ALTER VIEW ADD COLUMN
> operation, but it ain't there now.
> 
> (I suppose if you were really desperate you could think about manually
> hacking the system catalogs, but this would be pretty risky on a
> production database.)
> 
> > Also is there an easy way of dumping the definitions
> > of all the dependent views of a given object.
> 
> You can chase the links in pg_depend to see what the dependent objects
> are, but extracting their definitions would be a tad harder ...

Note that the definitions for views are stored in pg_views as well.