0
0
SQLquery~10 mins

SQL statement categories (DDL, DML, DQL, DCL) - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - SQL statement categories (DDL, DML, DQL, DCL)
Start
Identify SQL Statement
DDL: Create, Alter, Drop
DML: Insert, Update, Delete
DQL: Select
DCL: Grant, Revoke
Unknown Category
This flow shows how to categorize an SQL statement by checking if it changes structure, data, queries data, or manages permissions.
Execution Sample
SQL
CREATE TABLE students (id INT, name VARCHAR(50));
INSERT INTO students VALUES (1, 'Alice');
SELECT * FROM students;
GRANT SELECT ON students TO user1;
This sample shows one statement from each SQL category: DDL, DML, DQL, and DCL.
Execution Table
StepSQL StatementCategoryReason
1CREATE TABLE students (id INT, name VARCHAR(50));DDLChanges database structure by creating a table
2INSERT INTO students VALUES (1, 'Alice');DMLChanges data by adding a new row
3SELECT * FROM students;DQLQueries data without changing it
4GRANT SELECT ON students TO user1;DCLManages permissions by granting access
5ENDN/ANo more statements to categorize
💡 All statements categorized; process ends.
Variable Tracker
VariableStartAfter 1After 2After 3After 4Final
Current StatementNoneCREATE TABLE ...INSERT INTO ...SELECT ...GRANT ...None
CategoryNoneDDLDMLDQLDCLNone
Key Moments - 3 Insights
Why is SELECT considered DQL and not DML?
SELECT only reads data without changing it, so it fits DQL (Data Query Language). DML changes data, but SELECT does not modify anything, as shown in execution_table step 3.
Can CREATE TABLE be DML since it adds something?
No, CREATE TABLE changes the structure of the database, not the data inside it. This is why it is DDL, as seen in execution_table step 1.
What makes GRANT part of DCL?
GRANT controls who can do what in the database, managing permissions. This is the core of DCL, shown in execution_table step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what category is the statement 'INSERT INTO students VALUES (1, 'Alice');'?
ADML
BDDL
CDQL
DDCL
💡 Hint
Check execution_table row 2 under Category column.
At which step does the SQL statement change database structure?
AStep 3
BStep 1
CStep 2
DStep 4
💡 Hint
Look at execution_table Reason column for structure changes.
If a statement manages user permissions, which category does it belong to?
ADML
BDQL
CDCL
DDDL
💡 Hint
Refer to execution_table step 4 and variable_tracker Category after 4.
Concept Snapshot
SQL statements are grouped into four categories:
- DDL: Data Definition Language (structure changes like CREATE, ALTER)
- DML: Data Manipulation Language (data changes like INSERT, UPDATE)
- DQL: Data Query Language (data reading like SELECT)
- DCL: Data Control Language (permissions like GRANT, REVOKE)
Each category has a clear role in managing databases.
Full Transcript
This lesson shows how to classify SQL statements into four main categories: DDL, DML, DQL, and DCL. We start by checking if a statement changes the database structure, which means it is DDL. If not, we check if it changes data, which is DML. If it only reads data, it is DQL. Finally, if it manages permissions, it is DCL. We traced four example statements: CREATE TABLE (DDL), INSERT INTO (DML), SELECT (DQL), and GRANT (DCL). The execution table shows each step and why the statement fits its category. The variable tracker follows the current statement and category as we move through the steps. Key moments clarify common confusions, like why SELECT is not DML and why GRANT is DCL. The quiz tests understanding by asking about categories and steps. The snapshot summarizes the categories and their roles in simple terms.