Back to Materialize

DROP SOURCE

doc/user/content/sql/drop-source.md

1231.5 KB
Original Source

DROP SOURCE removes a source from Materialize. If there are objects depending on the source, you must explicitly drop them first, or use the CASCADE option.

Syntax

mzsql
DROP SOURCE [IF EXISTS] <source_name> [RESTRICT|CASCADE];
Syntax elementDescription
IF EXISTSOptional. If specified, do not return an error if the named source does not exist.
<source_name>The name of the source you want to remove.
CASCADEOptional. If specified, remove the source and its dependent objects.
RESTRICTOptional. Do not remove this source if it has dependent objects. (Default.)

Examples

Remove a source with no dependent objects

mzsql
SHOW SOURCES;
nofmt
...
my_source
mzsql
DROP SOURCE my_source;

Remove a source with dependent objects

mzsql
SHOW SOURCES;
nofmt
...
my_source
mzsql
DROP SOURCE my_source CASCADE;

Remove a source only if it has no dependent objects

You can use either of the following commands:

  • mzsql
    DROP SOURCE my_source;
    
  • mzsql
    DROP SOURCE my_source RESTRICT;
    

Do not issue an error if attempting to remove a nonexistent source

mzsql
DROP SOURCE IF EXISTS my_source;

Privileges

The privileges required to execute this statement are:

{{% include-headless "/headless/sql-command-privileges/drop-source" %}}