Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Identify common structured query language (SQL) statements

A worked example

Complete the statement

A database administrator ran the following statement in an Azure SQL Database:

GRANT SELECT, INSERT, UPDATE
ON Product
TO user1;

The user user1 must keep the SELECT and UPDATE permissions. The INSERT permission that was granted earlier must be removed. The Product table and the rows in it must not change.

Complete the Transact-SQL statement that meets the requirements.

 INSERT
ON Product
FROM user1;
  • Blank 1: REVOKE (correct answer)

    REVOKE removes a previously granted permission, here the INSERT permission given to user1, and leaves the other grants in place. DENY adds a denial of a permission rather than removing an earlier grant, and it names the principal with TO, not FROM. DELETE removes rows from a table, which must not change. DROP removes an object from the database, which would remove the Product table.

Why

Permissions on database objects are managed with Data Control Language (DCL) statements: GRANT, DENY and REVOKE. The requirement is to remove a permission that was granted earlier, which is what REVOKE does. Revoking only INSERT leaves the SELECT and UPDATE grants and the table data untouched.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free