---
title: "SQL Commands: DDL, DML, and DCL"  
description: "SQL Commands: DDL, DML, and DCL"  
author: "ICSM Computer"  
published: 2026-03-27  
updated: 2026-03-27  
canonical: https://www.mindstick.com/interview/34483/sql-commands-ddl-dml-and-dcl  
category: "SQL Server"  
tags: ["sql server"]  
reading_time: 4 minutes  

---

# SQL Commands: DDL, DML, and DCL

## 1. What is DDL (Data Definition Language)?

DDL commands are used to define and manage the structure of the database (schema). These commands deal with tables, indexes, and database objects.

### Common DDL Commands:

- **CREATE** – Creates database or table
- **ALTER** – Modifies existing structure
- **DROP** – Deletes objects
- **TRUNCATE** – Removes all records (faster than DELETE)

### Example:

```plaintext
CREATE TABLE Users (
    Id INT PRIMARY KEY,
    Name VARCHAR(100)
);
```

**Key Point:**\
DDL commands automatically commit changes (cannot rollback easily).

## 2. What is DML (Data Manipulation Language)?

**Answer:**\
DML commands are used to manipulate data inside tables.

### Common DML Commands:

- **INSERT** – Add new data
- **UPDATE** – Modify existing data
- **DELETE** – Remove data

### Example:

```plaintext
INSERT INTO Users (Id, Name)
VALUES (1, 'John');
```

## Key Point:

- Changes can be **rolled back**
- Works with transactions

## 3. What is DCL (Data Control Language)?

DCL commands are used to control access and permissions in the database.

### Common DCL Commands:

- **GRANT** – Gives permission
- **REVOKE** – Removes permission

### Example:

```plaintext
GRANT SELECT ON Users TO User1;
```

**Key Point:**\
Used for **security and authorization**

## Quick Difference Table

| Feature | DDL | DML | DCL |
| --- | --- | --- | --- |
| Purpose | Define structure | Manage data | Control access |
| Works On | Tables, schema | Records (rows) | Users & permissions |
| Commands | CREATE, ALTER, DROP | INSERT, UPDATE, DELETE | GRANT, REVOKE |
| Rollback | No (auto commit) | Yes | Depends |

## Interview Tip

If asked in interview, answer like this:

**“DDL is used to define database structure, DML is used to manipulate data, and DCL is used to control access and permissions.”**

## Answers

### Answer by ICSM Computer

## 1. What is DDL (Data Definition Language)?

DDL commands are used to define and manage the structure of the database (schema). These commands deal with tables, indexes, and database objects.

### Common DDL Commands:

- **CREATE** – Creates database or table
- **ALTER** – Modifies existing structure
- **DROP** – Deletes objects
- **TRUNCATE** – Removes all records (faster than DELETE)

### Example:

```plaintext
CREATE TABLE Users (
    Id INT PRIMARY KEY,
    Name VARCHAR(100)
);
```

**Key Point:**\
DDL commands automatically commit changes (cannot rollback easily).

## 2. What is DML (Data Manipulation Language)?

**Answer:**\
DML commands are used to manipulate data inside tables.

### Common DML Commands:

- **INSERT** – Add new data
- **UPDATE** – Modify existing data
- **DELETE** – Remove data

### Example:

```plaintext
INSERT INTO Users (Id, Name)
VALUES (1, 'John');
```

## Key Point:

- Changes can be **rolled back**
- Works with transactions

## 3. What is DCL (Data Control Language)?

DCL commands are used to control access and permissions in the database.

### Common DCL Commands:

- **GRANT** – Gives permission
- **REVOKE** – Removes permission

### Example:

```plaintext
GRANT SELECT ON Users TO User1;
```

**Key Point:**\
Used for **security and authorization**

## Quick Difference Table

| Feature | DDL | DML | DCL |
| --- | --- | --- | --- |
| Purpose | Define structure | Manage data | Control access |
| Works On | Tables, schema | Records (rows) | Users & permissions |
| Commands | CREATE, ALTER, DROP | INSERT, UPDATE, DELETE | GRANT, REVOKE |
| Rollback | No (auto commit) | Yes | Depends |

## Interview Tip

If asked in interview, answer like this:

**“DDL is used to define database structure, DML is used to manipulate data, and DCL is used to control access and permissions.”**


---

Original Source: https://www.mindstick.com/interview/34483/sql-commands-ddl-dml-and-dcl

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
