Database Basics

SQL statements are divided into the data definition language (DDL), data manipulation language (DML) and data control language (DCL). Which one is classified as DDL?

  1. AUPDATE employee SET dept = 'Dev' WHERE emp_no = 5
  2. BCREATE TABLE department (dept_id INTEGER PRIMARY KEY, dept_name CHAR(10))
  3. CGRANT SELECT ON employee TO tanaka
Show answer and explanation

Answer: B. CREATE TABLE department (dept_id INTEGER PRIMARY KEY, dept_name CHAR(10))

DDL (Data Definition Language) statements define the structure of a database, such as tables, views and indexes, and include CREATE, ALTER and DROP. DML (Data Manipulation Language) statements handle the data inside tables and include SELECT, INSERT, UPDATE and DELETE. DCL (Data Control Language) statements control things such as privileges and include GRANT, which gives a user privileges, and REVOKE, which takes them away. COMMIT, which makes a transaction permanent, and ROLLBACK, which cancels it, are sometimes counted as DCL and sometimes treated separately as transaction control statements. Among the choices, CREATE TABLE, which creates a table, is DDL.

  • A. UPDATE rewrites data in a table, so it is DML.
  • B. Correct. CREATE TABLE defines the structure of a table, so it is DDL.
  • C. GRANT gives a user privileges, so it is DCL.
Practice this topic Back to topic

Related calculators

Books on Database Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Database Basics questions

  1. A product table has five rows of (name, price): (pen, 120), (notebook, 250), (eraser, 80), (file, 300), (ruler, 150). Which shows, in order, the rows returned by SELECT name FROM product WHERE price >= 150 ORDER BY price DESC?
  2. The dept column of an employee table contains, from the top row down, Sales, Dev, Sales, Admin, Dev, Sales (six rows in total). How many rows does SELECT DISTINCT dept FROM employee return?
  3. What is the result of executing DELETE FROM employee in SQL without a WHERE clause?
  4. The score column of an exam table contains four values: 80, NULL, 70, 90 (NULL means the person did not take the exam). What is the result of SELECT AVG(score) FROM exam?
  5. The score column of a result table contains six values: 50, NULL, 70, NULL, 90, 30. Which shows, in order, the result of SELECT COUNT(*), COUNT(score), AVG(score) FROM result?