Thread: DROP VIEW name WITHOUT TYPE

DROP VIEW name WITHOUT TYPE

From
Przemysław Sztoch
Date:

Is it possible to extend DROP VIEW command:

DROP VIEW [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT | WITHOUT TYPE]

I want to allow to DROP VIEW if any objects depend on it.

Am I right, If we leave (or convert) TYPE linked to VIEW, then DROP will be possible?

--
Przemysław Sztoch | Mobile +48 509 99 00 66


Re: DROP VIEW name WITHOUT TYPE

From
"David G. Johnston"
Date:
On Fri, Nov 8, 2024 at 7:51 AM Przemysław Sztoch <przemyslaw@sztoch.pl> wrote:

Is it possible to extend DROP VIEW command:

DROP VIEW [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT | WITHOUT TYPE]

I want to allow to DROP VIEW if any objects depend on it.

Am I right, If we leave (or convert) TYPE linked to VIEW, then DROP will be possible?

No...you can't write "select * from type_name" and that is going to be the most common kind of dependency you have to deal with.

David J.

Re: DROP VIEW name WITHOUT TYPE

From
Tom Lane
Date:
=?UTF-8?Q?Przemys=C5=82aw_Sztoch?= <przemyslaw@sztoch.pl> writes:
> Am I right, If we leave (or convert) TYPE linked to VIEW, then DROP will be possible?

No ...

CREATE VIEW level1 AS SELECT * FROM base_table;
CREATE VIEW level2 AS SELECT * FROM level1;

You can't drop level1 without dropping level2; the composite type
associated with level1 doesn't enter into that.  I'd actually
find it rather surprising if there are many real-world cases where
other objects have a dependency on a view's composite type but not
on the view itself.

            regards, tom lane