drop view with out cascading the dependents

Started by Ravi Katkarover 15 years ago7 messagesgeneral
Jump to latest
#1Ravi Katkar
Ravi.Katkar@infor.com

Hi List,

Is there any feature to drop the view with out cascading the dependents.

Below is my requirement.

I have a view which is dependent on the other view/table. I wanted to drop the view dynamically and recreate the view with same name ( definition of view will differ ) with out cascading its dependents, after that I created the view it should have its dependents as to that of older one.

Thanks in advance.

Thanks,
Ravi Katkar

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ravi Katkar (#1)
Re: drop view with out cascading the dependents

Ravi Katkar <Ravi.Katkar@infor.com> writes:

Is there any feature to drop the view with out cascading the dependents.

No. But why don't you use CREATE OR REPLACE VIEW?

regards, tom lane

#3Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Tom Lane (#2)
Re: drop view with out cascading the dependents

On Tue, Oct 19, 2010 at 3:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Ravi Katkar <Ravi.Katkar@infor.com> writes:

Is there any feature to drop the view with out cascading the dependents.

No.  But why don't you use CREATE OR REPLACE VIEW?

only caveat is, it won't work if he adds/removes any columns. CREATE
OR REPLACE VIEW is rather useless in most practical implementations.

--
GJ

#4Ravi Katkar
Ravi.Katkar@infor.com
In reply to: Grzegorz Jaśkiewicz (#3)
Re: drop view with out cascading the dependents

That's true . it wont work if we add remove the columns.
I wanted to add column to view and change the data type to existing column

-----Original Message-----
From: Grzegorz Jaśkiewicz [mailto:gryzman@gmail.com]
Sent: Tuesday, October 19, 2010 7:50 PM
To: Tom Lane
Cc: Ravi Katkar; pgsql-general@postgresql.org
Subject: Re: [GENERAL] drop view with out cascading the dependents

On Tue, Oct 19, 2010 at 3:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Ravi Katkar <Ravi.Katkar@infor.com> writes:

Is there any feature to drop the view with out cascading the dependents.

No.  But why don't you use CREATE OR REPLACE VIEW?

only caveat is, it won't work if he adds/removes any columns. CREATE
OR REPLACE VIEW is rather useless in most practical implementations.

--
GJ

#5Ben Carbery
ben.carbery@gmail.com
In reply to: Ravi Katkar (#4)
Re: drop view with out cascading the dependents

You can always recreate the dependent views in the same process, since you
won't lose any data. If there are also linked tables you could use COPY
before deleting and recreating, it's fairly fast.

But..does the structure of your data really need to change? Just guessing,
but it just sounds a little like adjusting the schema to suit an
application, not the data.

2010/10/20 Ravi Katkar <Ravi.Katkar@infor.com>

Show quoted text

That's true . it wont work if we add remove the columns.
I wanted to add column to view and change the data type to existing column

#6Merlin Moncure
mmoncure@gmail.com
In reply to: Grzegorz Jaśkiewicz (#3)
Re: drop view with out cascading the dependents

2010/10/19 Grzegorz Jaśkiewicz <gryzman@gmail.com>:

On Tue, Oct 19, 2010 at 3:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Ravi Katkar <Ravi.Katkar@infor.com> writes:

Is there any feature to drop the view with out cascading the dependents.

No.  But why don't you use CREATE OR REPLACE VIEW?

only caveat is, it won't work if he adds/removes any columns. CREATE
OR REPLACE VIEW is rather useless in most practical implementations.

In recent versions of postgres (I think 8.4+?) you can add columns to
the view via create/replace (not drop of course). This greatly
reduces the practical annoyances of dropping view dependencies, at
least for me...

merlin

#7Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Merlin Moncure (#6)
Re: drop view with out cascading the dependents

2010/10/20 Merlin Moncure <mmoncure@gmail.com>:

In recent versions of postgres (I think 8.4+?) you can add columns to
the view via create/replace (not drop of course).  This greatly
reduces the practical annoyances of dropping view dependencies, at
least for me...

Ok, We're still on 8.3 here, and management reluctant to upgrade.
(which makes some sense).

--
GJ