What is the Difference Between grant and revoke?

🆚 Go to Comparative Table 🆚

The main difference between the GRANT and REVOKE commands lies in their purpose:

  • GRANT: This command is used to give access privileges to users on database objects, allowing them to perform specific tasks or access certain resources. It also allows users to grant permissions to other users. The syntax for the GRANT command is:
GRANT privilege_name ON object_name TO {user_name | public | role_name}
  • REVOKE: This command does the opposite of GRANT, as it removes user privileges on database objects. If access for a user is revoked, all specific permissions provided by that user to others will also be revoked. The syntax for the REVOKE command is:
REVOKE privilege_name ON object_name FROM {user_name | public | role_name}

In summary, the GRANT command is used to grant access privileges to users, while the REVOKE command is used to remove those privileges from users.

Comparative Table: grant vs revoke

The GRANT and REVOKE commands are part of the Data Control Language (DCL) component of SQL commands. They are used to manage access to database objects and control user privileges. Here is a table summarizing the differences between GRANT and REVOKE:

Feature GRANT REVOKE
Purpose Provides privileges to database objects for users Withdraws user privileges on database objects if any granted
Syntax GRANT privilege_name on object_name to user_name REVOKE privilege_name on object_name from user_name
Direction Grants permissions, allowing users to perform specific actions on database objects Revokes permissions, preventing users from performing specific actions on database objects
User Impact Increases user access to database objects Decreases user access to database objects

In summary, the GRANT command is used to provide users with privileges to perform specific actions on database objects, while the REVOKE command is used to withdraw those privileges.