> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# REVOKE

> Use REVOKE to remove specific privileges or roles from a user or a role.

Use REVOKE to remove specific privileges or roles from a user or a role. For the privileges supported by the database, see [Privileges supported by the database](/documents/4.2/administration/user_privs/authorization/user_privs.md).

**Tip**

* Common users can only revoke their privileges that have the `WITH GRANT OPTION` keyword from other users and roles. For information about `WITH GRANT OPTION`, see [GRANT](/documents/4.2/sql-reference/sql-statements/account-management/GRANT.md).
* Only users with the `user_admin` role has the privilege to revoke privileges from other users.

## Syntax

### Revoke privileges

The privileges that can be revoked are object-specific. The following part describes syntax based on objects.

#### System

```SQL theme={null}
REVOKE
    { CREATE RESOURCE GROUP | CREATE RESOURCE | CREATE EXTERNAL CATALOG | REPOSITORY | BLACKLIST | FILE | OPERATE } 
    ON SYSTEM
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

#### AI functions and providers

```sql theme={null}
REVOKE USAGE ON ALL AI FUNCTIONS FROM {ROLE <role_name> | USER <user_identity>};
REVOKE USAGE ON AI FUNCTION <function_name> FROM {ROLE <role_name> | USER <user_identity>};
REVOKE USAGE ON AI PROVIDER <provider_name> FROM {ROLE <role_name> | USER <user_identity>};
REVOKE USAGE ON ALL AI PROVIDERS FROM {ROLE <role_name> | USER <user_identity>};
```

Revocation applies to subsequent executions and replanning, including prepared EXECUTE. It does not cancel an in-flight query. This feature adds native authorization checks; external access controllers that do not implement AI checks deny these operations.

#### Resource group

```SQL theme={null}
REVOKE
    { ALTER | DROP | ALL [PRIVILEGES] } 
    ON { RESOURCE GROUP <resourcegroup_name> [, <resourcegroup_name>,...] ｜ ALL RESOURCE GROUPS} 
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

#### Resource

```SQL theme={null}
REVOKE
    { USAGE | ALTER | DROP | ALL [PRIVILEGES] } 
    ON { RESOURCE <resource_name> [, <resource_name>,...] ｜ ALL RESOURCES} 
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

#### User

```SQL theme={null}
REVOKE IMPERSONATE ON USER <user_identity> FROM USER <user_identity>;
```

#### Global UDF

```SQL theme={null}
REVOKE
    { USAGE | DROP | ALL [PRIVILEGES]} 
    ON { GLOBAL FUNCTION <function_name>(input_data_type) [, <function_name>(input_data_type),...]    
       | ALL GLOBAL FUNCTIONS }
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

#### Internal catalog

```SQL theme={null}
REVOKE 
    { USAGE | CREATE DATABASE | ALL [PRIVILEGES]} 
    ON CATALOG default_catalog
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

#### External catalog

```SQL theme={null}
REVOKE  
   { USAGE | DROP | ALL [PRIVILEGES] } 
   ON { CATALOG <catalog_name> [, <catalog_name>,...] | ALL CATALOGS}
   FROM { ROLE | USER} {<role_name>|<user_identity>}
```

#### Database

```SQL theme={null}
REVOKE 
    { ALTER | DROP | CREATE TABLE | CREATE VIEW | CREATE FUNCTION | CREATE MATERIALIZED VIEW | ALL [PRIVILEGES] } 
    ON {{ DATABASE <database_name> [, <database_name>,...]} | ALL DATABASES }
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

* You must first run SET CATALOG before you run this command.

#### Table

```SQL theme={null}
REVOKE  
    { ALTER | DROP | SELECT | INSERT | EXPORT | UPDATE | DELETE | ALL [PRIVILEGES]} 
    ON { TABLE <table_name> [, < table_name >,...]
       | ALL TABLES} IN 
           { { DATABASE <database_name> [, <database_name>,...]} | ALL DATABASES }
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

* You must first run SET CATALOG before you run this command.
* You can also use db.tbl to represent a table.

  ```SQL theme={null}
  REVOKE <priv> ON TABLE db.tbl FROM {ROLE <role_name> | USER <user_identity>}
  ```

#### View

```SQL theme={null}
REVOKE  
    { ALTER | DROP | SELECT | EXPORT | ALL [PRIVILEGES]}
    ON { VIEW <view_name> [, < view_name >,...]
       ｜ ALL VIEWS} IN 
           { { DATABASE <database_name> [, <database_name>,...]}  | ALL DATABASES }
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

* You must first run SET CATALOG before you run this command.
* You can also use db.view to represent a view.
* For the EXPORT privilege, only grant and revoke are supported. Exporting the view via `EXPORT TABLE` is not supported.

  ```SQL theme={null}
  REVOKE <priv> ON VIEW db.view FROM {ROLE <role_name> | USER <user_identity>}
  ```

#### Materialized view

```SQL theme={null}
REVOKE
    { SELECT | ALTER | REFRESH | DROP | EXPORT | ALL [PRIVILEGES]}
    ON { MATERIALIZED VIEW <mv_name> [, < mv_name >,...]
       ｜ ALL MATERIALIZED VIEWS} IN 
           { { DATABASE <database_name> [, <database_name>,...] } | ALL [DATABASES] }
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

* You must first run SET CATALOG before you run this command.
* You can also use db.mv to represent an mv.
* For the EXPORT privilege, only grant and revoke are supported. Exporting the materialized view via `EXPORT TABLE` is not supported.

  ```SQL theme={null}
  REVOKE <priv> ON MATERIALIZED VIEW db.mv FROM {ROLE <role_name> | USER <user_identity>}
  ```

#### Function

```SQL theme={null}
REVOKE
    { USAGE | DROP | ALL [PRIVILEGES]} 
    ON { FUNCTION <function_name>(input_data_type) [, <function_name>(input_data_type),...]
       ｜ ALL FUNCTIONS} IN 
           { { DATABASE <database_name> [, <database_name>,...] } | ALL DATABASES }
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

* You must first run SET CATALOG before you run this command.
* You can also use db.function to represent a function.

  ```SQL theme={null}
  REVOKE <priv> ON FUNCTION <db_name>.<function_name>(input_data_type) FROM {ROLE <role_name> | USER <user_identity>}
  ```

#### Storage volume

```SQL theme={null}
REVOKE
    CREATE STORAGE VOLUME 
    ON SYSTEM
    FROM { ROLE | USER} {<role_name>|<user_identity>}

REVOKE
    { USAGE | ALTER | DROP | ALL [PRIVILEGES] } 
    ON { STORAGE VOLUME < name > [, < name >,...] ｜ ALL STORAGE VOLUME} 
    FROM { ROLE | USER} {<role_name>|<user_identity>}
```

### Revoke roles

```SQL theme={null}
REVOKE <role_name> [,<role_name>, ...] FROM ROLE <role_name>
REVOKE <role_name> [,<role_name>, ...] FROM USER <user_identity>
```

## Parameters

| **Parameter** | **Description** |
| - | - |
| role\_name | The role name. |
| user\_identity | The user identity, for example, 'jack'@'192.%'. |
| resourcegroup\_name | The resource group name |
| resource\_name | The resource name. |
| function\_name | The function name. |
| catalog\_name | The name of the external catalog. |
| database\_name | The database name. |
| table\_name | The table name. |
| view\_name | The view name. |
| mv\_name | The name of the materialized view. |

## Examples

### Revoke privileges

Revoke the SELECT privilege on table `sr_member` from user `jack`:

```SQL theme={null}
REVOKE SELECT ON TABLE sr_member FROM USER 'jack'@'192.%'
```

Revoke the USAGE privilege on resource `spark_resource` from role `test_role`:

```SQL theme={null}
REVOKE USAGE ON RESOURCE 'spark_resource' FROM ROLE 'test_role';
```

### Revoke roles

Revoke the role `example_role` from user `jack`:

```SQL theme={null}
REVOKE example_role FROM 'jack'@'%';
```

Revoke the role `example_role` from role `test_role`:

```SQL theme={null}
REVOKE example_role FROM ROLE 'test_role';
```

## References

[GRANT](/documents/4.2/sql-reference/sql-statements/account-management/GRANT.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.