Valid in: SQL, ESQL
The Revoke statement revokes privileges. It removes database privileges or role access granted to the specified users, groups, roles, or public. (To confer privileges, use the grant statement.) You cannot revoke privileges granted by other users.
The Revoke statement has the following format:
[EXEC SQL] REVOKE [GRANT OPTION FOR]
ALL [PRIVILEGES] | privilege {, privilege} | role {, role}
[ON [objecttype] [schema.]objectname {, [schema.]objectname} |
CURRENT INSTALLATION]
FROM PUBLIC | [auth_type] auth_id {, auth_id}
[CASCASE | RESTRICT];
Specifies the privileges to revoke. To revoke all privileges, use ALL. The privileges must agree with the objecttype as follows:
Object Type |
Valid Privileges |
---|---|
TABLE (omit objecttype) |
copy_into copy_from delete excluding insert references select update |
DATABASE (or CURRENT INSTALLATION) |
[no]access [no]connect_time_limit [no]create_procedure [no]create_table [no]db_admin [no]idle_time_limit [no]lockmode [no]query_io_limit [no]query_row_limit [no]select_syscat [no]session_priority [no[table_statistics [no]update_syscat |
PROCEDURE |
execute |
EVENT |
register raise |
ROLE |
Omit this clause |
Specifies the type of object on which the privileges were granted. To revoke permission on a table, omit the objecttype parameter. Valid objecttypes are:
Specifies the name of the table, database procedure, database event, or role on which the privileges were granted.
Specifies the type of authorization identifier to which privileges were granted. Auth_type must be user, group, or role. The default is user. More than one auth_type cannot be specified.
Specifies the users, groups, or roles from which privileges are being revoked. The auth_ids must agree with the type specified by the auth_type.
For example, if you specify group as auth_type, the auth_id list must be a list of group identifiers. If you specify public for the auth_id, you must omit auth_type. You can revoke from users and public in the same revoke statement.
Revoking a database privilege makes that privilege on the specified database undefined for the specified grantee (auth_id). If an attempt is made to revoke a privilege that was not granted to a specified auth_id, no changes are made to the privileges of that auth_id.
Privileges granted on specific databases are not affected by revoke...on current installation, and privileges granted on current installation are not affected by revoke...on database. Revoking privileges from public does not affect privileges granted to specific user.
If a privilege was granted using its "no" form (for example, nocreate_table or noquery_io_limit), the same form must be used when revoking the privilege. For example, the following grant prevents a user from creating tables:
grant nocreate_table on database employee
to user karenk;
To remove this restriction:
revoke nocreate_table on database employee
from user karenk;
For more information about privileges, see Grant (privilege). For a description of group and role identifiers, and details about privilege dependencies, see the Database Administrator Guide.
Note: In some cases granting a database privilege imposes a restriction, and revoking the privilege removes the restriction. For example, grant nocreatetable prevents the user from creating tables.