WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

SQL & Databases · Basic · question 5 of 100

Can you explain the difference between DDL, DML, and DCL in SQL?

📕 Buy this interview preparation book: 100 SQL & Databases questions & answers — PDF + EPUB for $5

DDL stands for Data Definition Language, and it is used to define and modify the structure of database objects such as tables, indexes, and constraints. DDL commands do not affect the data stored in the database. Common DDL commands include CREATE, ALTER, and DROP.

Here is an example of a DDL command to create a table:

CREATE TABLE customers (
  customer_id INT PRIMARY KEY,
  customer_name VARCHAR(50),
  email VARCHAR(100),
  phone VARCHAR(20)
);

This statement creates a new table called customers with four columns and a primary key constraint.

DML stands for Data Manipulation Language, and it is used to manipulate data stored in the database. DML commands affect the data stored in the database but do not change the structure of database objects. Common DML commands include SELECT, INSERT, UPDATE, and DELETE.

Here is an example of a DML command to insert data into a table:

INSERT INTO customers (customer_id, customer_name, email, phone)
VALUES (1, 'John Smith', 'john@example.com', '555-1234');

This statement inserts a new record into the customers table with the specified values.

DCL stands for Data Control Language, and it is used to manage the access and permissions of database objects. DCL commands do not affect the data stored in the database or the structure of database objects. Common DCL commands include GRANT and REVOKE.

Here is an example of a DCL command to grant privileges to a user:

GRANT SELECT, INSERT, UPDATE ON customers TO user1;

This statement grants the user user1 the SELECT, INSERT, and UPDATE privileges on the customers table.

In summary, DDL is used to define and modify the structure of database objects, DML is used to manipulate data stored in the database, and DCL is used to manage access and permissions of database objects. By using these different types of commands, you can create, manipulate, and control data stored in the database.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic SQL & Databases interview — then scores it.
📞 Practice SQL & Databases — free 15 min
📕 Buy this interview preparation book: 100 SQL & Databases questions & answers — PDF + EPUB for $5

All 100 SQL & Databases questions · All topics