# Appendix: Privileges by commands

| Command | Privileges |
| --- | --- |
| <a href="/materialize/35604/sql/alter-cluster" ><code>ALTER CLUSTER</code></a> | <ul> <li> <p>Ownership of the cluster.</p> </li> <li> <p>To rename a cluster, you must also have membership in the <code>&lt;new_owner_role&gt;</code>.</p> </li> <li> <p>To swap names with another cluster, you must also have ownership of the other cluster.</p> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-cluster-replica" ><code>ALTER CLUSTER REPLICA</code></a> | <ul> <li>Ownership of the cluster replica.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing cluster.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-connection" ><code>ALTER CONNECTION</code></a> | <ul> <li>Ownership of the connection.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the connection is namespaced by a schema.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-database" ><code>ALTER DATABASE</code></a> | <ul> <li>Ownership of the database.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-default-privileges" ><code>ALTER DEFAULT PRIVILEGES</code></a> | <ul> <li>Role membership in <code>role_name</code>.</li> <li><code>USAGE</code> privileges on the containing database if <code>database_name</code> is specified.</li> <li><code>USAGE</code> privileges on the containing schema if <code>schema_name</code> is specified.</li> <li><em>superuser</em> status if the <em>target_role</em> is <code>PUBLIC</code> or <strong>ALL ROLES</strong> is specified.</li> </ul>  |
| <a href="/materialize/35604/sql/alter-index" ><code>ALTER INDEX</code></a> | <ul> <li>Ownership of the index.</li> </ul>  |
| <a href="/materialize/35604/sql/alter-materialized-view" ><code>ALTER MATERIALIZED VIEW</code></a> | <ul> <li>Ownership of the materialized view.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the materialized view is namespaced by a schema.</li> </ul> </li> <li>In addition, to apply a replacement: <ul> <li>Ownership of the replacement materialized view.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-network-policy" ><code>ALTER NETWORK POLICY</code></a> | <ul> <li>Ownership of the network policy.</li> </ul>  |
| <a href="/materialize/35604/sql/alter-role" ><code>ALTER ROLE</code></a> | <ul> <li><code>CREATEROLE</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/alter-schema" ><code>ALTER SCHEMA</code></a> | <ul> <li>Ownership of the schema.</li> <li>In addition, <ul> <li>To swap with another schema: <ul> <li>Ownership of the other schema</li> </ul> </li> <li>To change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing database.</li> </ul> </li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-secret" ><code>ALTER SECRET</code></a> | <ul> <li>Ownership of the secret being altered.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the secret is namespaced by a schema.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-sink" ><code>ALTER SINK</code></a> | <ul> <li>Ownership of the sink being altered.</li> <li>In addition, <ul> <li>To change the sink from relation: <ul> <li><code>SELECT</code> privileges on the new relation being written out to an external system.</li> <li><code>CREATE</code> privileges on the cluster maintaining the sink.</li> <li><code>USAGE</code> privileges on all connections and secrets used in the sink definition.</li> <li><code>USAGE</code> privileges on the schemas that all connections and secrets in the statement are contained in.</li> </ul> </li> <li>To change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the sink is namespaced by a schema.</li> </ul> </li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-source" ><code>ALTER SOURCE</code></a> | <ul> <li>Ownership of the source being altered.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the source is namespaced by a schema.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-system-reset" ><code>ALTER SYSTEM RESET</code></a> | <ul> <li><a href="/materialize/35604/security/cloud/users-service-accounts/#organization-roles" ><em>Superuser</em> privileges</a></li> </ul>  |
| <a href="/materialize/35604/sql/alter-system-set" ><code>ALTER SYSTEM SET</code></a> | <ul> <li><a href="/materialize/35604/security/cloud/users-service-accounts/#organization-roles" ><em>Superuser</em> privileges</a></li> </ul>  |
| <a href="/materialize/35604/sql/alter-table" ><code>ALTER TABLE</code></a> | <ul> <li>Ownership of the table being altered.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the table is namespaced by a schema.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-type" ><code>ALTER TYPE</code></a> | <ul> <li>Ownership of the type being altered.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the type is namespaced by a schema.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/alter-view" ><code>ALTER VIEW</code></a> | <ul> <li>Ownership of the view being altered.</li> <li>In addition, to change owners: <ul> <li>Role membership in <code>new_owner</code>.</li> <li><code>CREATE</code> privileges on the containing schema if the view is namespaced by a schema.</li> </ul> </li> </ul>  |
| <a href="/materialize/35604/sql/comment-on" ><code>COMMENT ON</code></a> | <ul> <li>Ownership of the object being commented on (unless the object is a role).</li> <li>To comment on a role, you must have the <code>CREATEROLE</code> privilege.</li> </ul>  |
| <a href="/materialize/35604/sql/copy-from" ><code>COPY FROM</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the table.</li> <li><code>INSERT</code> privileges on the table.</li> </ul>  |
| <a href="/materialize/35604/sql/copy-to" ><code>COPY TO</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations and types in the query are contained in.</li> <li><code>SELECT</code> privileges on all relations in the query. <ul> <li>NOTE: if any item is a view, then the view owner must also have the necessary privileges to execute the view definition. Even if the view owner is a <em>superuser</em>, they still must explicitly be granted the necessary privileges.</li> </ul> </li> <li><code>USAGE</code> privileges on all types used in the query.</li> <li><code>USAGE</code> privileges on the active cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/create-cluster" ><code>CREATE CLUSTER</code></a> | <ul> <li><code>CREATECLUSTER</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/create-cluster-replica" ><code>CREATE CLUSTER REPLICA</code></a> | <ul> <li>Ownership of the cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/create-connection" ><code>CREATE CONNECTION</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>USAGE</code> privileges on all connections and secrets used in the connection definition.</li> <li><code>USAGE</code> privileges on the schemas that all connections and secrets in the statement are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/create-database" ><code>CREATE DATABASE</code></a> | <ul> <li><code>CREATEDB</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/create-index" ><code>CREATE INDEX</code></a> | <ul> <li>Ownership of the object on which to create the index.</li> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>CREATE</code> privileges on the containing cluster.</li> <li><code>USAGE</code> privileges on all types used in the index definition.</li> <li><code>USAGE</code> privileges on the schemas that all types in the statement are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/create-materialized-view" ><code>CREATE MATERIALIZED VIEW</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>CREATE</code> privileges on the containing cluster.</li> <li><code>USAGE</code> privileges on all types used in the materialized view definition.</li> <li><code>USAGE</code> privileges on the schemas for the types used in the statement.</li> </ul>  |
| <a href="/materialize/35604/sql/create-network-policy/" ><code>CREATE NETWORK POLICY</code></a> | <ul> <li><code>CREATENETWORKPOLICY</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/create-role" ><code>CREATE ROLE</code></a> | <ul> <li><code>CREATEROLE</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/create-schema" ><code>CREATE SCHEMA</code></a> | <ul> <li><code>CREATE</code> privileges on the containing database.</li> </ul>  |
| <a href="/materialize/35604/sql/create-secret" ><code>CREATE SECRET</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/create-sink" ><code>CREATE SINK</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>SELECT</code> privileges on the item being written out to an external system. <ul> <li>NOTE: if the item is a materialized view, then the view owner must also have the necessary privileges to execute the view definition.</li> </ul> </li> <li><code>CREATE</code> privileges on the containing cluster if the sink is created in an existing cluster.</li> <li><code>CREATECLUSTER</code> privileges on the system if the sink is not created in an existing cluster.</li> <li><code>USAGE</code> privileges on all connections and secrets used in the sink definition.</li> <li><code>USAGE</code> privileges on the schemas that all connections and secrets in the statement are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/create-source" ><code>CREATE SOURCE</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>CREATE</code> privileges on the containing cluster if the source is created in an existing cluster.</li> <li><code>CREATECLUSTER</code> privileges on the system if the source is not created in an existing cluster.</li> <li><code>USAGE</code> privileges on all connections and secrets used in the source definition.</li> <li><code>USAGE</code> privileges on the schemas that all connections and secrets in the statement are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/create-table" ><code>CREATE TABLE</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>USAGE</code> privileges on all types used in the table definition.</li> <li><code>USAGE</code> privileges on the schemas that all types in the statement are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/create-type" ><code>CREATE TYPE</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>USAGE</code> privileges on all types used in the type definition.</li> <li><code>USAGE</code> privileges on the schemas that all types in the statement are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/create-view" ><code>CREATE VIEW</code></a> | <ul> <li><code>CREATE</code> privileges on the containing schema.</li> <li><code>USAGE</code> privileges on all types used in the view definition.</li> <li><code>USAGE</code> privileges on the schemas for the types in the statement.</li> <li>Ownership of the existing view if replacing an existing view with the same name (i.e., <code>OR REPLACE</code> is specified in <code>CREATE VIEW</code> command).</li> </ul>  |
| <a href="/materialize/35604/sql/delete" ><code>DELETE</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations and types in the query are contained in.</li> <li><code>DELETE</code> privileges on <code>table_name</code>.</li> <li><code>SELECT</code> privileges on all relations in the query. <ul> <li>NOTE: if any item is a view, then the view owner must also have the necessary privileges to execute the view definition. Even if the view owner is a <em>superuser</em>, they still must explicitly be granted the necessary privileges.</li> </ul> </li> <li><code>USAGE</code> privileges on all types used in the query.</li> <li><code>USAGE</code> privileges on the active cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-cluster-replica" ><code>DROP CLUSTER REPLICA</code></a> | <ul> <li>Ownership of the dropped cluster replica.</li> <li><code>USAGE</code> privileges on the containing cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-cluster" ><code>DROP CLUSTER</code></a> | <ul> <li>Ownership of the dropped cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-connection" ><code>DROP CONNECTION</code></a> | <ul> <li>Ownership of the dropped connection.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-database" ><code>DROP DATABASE</code></a> | <ul> <li>Ownership of the dropped database.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-index" ><code>DROP INDEX</code></a> | <ul> <li>Ownership of the dropped index.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-materialized-view" ><code>DROP MATERIALIZED VIEW</code></a> | <ul> <li>Ownership of the dropped materialized view.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-network-policy" ><code>DROP NETWORK POLICY</code></a> | <ul> <li><code>CREATENETWORKPOLICY</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-owned" ><code>DROP OWNED</code></a> | <ul> <li>Role membership in <code>role_name</code>.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-role" ><code>DROP ROLE</code></a> | <ul> <li><code>CREATEROLE</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-schema" ><code>DROP SCHEMA</code></a> | <ul> <li>Ownership of the dropped schema.</li> <li><code>USAGE</code> privileges on the containing database.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-secret" ><code>DROP SECRET</code></a> | <ul> <li>Ownership of the dropped secret.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-sink" ><code>DROP SINK</code></a> | <ul> <li>Ownership of the dropped sink.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-source" ><code>DROP SOURCE</code></a> | <ul> <li>Ownership of the dropped source.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-table" ><code>DROP TABLE</code></a> | <ul> <li>Ownership of the dropped table.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-type" ><code>DROP TYPE</code></a> | <ul> <li>Ownership of the dropped type.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-user" ><code>DROP USER</code></a> | <ul> <li><code>CREATEROLE</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/drop-view" ><code>DROP VIEW</code></a> | <ul> <li>Ownership of the dropped view.</li> <li><code>USAGE</code> privileges on the containing schema.</li> </ul>  |
| <a href="/materialize/35604/sql/explain-analyze" ><code>EXPLAIN ANALYZE</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations in the explainee are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/explain-filter-pushdown" ><code>EXPLAIN FILTER PUSHDOWN</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations in the explainee are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/explain-plan" ><code>EXPLAIN PLAN</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations in the explainee are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/explain-schema" ><code>EXPLAIN SCHEMA</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all items in the query are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/explain-timestamp" ><code>EXPLAIN TIMESTAMP</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations in the query are contained in.</li> </ul>  |
| <a href="/materialize/35604/sql/grant-privilege" ><code>GRANT PRIVILEGE</code></a> | <ul> <li>Ownership of affected objects.</li> <li><code>USAGE</code> privileges on the containing database if the affected object is a schema.</li> <li><code>USAGE</code> privileges on the containing schema if the affected object is namespaced by a schema.</li> <li><em>superuser</em> status if the privilege is a system privilege.</li> </ul>  |
| <a href="/materialize/35604/sql/grant-role" ><code>GRANT ROLE</code></a> | <ul> <li><code>CREATEROLE</code> privileges on the system.</li> </ul>  |
| <a href="/materialize/35604/sql/insert" ><code>INSERT</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations and types in the query are contained in.</li> <li><code>INSERT</code> privileges on <code>table_name</code>.</li> <li><code>SELECT</code> privileges on all relations in the query. <ul> <li>NOTE: if any item is a view, then the view owner must also have the necessary privileges to execute the view definition. Even if the view owner is a <em>superuser</em>, they still must explicitly be granted the necessary privileges.</li> </ul> </li> <li><code>USAGE</code> privileges on all types used in the query.</li> <li><code>USAGE</code> privileges on the active cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/reassign-owned" ><code>REASSIGN OWNED</code></a> | <ul> <li>Role membership in <code>old_role</code> and <code>new_role</code>.</li> </ul>  |
| <a href="/materialize/35604/sql/revoke-privilege" ><code>REVOKE PRIVILEGE</code></a> | <ul> <li>Ownership of affected objects.</li> <li><code>USAGE</code> privileges on the containing database if the affected object is a schema.</li> <li><code>USAGE</code> privileges on the containing schema if the affected object is namespaced by a schema.</li> <li><em>superuser</em> status if the privilege is a system privilege.</li> </ul>  |
| <a href="/materialize/35604/sql/revoke-role" ><code>REVOKE ROLE</code></a> | <ul> <li><code>CREATEROLE</code> privileges on the systems.</li> </ul>  |
| <a href="/materialize/35604/sql/select" ><code>SELECT</code></a> | <ul> <li> <p><code>SELECT</code> privileges on all <strong>directly</strong> referenced relations in the query. If the directly referenced relation is a view or materialized view: - <code>SELECT</code> privileges are required only on the directly referenced view/materialized view. <code>SELECT</code> privileges are <strong>not</strong> required for the underlying relations referenced in the view/materialized view definition unless those relations themselves are directly referenced in the query.</p> </li> <li> <p>However, the owner of the view/materialized view (including those with <strong>superuser</strong> privileges) must have all required <code>SELECT</code> and <code>USAGE</code> privileges to run the view definition regardless of who is selecting from the view/materialized view.</p> </li> <li> <p><code>USAGE</code> privileges on the schemas that contain the relations in the query.</p> </li> <li> <p><code>USAGE</code> privileges on the active cluster.</p> </li> </ul>  |
| <a href="/materialize/35604/sql/show-columns" ><code>SHOW COLUMNS</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing <code>item_ref</code>.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-cluster" ><code>SHOW CREATE CLUSTER</code></a> | There are no privileges required to execute this statement. |
| <a href="/materialize/35604/sql/show-create-connection" ><code>SHOW CREATE CONNECTION</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the connection.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-index" ><code>SHOW CREATE INDEX</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the index.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-materialized-view" ><code>SHOW CREATE MATERIALIZED VIEW</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the materialized view.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-type" ><code>SHOW CREATE TYPE</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the table.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-sink" ><code>SHOW CREATE SINK</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the sink.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-source" ><code>SHOW CREATE SOURCE</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the source.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-table" ><code>SHOW CREATE TABLE</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the table.</li> </ul>  |
| <a href="/materialize/35604/sql/show-create-view" ><code>SHOW CREATE VIEW</code></a> | <ul> <li><code>USAGE</code> privileges on the schema containing the view.</li> </ul>  |
| <a href="/materialize/35604/sql/subscribe" ><code>SUBSCRIBE</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations and types in the query are contained in.</li> <li><code>SELECT</code> privileges on all relations in the query. <ul> <li>NOTE: if any item is a view, then the view owner must also have the necessary privileges to execute the view definition. Even if the view owner is a <em>superuser</em>, they still must explicitly be granted the necessary privileges.</li> </ul> </li> <li><code>USAGE</code> privileges on all types used in the query.</li> <li><code>USAGE</code> privileges on the active cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/update" ><code>UPDATE</code></a> | <ul> <li><code>USAGE</code> privileges on the schemas that all relations and types in the query are contained in.</li> <li><code>UPDATE</code> privileges on the table being updated.</li> <li><code>SELECT</code> privileges on all relations in the query. <ul> <li>NOTE: if any item is a view, then the view owner must also have the necessary privileges to execute the view definition. Even if the view owner is a <em>superuser</em>, they still must explicitly be granted the necessary privileges.</li> </ul> </li> <li><code>USAGE</code> privileges on all types used in the query.</li> <li><code>USAGE</code> privileges on the active cluster.</li> </ul>  |
| <a href="/materialize/35604/sql/validate-connection" ><code>VALIDATE CONNECTION</code></a> | <ul> <li><code>USAGE</code> privileges on the containing schema.</li> <li><code>USAGE</code> privileges on the connection.</li> </ul>  |

