GRANT
and REVOKE
You have created a number of tables in Oracle and as owner of these tables you have all possible privileges to the table. Privileges include be able to alter that table, insert new rows, update rows, delete rows or even just view the table.
As the owner you can grant privileges on your tables to other users. Further the grantee (that is the person granted the privileges) can also be given the right to the grant the same privileges to other users.
The syntax of the GRANT
comment is:
GRANT privilege1 [,privilege2 …] [(columnnames)] | ALL
ON objectname
TO user/PUBLIC
[WITH GRANT OPTION];
privilege include: INSERT, UPDATE, DELETE, SELECT, ALTER
For example
GRANT ALL ON Invoice TO s999999 WITH GRANT OPTION;
grants all privileges on the table
Invoice
to the user s999999
with the GRANT OPTION
. The GRANT OPTION
allows s999999
to grant any privilege on INVOICE
to another user.
GRANT SELECT
ON INVOICE
TO PUBLIC
grants the right to use SELECT
statements on the INVOICE
table to all users, that is PUBLIC
Privileges can be granted, and they can be taken away. The syntax of the REVOKE
statement is:
REVOKE privilege1 [,privilege2 …] | ALL
ON objectname
FROM user/PUBLIC;
For example
REVOKE ALL ON Invoice FROM s999999;
revokes the privileges granted by the earlier statement.