Purpose
This statement is used by a system administrator to revoke some privileges from a user.
Limitations and considerations
- The user must have the revoked privilege (for example, the
SELECTprivilege on tabletbl1) and theGRANT OPTIONprivilege.
Privileges required
When a privilege does not have the
GRANT OPTION, the revocation operation does not cascade. For example, ifuser1grants a privilege touser2, revoking the privilege fromuser1does not automatically revoke the corresponding privilege fromuser2. However, if a privilege has theGRANT OPTION, the revocation operation cascades.To revoke the
ALL PRIVILEGESorGRANT OPTIONprivilege, the current user must have the globalGRANT OPTIONprivilege or theUPDATEorDELETEprivilege on the privilege table.
For more information about privileges in OceanBase Database, see Privilege types in Oracle-compatible mode.
Syntax
/*Revoke object privileges*/
REVOKE {obj_privilege [, obj_privilege...]} ON obj_clause FROM {user_name [, user_name ...]}
/*Revoke system privileges*/
REVOKE {system_privilege_list | ALL PRIVILEGES} FROM user_name [, user_name ...];
REVOKE ALL [PRIVILEGES], GRANT_OPTION FROM user_name [, user_name ...];
/*Revoke roles*/
REVOKE role_name [, role_name ...] FROM user_name;
obj_clause:
* [. *]
| relation_name . {* | relation_name}
| [DIRECTORY] relation_name
| CATALOG external_catalog_name
Parameters
| Parameter | Description |
|---|---|
| obj_privilege | The type of object privileges to be revoked. For more information about the types and descriptions of object privileges, see the table in the following section. Separate the types of multiple object privileges with commas (,). |
| obj_clause | The clause that specifies the level of privilege revocation and the name of the specific object. Privileges can be classified into the following levels:
|
| system_privilege_list | The type of system privileges to be revoked. Separate the types of multiple system privileges with commas (,). |
| ALL [PRIVILEGES] | Specifies to revoke all privileges except the GRANT OPTION privilege. |
obj_clause
* [. *]: Refers to all tables in all databases.The example is as follows:
Revoke the global
SELECTandINSERTprivileges from usersuser001anduser002.REVOKE SELECT, INSERT ON *.* FROM 'user001', 'user002';relation_name . {* | relation_name}: Refers to all tables in the specified database.db_namerepresents the name of the specified database.The example is as follows:
Revoke the insert privilege on all tables in the
testdatabase from useruser003.REVOKE INSERT ON 'test'.* FROM 'user003';[DIRECTORY] relation_name: represents a specific table in a specific database.The example is as follows:
Revoke the
SELECTprivilege ontbl2in thetestdatabase from useruser003.REVOKE SELECT ON 'test'.'tbl2' FROM 'user003';CATALOG external_catalog_name: Represents the catalog in the Catalog.The example is as follows:
Revoke the
USE CATALOGprivilege on the objecttest_odps_catalogin the Catalog from useruser004.REVOKE USE CATALOG ON CATALOG test_odps_catalog FROM user004;
The following table describes the privilege types that can be revoked.
Privilege types
| Privilege | Description |
|---|---|
| ALL PRIVILEGES | All privileges except GRANT OPTION. |
| ALTER | The ALTER TABLE privilege. |
| CREATE | The CREATE TABLE privilege. |
| DELETE | The DELETE privilege. |
| DROP | The DROP privilege. |
| GRANT OPTION | The GRANT OPTION privilege. |
| INSERT | The INSERT privilege. |
| UPDATE | The UPDATE privilege. |
| SELECT | The SELECT privilege. |
| INDEX | The CREATE INDEX and DROP INDEX privileges. |
| SHOW VIEW | The SHOW CREATE VIEW privilege. |
| SHOW DATABASES | The global SHOW DATABASES privilege. |
| SUPER | The privilege to modify global system parameters by using the SET GLOBAL statement. |
| REFERENCES | The privilege to create constraints that reference tables. |
| EXECUTE | The privilege to execute stored programs. |
| FLASHBACK | The FLASHBACK privilege. |
| READ | The READ privilege. |
| WRITE | The WRITE privilege. |
| CREATE SESSION | The privilege to connect to a database. |
| EXEMPT REDACTION POLICY | The privilege to bypass any existing REDACTION POLICY and view data. |
| SYSDBA | The SYSDBA privilege. |
| SYSOPER | The SYSOPER privilege. |
| SYSBACKUP | The SYSBACKUP privilege. |
| CREATE TABLE | The privilege to create tables in the specified user schema. |
| CREATE ANY TABLE | The privilege to create tables in all user schemas except the SYS user schema. |
| ALTER ANY TABLE | The privilege to modify tables in all user schemas except the SYS user schema. |
| BACKUP ANY TABLE | The privilege to back up tables in all user schemas except the SYS user schema. |
| DROP ANY TABLE | The privilege to drop tables in all user schemas except the SYS user schema. |
| LOCK ANY TABLE | The privilege to lock tables in all user schemas except the SYS user schema. |
| COMMENT ANY TABLE | The privilege to comment on tables in all user schemas except the SYS user schema. |
| SELECT ANY TABLE | The privilege to view tables in all user schemas except the SYS user schema. |
| INSERT ANY TABLE | The privilege to insert rows into tables in all user schemas except the SYS user schema. |
| UPDATE ANY TABLE | The privilege to update rows in tables in all user schemas except the SYS user schema. |
| DELETE ANY TABLE | The privilege to delete tables in all user schemas except the SYS user schema. |
| FLASHBACK ANY TABLE | The privilege to perform FLASHBACK on tables in all user schemas except the SYS user schema. |
| CREATE ROLE | The privilege to create roles. |
| DROP ANY ROLE | The privilege to drop any role. |
| GRANT ANY ROLE | The privilege to grant any role. |
| ALTER ANY ROLE | The privilege to modify any role. |
| AUDIT ANY | The privilege to modify objects in all user schemas except the SYS user schema. |
| GRANT ANY PRIVILEGE | The privilege to grant any system privilege. |
| GRANT ANY OBJECT PRIVILEGE | The privilege to grant any object privilege. |
| CREATE ANY INDEX | The privilege to create indexes in all user schemas except the SYS user schema. |
| ALTER ANY INDEX | The privilege to modify indexes in all user schemas except the SYS user schema. |
| DROP ANY INDEX | The privilege to drop indexes in all user schemas except the SYS user schema. |
| CREATE ANY VIEW | The privilege to create views in all user schemas except the SYS user schema. |
| DROP ANY VIEW | The privilege to drop views in all user schemas except the SYS user schema. |
| CREATE VIEW | The privilege to create views in the specified user schema. |
| SELECT ANY DICTIONARY | The privilege to query the DICTIONARY in all user schemas except the SYS user schema. |
| CREATE PROCEDURE | The privilege to create PROCEDURE in the specified user schema. |
| CREATE ANY PROCEDURE | The privilege to create PROCEDURE in all user schemas except the SYS user schema. |
| ALTER ANY PROCEDURE | The privilege to modify PROCEDURE in all user schemas except the SYS user schema. |
| DROP ANY PROCEDURE | The privilege to drop PROCEDURE in all user schemas except the SYS user schema. |
| EXECUTE ANY PROCEDURE | The privilege to execute PROCEDURE in all user schemas except the SYS user schema. |
| CREATE SYNONYM | The privilege to create SYNONYM in the specified user schema. |
| CREATE ANY SYNONYM | The privilege to create SYNONYM in all user schemas except the SYS user schema. |
| DROP ANY SYNONYM | The privilege to drop SYNONYM in all user schemas except the SYS user schema. |
| CREATE PUBLIC SYNONYM | The privilege to create public SYNONYM. |
| DROP PUBLIC SYNONYM | The privilege to drop public SYNONYM. |
| CREATE SEQUENCE | The privilege to create SEQUENCE in the specified user schema. |
| CREATE ANY SEQUENCE | The privilege to create SEQUENCE in all user schemas except the SYS user schema. |
| ALTER ANY SEQUENCE | The privilege to modify SEQUENCE in all user schemas except the SYS user schema. |
| DROP ANY SEQUENCE | The privilege to drop SEQUENCE in all user schemas except the SYS user schema. |
| SELECT ANY SEQUENCE | The privilege to query SEQUENCE in all user schemas except the SYS user schema. |
| CREATE TRIGGER | The privilege to create TRIGGER in the specified user schema. |
| CREATE ANY TRIGGER | The privilege to create TRIGGER in all user schemas except the SYS user schema. |
| ALTER ANY TRIGGER | The privilege to modify TRIGGER in all user schemas except the SYS user schema. |
| DROP ANY TRIGGER | The privilege to drop TRIGGER in all user schemas except the SYS user schema. |
| CREATE PROFILE | The privilege to create PROFILE. |
| ALTER PROFILE | The privilege to modify PROFILE. |
| DROP PROFILE | The privilege to drop PROFILE. |
| CREATE USER | The privilege to create users. |
| ALTER USER | The privilege to modify users. |
| DROP USER | The privilege to drop users. |
| CREATE TYPE | The privilege to create TYPE in the specified user schema. |
| CREATE ANY TYPE | The privilege to create TYPE in all user schemas except the SYS user schema. |
| ALTER ANY TYPE | The privilege to modify TYPE in all user schemas except the SYS user schema. |
| DROP ANY TYPE | The privilege to drop TYPE in all user schemas except the SYS user schema. |
| EXECUTE ANY TYPE | The privilege to execute TYPE in all user schemas except the SYS user schema. |
| UNDER ANY TYPE | The privilege to create SUBTYPE based on TYPE in all user schemas except the SYS user schema. |
| PURGE DBA_RECYCLEBIN | The privilege to purge all objects from the system recycle bin. |
| CREATE ANY OUTLINE | The privilege to create OUTLINE in all user schemas except the SYS user schema. |
| ALTER ANY OUTLINE | The privilege to modify OUTLINE in all user schemas except the SYS user schema. |
| DROP ANY OUTLINE | The privilege to drop OUTLINE in all user schemas except the SYS user schema. |
| SYSKM | The SYSKM privilege. |
| CREATE TABLESPACE | The privilege to create tablespaces. |
| ALTER TABLESPACE | The privilege to modify tablespaces. |
| DROP TABLESPACE | The privilege to drop tablespaces. |
| ALTER SYSTEM | The ALTER SYSTEM privilege. |
| CREATE DATABASE LINK | The privilege to create DATABASE LINK in the specified user schema. |
| CREATE PUBLIC DATABASE LINK | The privilege to create PUBLIC DATABASE LINK. |
| DROP DATABASE LINK | The privilege to drop DATABASE LINK in the specified user schema. |
| ALTER SESSION | The privilege to modify SESSION. |
| ALTER DATABASE | The privilege to modify DATABASE. |
Examples
Create a user and a role.
CREATE USER user1 IDENTIFIED BY password; CREATE ROLE role1; CREATE TABLE user1.tbl1 (id INT);Grant privileges to the role.
GRANT SELECT ON user1.tbl1 TO role1;Grant the role to the user.
GRANT role1 TO user1;Revoke the privileges granted to the role on the table.
REVOKE SELECT ON user1.tbl1 FROM role1;
The preceding steps enable you to grant and revoke privileges.
The following examples show SQL statements for revoking all privileges, object privileges, and system privileges.
- Revoke all privileges from user user1.
obclient> REVOKE ALL PRIVILEGES FROM user1;
Query OK, 0 rows affected
- Revoke the SELECT privilege on the user1.tbl1 table from role1.
obclient> REVOKE SELECT ON user1.tbl1 FROM role1;
Query OK, 0 rows affected
- Revoke the DROP ANY TABLE privilege from users user1 and user2.
obclient> REVOKE DROP ANY TABLE FROM user1,user2;
Query OK, 0 rows affected
References
For more information about how to query user privileges, see Query user privileges.
For more information about how to query roles and privileges in a role, see Query roles.
You can query the information about the created users in the
dba_userstable. For more information about thedba_userstable, see DBA_USERS.