Follow us: Subscribe via RSS Feed Connect on YouTube Connect on YouTube


Tuesday, 11 April 2017

SQL Grant and Revoke

SQL Grant

This is used to grant the privileges to other users
     Grant <privileges> on <object_name> to <user_name> [with grant option];
     SQL> grant select on student to sudha;         -- you can give individual privilege

      SQL> grant select, insert on student to sudha;       -- you can give set of privileges

     SQL> grant all on student to sudha;                -- you can give all privileges
     The sudha user has to use dot method to access the object.

     SQL> select * from saketh.student;

     The sudha user can not grant permission on student table to other users. To get this type of option use the following.

     SQL> grant all on student to sudha with grant option;  
     Now sudha user also grant permissions on student table.

SQL Revoke

This is used to revoke the privileges from the users to which you granted the privileges.
     Revoke <privileges> on <object_name> from <user_name>;
     SQL> revoke select on student form sudha; -- you can revoke individual privilege

     SQL> revoke select, insert on student from sudha;            -- you can revoke set of privileges

      SQL> revoke all on student from sudha;       -- you can revoke all privileges
Share this article :


Post a Comment