Cloud

DROP VIEW

The DROP VIEW statement removes a view. A view stores no data, so DROP VIEW removes only the view’s definition. The tables that the view reads do not change.

Syntax

DROP VIEW [IF EXISTS] [schema_name.]view_name;
  • IF EXISTS: Optional. Prevents an error if the view does not exist.

  • schema_name: Optional. The Redpanda SQL schema that contains the view.

  • view_name: Name of the view to remove. Each DROP VIEW statement removes one view.

Behavior

  • You cannot drop a view while another view reads it. The statement fails with cannot drop view <view-name> because other objects depend on it. Drop the dependent view first.

  • The DROP VIEW statement has no CASCADE or RESTRICT option.

  • To drop a table, use DROP TABLE instead.

Permissions

Only the owner of the view or a superuser can drop it. Other users get permission denied: must be owner of table <view-name>.

Examples

Remove a view:

DROP VIEW large_orders;

Remove a view only if it exists:

DROP VIEW IF EXISTS large_orders;

Remove a view and the view that reads it. Drop the dependent view first:

DROP VIEW top_customers;
DROP VIEW large_orders;