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?
- AUPDATE employee SET dept = 'Dev' WHERE emp_no = 5
- BCREATE TABLE department (dept_id INTEGER PRIMARY KEY, dept_name CHAR(10))
- 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.