Bird
Raised Fist0
DBMS Theoryknowledge~5 mins

DDL (CREATE, ALTER, DROP) in DBMS Theory - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What does DDL stand for in databases?
DDL stands for Data Definition Language. It is used to define and manage database structures like tables and schemas.
Click to reveal answer
beginner
What is the purpose of the CREATE command in DDL?
The CREATE command is used to make new database objects such as tables, indexes, or views.
Click to reveal answer
intermediate
How does the ALTER command work in DDL?
ALTER changes the structure of an existing database object, like adding a new column to a table or changing a column's data type.
Click to reveal answer
beginner
What happens when you use the DROP command?
DROP deletes a database object completely, such as a table or index, removing all its data and structure.
Click to reveal answer
intermediate
Can you recover data after using DROP on a table?
Usually, no. DROP removes the table and its data permanently unless you have backups or special recovery tools.
Click to reveal answer
Which DDL command is used to create a new table?
ACREATE
BALTER
CDROP
DSELECT
What does the ALTER command do?
ADeletes a table
BChanges the structure of a table
CCreates a new database
DInserts data into a table
Which command removes a table and all its data permanently?
AUPDATE
BALTER
CCREATE
DDROP
If you want to add a new column to an existing table, which command should you use?
ADROP
BCREATE
CALTER
DSELECT
Which of these is NOT a DDL command?
AINSERT
BDROP
CCREATE
DALTER
Explain the roles of CREATE, ALTER, and DROP commands in managing database structures.
Think about how you build, change, or remove things in real life.
You got /3 concepts.
    Describe what happens when you use the DROP command on a table and why it should be used carefully.
    Consider deleting a file on your computer.
    You got /3 concepts.

      Practice

      (1/5)
      1. What does the CREATE statement do in a database?
      easy
      A. It makes a new table to store data.
      B. It deletes an existing table and its data.
      C. It changes the data inside a table.
      D. It backs up the database.

      Solution

      1. Step 1: Understand the purpose of CREATE

        The CREATE statement is used to make new database objects, such as tables, to store data.
      2. Step 2: Compare with other statements

        DROP deletes tables, ALTER changes structure, but CREATE makes new tables.
      3. Final Answer:

        It makes a new table to store data. -> Option A
      4. Quick Check:

        CREATE = Make new table [OK]
      Hint: CREATE always makes new tables, not deletes or changes [OK]
      Common Mistakes:
      • Confusing CREATE with DROP which deletes tables
      • Thinking CREATE changes existing data
      • Assuming CREATE backs up data
      2. Which of the following is the correct syntax to add a new column named age of type INT to an existing table students?
      easy
      A. ALTER students ADD age INT;
      B. ALTER TABLE students ADD COLUMN age INT;
      C. DROP TABLE students ADD age INT;
      D. CREATE TABLE students ADD age INT;

      Solution

      1. Step 1: Identify correct ALTER syntax

        The correct syntax to add a column is: ALTER TABLE table_name ADD COLUMN column_name datatype;
      2. Step 2: Check each option

        ALTER TABLE students ADD COLUMN age INT; matches the correct syntax. Options B and C misuse CREATE and DROP. ALTER students ADD age INT; misses TABLE keyword.
      3. Final Answer:

        ALTER TABLE students ADD COLUMN age INT; -> Option B
      4. Quick Check:

        ALTER TABLE + ADD COLUMN = ALTER TABLE students ADD COLUMN age INT; [OK]
      Hint: ALTER TABLE ... ADD COLUMN ... is the correct form [OK]
      Common Mistakes:
      • Omitting TABLE keyword after ALTER
      • Using CREATE or DROP instead of ALTER
      • Forgetting the COLUMN keyword (optional but clearer)
      3. Consider the following SQL commands executed in order:
      CREATE TABLE employees (id INT, name VARCHAR(50));
      ALTER TABLE employees ADD COLUMN salary INT;
      What will be the structure of the employees table after these commands?
      medium
      A. Table with columns: id, name, salary
      B. Table with columns: id, salary
      C. Table with columns: id, name
      D. Table with columns: name, salary

      Solution

      1. Step 1: Analyze CREATE TABLE command

        The first command creates a table named employees with columns id and name.
      2. Step 2: Analyze ALTER TABLE command

        The second command adds a new column salary to the employees table.
      3. Final Answer:

        Table with columns: id, name, salary -> Option A
      4. Quick Check:

        CREATE + ALTER ADD COLUMN = id, name, salary [OK]
      Hint: ALTER ADD COLUMN adds new columns to existing tables [OK]
      Common Mistakes:
      • Ignoring the ALTER command effect
      • Assuming DROP was used to remove columns
      • Thinking ALTER replaces columns instead of adding
      4. Identify the error in the following SQL statement:
      ALTER TABLE employees DROP salary;
      medium
      A. Table name is incorrect
      B. DROP cannot be used with ALTER TABLE
      C. Missing COLUMN keyword after DROP
      D. salary column does not exist

      Solution

      1. Step 1: Understand DROP syntax in ALTER TABLE

        To remove a column, syntax requires: ALTER TABLE table_name DROP COLUMN column_name;
      2. Step 2: Check the given statement

        The statement misses the COLUMN keyword after DROP, causing syntax error.
      3. Final Answer:

        Missing COLUMN keyword after DROP -> Option C
      4. Quick Check:

        ALTER TABLE DROP COLUMN required [OK]
      Hint: DROP COLUMN must be used, not just DROP [OK]
      Common Mistakes:
      • Omitting COLUMN keyword after DROP
      • Confusing DROP TABLE with DROP COLUMN
      • Assuming DROP alone removes columns
      5. You want to permanently delete a table named orders and all its data from the database. Which SQL command should you use?
      hard
      A. ALTER TABLE orders DELETE;
      B. ALTER TABLE orders DROP;
      C. CREATE TABLE orders;
      D. DROP TABLE orders;

      Solution

      1. Step 1: Understand the purpose of DROP TABLE

        DROP TABLE deletes the entire table and its data permanently from the database.
      2. Step 2: Evaluate the options

        DROP TABLE orders; uses correct syntax. ALTER TABLE orders DROP; and D misuse ALTER. CREATE TABLE orders; creates a table instead of deleting.
      3. Final Answer:

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

        DROP TABLE = delete table permanently [OK]
      Hint: Use DROP TABLE to delete tables permanently [OK]
      Common Mistakes:
      • Using ALTER instead of DROP to delete tables
      • Confusing CREATE with DROP
      • Omitting TABLE keyword in DROP statement
      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