DROP_VIEW(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… 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. So myschema.myview is 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 EXISTS option, which is a PostgreSQL extension โ€” the standard didn't think of it, we did. ๐ŸŽ€

๐ŸŒธ SEE ALSO ๐ŸŒธ


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