Back to Materialize

DROP CONNECTION

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

1231.7 KB
Original Source

DROP CONNECTION removes a connection from Materialize. If there are sources depending on the connection, you must explicitly drop them first, or use the CASCADE option.

Syntax

mzsql
DROP CONNECTION [IF EXISTS] <connection_name> [CASCADE|RESTRICT];
Syntax elementDescription
IF EXISTSOptional. If specified, do not return an error if the specified connection does not exist.
connection_name>The connection you want to drop. For available connections, see SHOW CONNECTIONS.
CASCADEOptional. If specified, remove the connection and its dependent objects.
RESTRICTOptional. Do not drop the connection if it has dependencies. (Default)

Examples

Dropping a connection with no dependencies

To drop an existing connection, run:

mzsql
DROP CONNECTION kafka_connection;

To avoid issuing an error if the specified connection does not exist, use the IF EXISTS option:

mzsql
DROP CONNECTION IF EXISTS kafka_connection;

Dropping a connection with dependencies

If the connection has dependencies, Materialize will throw an error similar to:

mzsql
DROP CONNECTION kafka_connection;
nofmt
ERROR:  cannot drop materialize.public.kafka_connection: still depended upon by catalog item
'materialize.public.kafka_source'

, and you'll have to explicitly ask to also remove any dependent objects using the CASCADE option:

mzsql
DROP CONNECTION kafka_connection CASCADE;

Privileges

The privileges required to execute this statement are:

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