84.0k views
0 votes
Describe the GRANT statement and explain how it relates to security. What types of privileges may be granted? How are they revoked?

User Kirk Logan
by
4.8k points

1 Answer

4 votes

Answer:

GRANT statement basically allows access to the database.

Step-by-step explanation:

GRANT statement allows the user to get privileges on the database. This allows the users to manipulate data in the database or perform some actions such as SELECT, CREATE, DELETE etc are some privileges granted to the users to select data from a table, to create a relation/table or to delete records from a table etc.

GRANT statement involves the type of privilege that is to be granted such as SELECT, the object to which the access is to be granted such as a table so the table name is mentioned here and third is the name of the user to which the rights or privilege is to be granted.

Privileges can be system or object.

System privileges examples are: DROP, CREATE ,ALTER, etc in which DROP allows to delete a database object, create allows to create a database object and ALTER is used to modify database objects.

Object privileges allows to perform actions on a table and manipulate data in a table. For example INSERT, EXECUTE, SELECT, UPDATE etc.

GRANT statement is beneficial for security purposes as it grants certain access and privileges to specific users according to their requirements and does not give access to every object to all users which helps in securing the data and database objects as giving access to all users can sometimes be a security risk. So GRANT statement by selective access to specific users for specific operations can be beneficial in securing the data in the database e.g from being corrupted in anyway. It defines roles for different users for performing different actions to make sure that users only access the database in ways they are granted or permitted to. GRANT allows each user only the privileges necessary to perform a task.

The access rights given by the GRANT statement can be revoked by using REVOKE command. This statement is used to remove the privileges from the users or database objects. This statement involves the privilege to be revoked e.g SELECT, the object on which the privilege is to be revoked such as table name and the user name from whom the granted privilege is to be revoked.