Skip to content
doubtly

1 answer

Best answer

DCL (Data Control Language) commands are used to control access to a database. Here's an explanation of two common DCL commands with examples:

  1. GRANT: The GRANT command is used to give users or roles access to specific database objects or operations. The syntax for the GRANT command is:

    GRANT privileges ON object TO user;

    For example, to give a user named "Alice" SELECT privileges on the "Employees" table, we might use the following command:

    GRANT SELECT ON Employees TO Alice;

    This command gives Alice the ability to retrieve data from the "Employees" table.

  2. REVOKE: The REVOKE command is used to revoke previously granted access privileges. The syntax for the REVOKE command is:

    REVOKE privileges ON object FROM user;

    For example, to revoke the SELECT privileges that we previously granted to Alice on the "Employees" table, we might use the following command:

    REVOKE SELECT ON Employees FROM Alice;

    This command removes Alice's ability to retrieve data from the "Employees" table.

DCL commands are important for ensuring the security and integrity of a database by controlling who has access to it and what they can do with it.

Doubtly · 3 May 2023 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.