Bird
Raised Fist0
SQLquery~20 mins

SQL statement categories (DDL, DML, DQL, DCL) - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
SQL Statement Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the category of the SQL statement
Which category does the following SQL statement belong to?
CREATE TABLE Students (ID INT, Name VARCHAR(100));
AData Definition Language (DDL)
BData Manipulation Language (DML)
CData Query Language (DQL)
DData Control Language (DCL)
Attempts:
2 left
💡 Hint
Think about whether this statement changes the structure of the database or the data inside it.
🧠 Conceptual
intermediate
2:00remaining
Classify the SQL statement type
What category does this SQL statement belong to?
SELECT * FROM Employees WHERE Department = 'Sales';
AData Control Language (DCL)
BData Manipulation Language (DML)
CData Query Language (DQL)
DData Definition Language (DDL)
Attempts:
2 left
💡 Hint
This statement retrieves data without changing it.
❓ query_result
advanced
2:00remaining
Determine the effect of a DML statement
What will be the result of this SQL statement?
INSERT INTO Products (ID, Name) VALUES (101, 'Pen');
SELECT COUNT(*) FROM Products;

Assuming the Products table initially has 5 rows.
AError: Cannot insert duplicate ID
B5
C0
D6
Attempts:
2 left
💡 Hint
INSERT adds a new row to the table.
📝 Syntax
advanced
2:00remaining
Identify the correct DCL statement syntax
Which of the following SQL statements correctly grants SELECT permission on the Customers table to user 'Alice'?
AGRANT SELECT ON Customers TO Alice;
BGRANT SELECT FROM Customers TO Alice;
CGRANT SELECT Customers TO Alice;
DGRANT SELECT ON Customers FOR Alice;
Attempts:
2 left
💡 Hint
The correct syntax uses ON before the table name.
🔧 Debug
expert
2:00remaining
Find the error in this mixed SQL statement
What error will this SQL code produce?
UPDATE Orders SET Status = 'Shipped' WHERE OrderID = 123;
GRANT DELETE ON Orders TO Bob;
ARuntime error on UPDATE statement
BNo error, both statements run successfully
CSyntax error on GRANT statement
DPermission error on UPDATE statement
Attempts:
2 left
💡 Hint
Both UPDATE and GRANT are valid statements in their categories.

Practice

(1/5)
1. Which category of SQL statements is used to create or modify the structure of database objects like tables and indexes?
easy
A. Data Manipulation Language (DML)
B. Data Query Language (DQL)
C. Data Definition Language (DDL)
D. Data Control Language (DCL)

Solution

  1. Step 1: Understand the role of DDL

    DDL commands define or change database structures, such as creating tables or indexes.
  2. Step 2: Differentiate from other categories

    DML changes data, DQL queries data, and DCL controls access, so they don't modify structure.
  3. Final Answer:

    Data Definition Language (DDL) -> Option C
  4. Quick Check:

    Structure changes = DDL [OK]
Hint: Structure changes mean DDL commands [OK]
Common Mistakes:
  • Confusing DDL with DML because both change something
  • Thinking SELECT is DDL instead of DQL
  • Mixing up DCL with DDL
2. Which of the following is the correct syntax to grant SELECT permission on a table named employees to a user john?
easy
A. GRANT SELECT TO john ON employees;
B. GRANT john ON employees SELECT;
C. SELECT GRANT ON employees TO john;
D. GRANT SELECT ON employees TO john;

Solution

  1. Step 1: Recall correct GRANT syntax

    The correct syntax is: GRANT permission ON object TO user;
  2. Step 2: Match syntax with options

    GRANT SELECT ON employees TO john; matches the correct order and keywords exactly.
  3. Final Answer:

    GRANT SELECT ON employees TO john; -> Option D
  4. Quick Check:

    GRANT + permission + ON + object + TO + user [OK]
Hint: GRANT syntax: GRANT permission ON object TO user [OK]
Common Mistakes:
  • Swapping TO and ON keywords
  • Placing user before permission
  • Using SELECT before GRANT
3. What will be the output of the following SQL statement?
SELECT * FROM employees WHERE salary > 50000;
medium
A. All rows from employees with salary greater than 50000
B. All rows from employees with salary less than 50000
C. Syntax error due to missing semicolon
D. No rows because salary column does not exist

Solution

  1. Step 1: Understand the SELECT query

    The query selects all columns (*) from employees where salary is greater than 50000.
  2. Step 2: Analyze the WHERE condition

    Only rows with salary > 50000 are returned; others are excluded.
  3. Final Answer:

    All rows from employees with salary greater than 50000 -> Option A
  4. Quick Check:

    WHERE salary > 50000 filters rows correctly [OK]
Hint: WHERE filters rows; > means greater than [OK]
Common Mistakes:
  • Confusing > with <
  • Thinking semicolon is mandatory for output
  • Assuming salary column missing without info
4. Identify the error in the following SQL statement:
INSERT INTO employees (id, name salary) VALUES (1, 'Alice', 60000);
medium
A. Missing comma between columns 'name' and 'salary'
B. VALUES keyword is misspelled
C. Table name should be in quotes
D. Cannot insert numeric value into salary column

Solution

  1. Step 1: Check column list syntax

    Columns must be separated by commas; here 'name' and 'salary' lack a comma.
  2. Step 2: Verify other parts

    VALUES is correct, table name does not need quotes, numeric salary is valid.
  3. Final Answer:

    Missing comma between columns 'name' and 'salary' -> Option A
  4. Quick Check:

    Column list commas are required [OK]
Hint: Check commas between column names carefully [OK]
Common Mistakes:
  • Ignoring missing commas in column list
  • Thinking table names need quotes
  • Assuming VALUES keyword typo
5. You want to remove a table named orders and all its data permanently from the database. Which SQL statement category should you use, and which command is correct?
hard
A. DML - DELETE FROM orders;
B. DDL - DROP TABLE orders;
C. DCL - REVOKE ALL ON orders;
D. DQL - SELECT * FROM orders;

Solution

  1. Step 1: Understand the goal

    Removing a table and its data permanently means deleting the structure, not just data.
  2. Step 2: Identify correct category and command

    DDL commands modify structure; DROP TABLE removes the table entirely.
  3. Final Answer:

    DDL - DROP TABLE orders; -> Option B
  4. Quick Check:

    Drop table = remove structure and data [OK]
Hint: DROP removes table; DELETE removes data only [OK]
Common Mistakes:
  • Using DELETE which only removes data, not table
  • Confusing REVOKE with deleting tables
  • Thinking SELECT can remove anything
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard