Skip to main content
The DROP VIEW removes a from a database. The DROP VIEW statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .

Required privileges

The user must have the DROP on the specified view(s). If CASCADE is used to drop dependent views, the user must have the DROP privilege on each dependent view as well.

Synopsis

drop_view syntax diagram

Parameters

ParameterDescription
MATERIALIZEDDrop a .
IF EXISTSDrop the view if it exists; if it does not exist, do not return an error.
view\_name\_listA comma-separated list of view names. To find view names, use: SELECT \* FROM information\_schema.tables WHERE table\_type = 'VIEW';
CASCADEDrop other views that depend on the view being dropped. CASCADE does not list views it drops, so should be used cautiously.
RESTRICT(Default) Do not drop the view if other views depend on it.

Examples

Remove a view (no dependencies)

In this example, other views do not depend on the view being dropped.

Remove a view (with dependencies)

In this example, another view depends on the view being dropped. Therefore, it’s only possible to drop the view while simultaneously dropping the dependent view using CASCADE. CASCADE drops all dependent views without listing them, which can lead to inadvertent and difficult-to-recover losses. To avoid potential harm, we recommend dropping objects individually in most cases.

See also