Back to Materialize

DROP SECRET

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

1231.7 KB
Original Source

DROP SECRET removes a secret from Materialize's secret management system. If there are connections depending on the secret, you must explicitly drop them first, or use the CASCADE option.

Syntax

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

Examples

Dropping a secret with no dependencies

To drop an existing secret, run:

mzsql
DROP SECRET kafka_sasl_password;

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

mzsql
DROP SECRET IF EXISTS kafka_sasl_password;

Dropping a secret with dependencies

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

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

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

mzsql
DROP SECRET kafka_sasl_password CASCADE;

Privileges

The privileges required to execute this statement are:

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