Oracle8i SQL Reference Release 2 (8.1.6) A76989-01 |
|
SQL Statements (continued), 4 of 8
To grant privileges for a particular object to users, roles, and PUBLIC
. To grant system privileges and roles, use the GRANT
system_privileges_and_roles
statement described in the previous section of this chapter. Table 7-7 summarizes the object privileges that you can grant on each type of object.
If you grant a privilege to a user, Oracle adds the privilege to the user's privilege domain. The user can immediately exercise the privilege.
If you grant a privilege to a role, Oracle adds the privilege to the role's privilege domain. Users who have been granted and have enabled the role can immediately exercise the privilege. Other users who have been granted the role can enable the role and exercise the privilege.
If you grant a privilege to PUBLIC
, Oracle adds the privilege to the privilege domain of each user. All users can immediately exercise the privilege.
Table 7-8 lists object privileges and the operations that they authorize. You can grant any of these system privileges with the GRANT
statement.
For information on granting system privileges and roles, see "GRANT system_privileges_and_roles". For information on revoking object grants, see "REVOKE schema_object_privileges".
You must own the object or the owner of the object must have granted you the object privileges with the GRANT
OPTION
. This rule applies to users with the DBA
role.
object_priv |
is an object privilege to be granted. You can substitute any of the values shown in Table 7-7. See also Table 7-8. Restriction: A privilege cannot appear more than once in the list of privileges to be granted. |
|
|
grants all the privileges for the object that you have been granted with the |
|
column |
specifies a table or view column on which privileges are granted. You can specify columns only when granting the |
|
|
identifies the object on which the privileges are granted. Directory schema objects and Java source and resource schema objects are identified separately because they reside in separate namespaces. |
|
|
object |
identifies the schema object on which the privileges are granted. If you do not qualify object with schema, Oracle assumes the object is in your own schema. The object can be one of the following types (see Table 7-7): |
|
|
Note: You cannot grant privileges directly to a single partition of a partitioned table. For information on how to grant privileges to a single partition indirectly, refer to Oracle8i Concepts. |
|
|
identifies a directory schema object on which privileges are granted by the DBA. You cannot qualify directory_name with a schema name. See "CREATE DIRECTORY". |
|
|
identifies a Java source or resource schema object on which privileges are granted. See "CREATE JAVA". |
|
identifies users or roles to which the object privilege is granted.
Restriction: A user or role cannot appear more than once in the |
|
|
|
grants object privileges to all users. |
|
allows the grantee to grant the object privileges to other users and roles. Restriction: You can specify this clause only when granting to a user or to PUBLIC, not when granting to a role. |
Object Privilege | Allows Grantee to . . . |
---|---|
The following table privileges authorize operations on a table. Any one of following object privileges allows the grantee to lock the table in any lock mode with the |
|
|
Change the table definition with the |
|
Remove rows from the table with the
Note: You must grant the |
|
Create an index on the table with the |
|
Add new rows to the table with the |
|
Create a constraint that refers to the table. You cannot grant this privilege to a role. |
|
Query the table with the |
|
Change data in the table with the |
|
Note: You must grant the |
The following view privileges authorize operations on a view. Any one of the following object privileges allows the grantee to lock the view in any lock mode with the
To grant a privilege on a view, you must have that privilege with the |
|
|
Remove rows from the view with the |
|
Add new rows to the view with the |
|
Query the view with the |
|
Change data in the view with the |
The following sequence privileges authorize operations on a sequence. |
|
|
Change the sequence definition with the |
|
Examine and increment values of the sequence with the |
The following procedure, function, and package privilege authorizes operations on procedures, functions, or packages. This privilege also applies to Java sources, classes, and resources, which Oracle treats as though they were procedures for purposes of granting object privileges. |
|
|
Compile the procedure or function or execute it directly, or access any program object declared in the specification of a package. |
|
Note: Users do not need this privilege to execute a procedure, function, or package indirectly. |
|
See Also: Oracle8i Concepts and Oracle8i Application Developer's Guide - Fundamentals. |
The following snapshot privilege authorizes operations on a snapshot. |
|
|
Query the snapshot with the |
Synonym privileges are the same as the privileges for the base object. Granting a privilege on a synonym is equivalent to granting the privilege on the base object. Similarly, granting a privilege on a base object is equivalent to granting the privilege on all synonyms for the object. If you grant a user a privilege on a synonym, the user can use either the synonym name or the base object name in the SQL statement that exercises the privilege. |
|
The following directory privilege provides secured access to the files stored in the operating system directory to which the directory object serves as a pointer. The directory object contains the full pathname of the operating system directory where the files reside. Because the files are actually stored outside the database, Oracle server processes also need to have appropriate file permissions on the file system server. Granting object privileges on the directory database object to individual database users, rather than on the operating system, allows Oracle to enforce security during file operations. |
|
|
Read files in the directory. |
The following object type privilege authorizes operations on an object type |
|
|
Use and reference the specified object and to invoke its methods. |
The following indextype privilege authorizes operations on indextypes. |
|
|
Reference an indextype. |
The following operator privilege authorizes operations on user-defined operators. |
|
|
Reference an operator. |
To grant READ
on directory BFILE_DIR1
to user SCOTT
, with the GRANT
OPTION
, issue the following statement:
GRANT READ ON DIRECTORY bfile_dir1 TO scottWITH GRANT OPTION;
To grant all privileges on the table BONUS
to the user JONES
with the GRANT
OPTION
, issue the following statement:
GRANT ALL ON bonus TO jonesWITH GRANT OPTION;
JONES
can subsequently perform the following operations:
BONUS
table
BONUS
table to another user or role
To grant SELECT
and UPDATE
privileges on the view GOLF_HANDICAP
to all users, issue the following statement:
GRANT SELECT, UPDATEON golf_handicap TO PUBLIC;
All users can subsequently query and update the view of golf handicaps.
To grant SELECT
privilege on the ESEQ
sequence in the schema ELLY
to the user BLAKE
, issue the following statement:
GRANT SELECTON elly.eseq TO blake;
BLAKE
can subsequently generate the next value of the sequence with the following statement:
SELECT elly.eseq.NEXTVALFROM DUAL;
To grant BLAKE
the REFERENCES
privilege on the EMPNO
column and the UPDATE
privilege on the EMPNO
, SAL
, and COMM
columns of the EMP
table in the schema SCOTT
, issue the following statement:
GRANT REFERENCES (empno), UPDATE (empno, sal, comm)ON scott.emp TO blake;
BLAKE
can subsequently update values of the EMPNO
, SAL
, and COMM
columns. BLAKE
can also define referential integrity constraints that refer to the EMPNO
column. However, because the GRANT
statement lists only these columns, BLAKE
cannot perform operations on any of the other columns of the EMP
table.
For example, BLAKE
can create a table with a constraint:
CREATE TABLE dependent(dependno NUMBER, dependname VARCHAR2(10), employee NUMBER CONSTRAINT in_emp REFERENCES scott.emp(empno) );
The constraint IN_EMP
ensures that all dependents in the DEPENDENT
table correspond to an employee in the EMP
table in the schema SCOTT
.
|
![]() Copyright © 1999 Oracle Corporation. All Rights Reserved. |
|