Skip to main content

Drop View

Drop a view. Only the view's definition is removed; the tables it reads are unchanged. Run it in a SQL paragraph, or in a Magpie paragraph as sql(DROP VIEW …), where it runs immediately and leaves result unchanged.

Only views can be dropped this way. To drop a table that holds data, use the Magpie Drop Table command: DROP TABLE isn't supported as a SQL statement.

Syntax​

DROP VIEW [IF EXISTS] <view>

Parameters​

view​

String — The view to drop, as view or schema.view, in the current repository. Temporary views can be dropped too.

Options​

if exists​

If the view doesn't exist, do nothing. Magpie prints View "<view>" does not exist. Skipped drop operation.

Examples​

DROP VIEW IF EXISTS sales.open_orders

Errors​

MessageCause
View "<view>" does not exist.There is no such view, and IF EXISTS wasn't given.
DROP VIEW cannot drop "<table>": it is not a view (only tables with SQL persistence are views). Use the Magpie command 'drop table <table>' instead.The table holds data. This is an error even with IF EXISTS.
DROP VIEW does not support a repository-qualified target …The view names a repository. Run use repository and name the view without it.
DROP TABLE is not supported as a SQL statement. Use the Magpie command 'drop table <name> [if exists] [with delete]' instead.DROP TABLE was run as SQL.

Security​

Requires Write permission on the view.