Bird
Raised Fist0
SQLquery~10 mins

SQL statement categories (DDL, DML, DQL, DCL) - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new table named 'employees'.

SQL
CREATE [1] employees (id INT, name VARCHAR(100));
Drag options to blanks, or click blank then click option'
ADATABASE
BTABLE
CVIEW
DINDEX
Attempts:
3 left
💡 Hint
Common Mistakes
Using CREATE DATABASE instead of CREATE TABLE.
Using CREATE VIEW when a table is needed.
2fill in blank
medium

Complete the code to insert a new row into the 'employees' table.

SQL
INSERT INTO employees [1] (1, 'Alice');
Drag options to blanks, or click blank then click option'
ASELECT
BSET
CVALUES
DINTO
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET instead of VALUES in INSERT statements.
Using SELECT incorrectly in this context.
3fill in blank
hard

Fix the error in the query to select all columns from 'employees'.

SQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
A*
BALL
CEVERY
DALL_COLUMNS
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALL or EVERY which are not valid in this context.
Trying to write ALL_COLUMNS which is not a SQL keyword.
4fill in blank
hard

Fill both blanks to grant SELECT permission on 'employees' to user 'john'.

SQL
GRANT [1] ON employees TO [2];
Drag options to blanks, or click blank then click option'
ASELECT
BINSERT
Cjohn
Dadmin
Attempts:
3 left
💡 Hint
Common Mistakes
Granting INSERT instead of SELECT.
Using the wrong username.
5fill in blank
hard

Fill all three blanks to update the name of employee with id 1 to 'Bob'.

SQL
UPDATE employees SET [1] = [2] WHERE [3] = 1;
Drag options to blanks, or click blank then click option'
Aname
B'Bob'
Cid
Dsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Using salary instead of name.
Forgetting quotes around 'Bob'.
Using wrong condition column.

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