DROP_VIEW(7pg18)
๐ NAME ๐
DROP_VIEW โ bestie, it's how you remove a view. That's it. That's the whole job. โจ
๐ SYNOPSIS ๐
DROP VIEW [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
๐ฆ DESCRIPTION ๐ฆ
Okay so DROP VIEW drops an existing view. Simple, clean, iconic. ๐ธ
But listen โ there's a whole vibe check you have to pass first: to execute this command you must be the owner of the view. Not a friend of the owner. Not someone who once saw the view in a group chat. The owner. Periodt. ๐
โจ PARAMETERS โจ
IF EXISTSโ the "no drama please" flag ๐. If the view doesn't exist, don't throw an error. Instead, a notice gets issued. So like, it still tells you, just gently. ๐ซถnameโ the name of the view to remove, and yes it can be optionally schema-qualified. Somyschema.myviewis valid, go off. ๐CASCADEโ the "and take everyone with it" option ๐ญ๐ฅ. This automatically drops objects that depend on the view (like other views, bestie, it's giving dominoes ๐ข๐ข๐ข), and in turn all objects that depend on those objects. See Section 5.15 for the full lore.RESTRICTโ the "actually no, don't" option ๐ . This refuses to drop the view if any objects depend on it. This is the default, so if you don't say anything, the cautious girlie behavior is what you get. No accidental mass deletion energy here. ๐
โ ๏ธ Heads up bestie: CASCADE is not playing. It chains. Views on views on views. Make sure you know what's downstream before you send it. ๐
๐ EXAMPLES ๐
This command will remove the view called kinds:
DROP VIEW kinds;
Clean. One line. Slayed. โจ
๐ COMPATIBILITY ๐
So this command conforms to the SQL standard โ mostly. Two little asterisks, bestie:
- The standard only allows one view to be dropped per command. PostgreSQL said "what if we let you do a bunch," because why not. ๐
- Apart from the
IF EXISTSoption, which is a PostgreSQL extension โ the standard didn't think of it, we did. ๐
๐ธ SEE ALSO ๐ธ
ALTER VIEW(ALTER_VIEW(7))CREATE VIEW(CREATE_VIEW(7))
okay that's the whole page bestie, go forth and drop responsibly ๐โจ
this was PostgreSQL 18.6 documentation, dated 2026 โ ty for coming to my TED talk, mwah ๐๐ฆ๐
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms