CompTIA DataSys+ (DS0-001)Database FundamentalsMedium

A database administrator needs to create a new user account with privileges to only read data from the `Sales` and `Customers` tables. The user should not be able to modify or delete any data. Which SQL DDL command, along with appropriate clauses, should the administrator use?

  1. AGRANT SELECT ON Sales, Customers TO new_user;
  2. BALTER USER new_user ADD ROLE reader;
  3. CCREATE USER new_user WITH SELECT ON Sales, Customers;
  4. DSET PERMISSION FOR new_user TO READ ONLY;
Show answer & explanation

Correct answer: A. GRANT SELECT ON Sales, Customers TO new_user;

The `GRANT` command is used to assign specific privileges to database users or roles. `SELECT` is the privilege for reading data, and it can be granted on specified tables to a user.

Why the other options are wrong

  • B. While roles can simplify privilege management, `ALTER USER` is for modifying user attributes, and `ADD ROLE` is part of role management, not direct privilege granting.
  • C. This syntax is not a standard SQL DDL command for granting privileges.
  • D. SET PERMISSION is not a standard SQL command for granting user privileges.

SQL DDL (Data Definition Language)

A subset of SQL used to define and manage the database structure and schema, including creating, modifying, and deleting database objects.

  • Includes CREATE, ALTER, DROP, TRUNCATE, RENAME.
  • Also includes GRANT and REVOKE for permission management.
  • Operates on the structure of the database, not the data content.

Memory trick: DDL defines your database's look and feel.

More Database Fundamentals questions