Oracle9i SQL Reference
Release 1 (9.0.1)

Part Number A90125-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

SQL Statements:
DROP SEQUENCE to ROLLBACK, 19 of 20


REVOKE

Purpose

Use the REVOKE statement to:

Prerequisites

To revoke a system privilege or role, you must have been granted the privilege with the ADMIN OPTION.

To revoke a role, you must have been granted the role with the ADMIN OPTION. You can revoke any role if you have the GRANT ANY ROLE system privilege.

To revoke an object privilege, you must have previously granted the object privileges to each user and role.

The REVOKE statement can revoke only privileges and roles that were previously granted directly with a GRANT statement. You cannot use this statement to revoke:

Syntax

revoke::=


Text description of statements_917a.gif follows
Text description of revoke

revoke_system_privileges::=


Text description of statements_941.gif follows
Text description of revoke_system_privileges

revoke_object_privileges::=


Text description of statements_942.gif follows
Text description of revoke_object_privileges

grantee_clause::=


Text description of statements_943.gif follows
Text description of grantee_clause

on_object_clause::=


Text description of statements_933.gif follows
Text description of on_object_clause

Keywords and Parameters

revoke_system_privileges

system_privilege

Specify the system privilege to be revoked.

See Also:

Table 16-1 for a list of the system privileges 

Restriction: A system privilege cannot appear more than once in the list of privileges to be revoked.

Oracle provides a shortcut for specifying all system privileges at once:

role

Specify the role to be revoked.

Restriction: A system role cannot appear more than once in the list of roles to be revoked.

See Also:

Table 16-2 for a list of the roles predefined by Oracle 

grantee_clause

FROM grantee_clause identifies users or roles from which the system privilege, role, or object privilege is to be revoked.

PUBLIC

Specify PUBLIC to revoke the privileges or roles from all users.

revoke_object_privileges

object_privilege

Specify the object privilege to be revoked. You can substitute any of the following values: ALTER, DELETE, EXECUTE, INDEX, INSERT, READ, REFERENCES, SELECT, UPDATE.


Note:

Each privilege authorizes some operation. By revoking a privilege, you prevent the revokee from performing that operation. However, multiple users may grant the same privilege to the same user, role, or PUBLIC. To remove the privilege from the grantee's privilege domain, all grantors must revoke the privilege. If even one grantor does not revoke the privilege, the grantee can still exercise the privilege by virtue of that grant. 


If you revoke a privilege from a user, Oracle removes the privilege from the user's privilege domain. Effective immediately, the user cannot exercise the privilege.

If you revoke a privilege from a role, Oracle removes the privilege from the role's privilege domain. Effective immediately, users with the role enabled cannot exercise the privilege. Other users who have been granted the role cannot exercise the privilege after enabling the role.

If you revoke a privilege from PUBLIC, Oracle removes the privilege from the privilege domain of each user who has been granted the privilege through PUBLIC. Effective immediately, all such users are restricted from exercising the privilege. However, the privilege is not revoked from users who have been granted the privilege directly or through roles.

Restriction: A privilege cannot appear more than once in the list of privileges to be revoked. A user, a role, or PUBLIC cannot appear more than once in the FROM clause.

ALL [PRIVILEGES]

Specify ALL to revoke all object privileges that you have granted to the revokee. (The keyword PRIVILEGES is provided for semantic clarity and is optional.)


Note:

If no privileges have been granted on the object, Oracle takes no action and does not return an error. 


CASCADE CONSTRAINTS

This clause is relevant only if you revoke the REFERENCES privilege or ALL [PRIVILEGES]. It drops any referential integrity constraints that the revokee has defined using the REFERENCES privilege (which might have been granted either explicitly or implicitly through a grant of ALL [PRIVILEGES]).

FORCE

Specify FORCE to revoke the EXECUTE object privilege on user-defined type objects with table or type dependencies. You must use FORCE to revoke the EXECUTE object privilege on user-defined type objects with table dependencies.

If you specify FORCE, all privileges will be revoked, but all dependent objects are marked INVALID, data in dependent tables becomes inaccessible, and all dependent function-based indexes are marked UNUSABLE. (Regranting the necessary type privilege will revalidate the table.)

See Also:

Oracle9i Database Concepts for detailed information about type dependencies and user-defined object privileges 

on_object_clause

The on_object_clause identifies the objects on which privileges are to be revoked.

object

Specify the object on which the object privileges are to be revoked. This object can be:

If you do not qualify object with schema, Oracle assumes the object is in your own schema.

If you revoke the SELECT object privilege (with or without the GRANT OPTION) on the containing table or materialized view of a materialized view, Oracle invalidates the materialized view.

If you revoke the SELECT object privilege (with or without the GRANT OPTION) on any of the master tables of a materialized view, Oracle invalidates both the materialized view and its containing table or materialized view.

DIRECTORY directory_name

Specify the directory object on which privileges are to be revoked. You cannot qualify directory_name with schema. The object must be a directory.

See Also:

CREATE DIRECTORY 

JAVA SOURCE | RESOURCE

The JAVA clause lets you specify a Java source or resource schema object on which privileges are to be revoked.

Examples

Revoke a System Privilege from Users Example

The following statement revokes the DROP ANY TABLE system privilege from the users hr and oe:

REVOKE DROP ANY TABLE 
    FROM hr, oe; 

The users hr and oe can no longer drop tables in schemas other than their own.

Revoke a Role from a User Example

The following statement revokes the role dw_manager from the user sh:

REVOKE dw_manager 
    FROM sh; 

sh can no longer enable the dw_manager role.

Revoke a System Privilege from a Role Example

The following statement revokes the CREATE TABLESPACE system privilege from the dw_manager role:

REVOKE CREATE TABLESPACE 
   FROM dw_manager; 

Enabling the dw_manager role no longer allows users to create tablespaces.

Revoke a Role from a Role Example

To revoke the role dw_user from the role dw_manager, issue the following statement:

REVOKE dw_user
  FROM dw_manager; 

dw_user privileges are no longer granted to dw_manager

Revoke an Object Privilege from a User Example

You can grant DELETE, INSERT, SELECT, and UPDATE privileges on the table orders to the user hr with the following statement:

GRANT ALL 
    ON orders TO hr; 

To revoke the DELETE privilege on orders from hr, issue the following statement:

REVOKE DELETE 
    ON orders FROM hr; 
Revoke All Object Privileges from a User Example

To revoke the remaining privileges on orders that you granted to hr, issue the following statement:

REVOKE ALL 
    ON orders FROM hr; 
Revoke Object Privileges from PUBLIC Example

You can grant SELECT and UPDATE privileges on the view emp_details_view to all users by granting the privileges to the role PUBLIC:

GRANT SELECT, UPDATE 
    ON emp_details_view TO public; 

The following statement revokes UPDATE privilege on emp_details_view from all users:

REVOKE UPDATE 
    ON emp_details_view FROM public;

Users can no longer update the emp_details_view view, although users can still query it. However, if you have also granted the UPDATE privilege on emp_details_view to any users, either directly or through roles, these users retain the privilege.

Revoke an Object Privilege on a Sequence from a User Example

You can grant the user oe the SELECT privilege on the departments_seq sequence in the schema hr with the following statement:

GRANT SELECT 
    ON hr.departments_seq TO oe; 

To revoke the SELECT privilege on departments_seq from oe, issue the following statement:

REVOKE SELECT 
    ON hr.departments_seq FROM oe; 

However, if the user hr has also granted SELECT privilege on departments to sh, sh can still use departments by virtue of hr's grant.

Revoke an Object Privilege with CASCADE CONSTRAINTS Example

You can grant oe the privileges REFERENCES and UPDATE on the employees table in the schema hr with the following statement:

GRANT REFERENCES, UPDATE 
    ON hr.employees TO oe; 

oe can exercise the REFERENCES privilege to define a constraint in his own dependent table that refers to the employees table in the schema hr:

CREATE TABLE dependent 
(dependno   NUMBER, 
 dependname VARCHAR2(10), 
 employee   NUMBER                   
    CONSTRAINT in_emp REFERENCES hr.employees(employee_id) ); 

You can revoke the REFERENCES privilege on hr.employees from oe by issuing the following statement that contains the CASCADE CONSTRAINTS clause:

REVOKE REFERENCES 
    ON hr.employees 
    FROM oe 
    CASCADE CONSTRAINTS; 

Revoking oe's REFERENCES privilege on hr.employees causes Oracle to drop the in_emp constraint, because oe required the privilege to define the constraint.

However, if oe has also been granted the REFERENCES privilege on hr.employees by a user other than you, Oracle does not drop the constraint. oe still has the privilege necessary for the constraint by virtue of the other user's grant.

Revoke an Object Privilege on a Directory from a User Example

You can revoke READ privilege on directory bfile_dir from hr, by issuing the following statement:

REVOKE READ ON DIRECTORY bfile_dir FROM hr;

Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback