pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
drop view even with dependencies?
2+ messages / 2 participants
[nested] [flat]

* drop view even with dependencies?
@ 2005-03-07 21:38  Henry Ortega <juandelacruz@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Henry Ortega @ 2005-03-07 21:38 UTC (permalink / raw)
  To: pgsql-sql

Is there a way to drop a VIEW in postgres without
the need to drop all the dependencies?

VIEW 3
    |
VIEW 2
    |
VIEW 1

In my case, VIEW 3 depends on VIEW 2, and VIEW 2 depends
on VIEW 1.

Is there a way to drop VIEW 3 without dropping VIEW 1 and 2?
I tried CREATE OR REPLACE VIEW but replace will only work
if they have the same number of fields.

Also with tables, can I drop a table even if there are multiple views
that depend on it?

It's such a pain in the neck to have to drop all the dependencies and
recreate them all over again. Any help would greatly appreciated.
I am using Postgres 7.3.2



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: drop view even with dependencies?
@ 2005-03-08 01:17  Michael Fuhr <mike@fuhr.org>
  parent: Henry Ortega <juandelacruz@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Fuhr @ 2005-03-08 01:17 UTC (permalink / raw)
  To: Henry Ortega <juandelacruz@gmail.com>; +Cc: pgsql-sql

On Mon, Mar 07, 2005 at 04:38:53PM -0500, Henry Ortega wrote:

> Is there a way to drop a VIEW in postgres without
> the need to drop all the dependencies?
....
> Also with tables, can I drop a table even if there are multiple views
> that depend on it?

I'm not aware of a way.  It could be argued that doing so would be
A Bad Thing: a view has a particular meaning, and by dropping the
things the view depends on you'd be subverting that meaning.  The
DBMS doesn't know what your intentions are, so it doesn't allow you
to break the dependencies.

> It's such a pain in the neck to have to drop all the dependencies and
> recreate them all over again.

Do you not keep the definitions in a file?  It can be useful to
put all the necessary DROP and CREATE statements in a file, so
if you need to change anything you simply edit the file and run
"psql -f filename.sql".

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-03-08 01:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-07 21:38 drop view even with dependencies? Henry Ortega <juandelacruz@gmail.com>
2005-03-08 01:17 ` Michael Fuhr <mike@fuhr.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox