Object Privileges  «Prev  Next»
Lesson 3 GRANT Command
ObjectiveGrant other Users Access to your Tables

Oracle GRANT Command

When you create a table or view, you are automatically given access to the data contained within the object. If you want to grant access privileges to another user, you have to explicitly give them access to the objects through the GRANT command.

GRANT Syntax

The syntax used to grant privileges for a table or view is shown using the syntax below.

Granting privileges in Oracle

GRANT privilege/ALL ON object TO user/PUBLIC
  1. Privilege is the name of a specific privilege. The ALL keyword means that all privileges will be granted on the target object to the specified user
  2. The name of the table or view to which the privileges apply.
  3. User is the name of an existing Oracle user. The keyword PUBLIC refers to a special user group that applies the privilege to all users of the database.

Grant Privilege on Object to User
You may notice that you can grant privileges to something called PUBLIC. PUBLIC is a special keyword that is explained at the following link. Oracle Database Public Privileges.
To grant INSERT or UPDATE privileges to a specific column in a table, you use the same syntax as described in the MouseOver, except that you insert the name of the column between the list of privileges and the keyword ON.

Examples

If you wanted to grant all privileges to a user called "ADMIN" for the table COIN, you would use the following syntax:
GRANT ALL ON COIN 
TO ADMIN;

If you wanted to grant INSERT privileges for the WINNING_BID column in the LOT table to the user called "AUCTIONEER", you would use the following syntax:
GRANT INSERT winning_bid ON LOT TO AUCTIONEER;

The next lesson exploresusing Security Manager to assign object privileges.

grant Command - Exercise

Click the Exercise link to practice granting access to database objects.
grant Command - Exercise