DDL Commands: CREATE, ALTER, DROP

Commands used to define or change the structure of database objects (tables, views, indexes).

Main Commands:

  • CREATE → Create objects
  • ALTER → Modify structure
  • DROP → Delete objects

1. CREATE (Make New Object)

Syntax:

CREATE TABLE table_name (
   column1 datatype constraints,
   column2 datatype constraints,
   ...
);

Example:

CREATE TABLE Students (
   ID INT NOT NULL,
   Name VARCHAR(50),
   Age INT CHECK (Age > 0),
   PRIMARY KEY (ID)
);

Key Points:

  • Defines table structure.
  • Supports constraints → NOT NULL, UNIQUE, CHECK, PRIMARY KEY.

2. ALTER (Change Structure)

Syntax:

ALTER TABLE table_name ADD column_name datatype;
ALTER TABLE table_name MODIFY column_name datatype;
ALTER TABLE table_name DROP COLUMN column_name;

Examples:

  • Add column → ALTER TABLE Students ADD Address VARCHAR(100);
  • Modify column → ALTER TABLE Students MODIFY Name VARCHAR(100);
  • Drop column → ALTER TABLE Students DROP COLUMN Address;

Key Points:

  • Can add, modify, or drop columns.
  • Data in table remains safe.

3. DROP (Delete Object)

Syntax:

DROP TABLE table_name;

Example:

DROP TABLE Students;

Key Points:

  • Removes object + its data permanently.
  • Cannot be undone → use carefully.

Quick Comparison

CommandPurposeMake a new object
CREATEMake new objectDefines structure (e.g., table, index)
ALTERChange structureUpdates structure, keeps data
DROPDelete objectRemoves object + data permanently

MCQs on CREATE, ALTER, DROP — DDL Commands


🔶 SECTION A — BASIC DEFINITIONS

1. CREATE, ALTER, DROP are part of which SQL category?

A. DML
B. DDL
C. TCL
D. DCL
Answer: B

2. CREATE command is used to:

A. Insert data
B. Modify data
C. Create database objects
D. Remove constraints
Answer: C

3. ALTER command is used to:

A. Delete table
B. Modify structure of a table
C. Insert row
D. Grant permissions
Answer: B

4. DROP command is used to:

A. Delete rows only
B. Delete table permanently
C. Remove duplicate values
D. Insert new columns
Answer: B

5. DDL commands are:

A. Auto-committed
B. Must use COMMIT
C. Reversible
D. Transactional
Answer: A


🔶 SECTION B — CREATE COMMAND

6. CREATE TABLE command creates:

A. New record
B. New column
C. New table
D. New constraint
Answer: C

7. Syntax of CREATE TABLE includes:

A. Column names
B. Data types
C. Constraints
D. All of the above
Answer: D

8. CREATE DATABASE creates:

A. A new table
B. A new schema
C. A new database
D. A new user
Answer: C

9. Why do we use CREATE VIEW?

A. To create temporary table
B. To create virtual table
C. To create permanent index
D. To create new user
Answer: B

10. Which of the following cannot be created using CREATE?

A. Table
B. Index
C. Trigger
D. Row
Answer: D


🔶 SECTION C — ALTER COMMAND

11. ALTER TABLE can be used to:

A. Add columns
B. Modify columns
C. Drop columns
D. All of these
Answer: D

12. To add a column “Age” to table Student, we use:

A. ALTER TABLE Student ADD COLUMN Age INT;
B. ADD Student TABLE Age;
C. INSERT Age TO Student;
D. MODIFY Student COLUMN Age;
Answer: A

13. ALTER TABLE MODIFY is used to:

A. Change data type
B. Insert row
C. Drop table
D. Create view
Answer: A

14. ALTER TABLE DROP COLUMN removes:

A. Data only
B. Column permanently
C. Only constraints
D. Only NULL values
Answer: B

15. ALTER command affects:

A. Table structure only
B. Data only
C. Both structure and data
D. Only Primary Key
Answer: A


🔶 SECTION D — DROP COMMAND

16. DROP TABLE deletes:

A. All rows only
B. Table structure + data
C. Only structure
D. Only metadata
Answer: B

17. DROP DATABASE removes:

A. One table
B. All tables + data
C. Only default tables
D. Only metadata
Answer: B

18. DROP is:

A. Reversible
B. Permanent
C. Temporary
D. Used for partial deletion
Answer: B

19. DROP INDEX is used to:

A. Delete index
B. Create table
C. Drop database
D. Insert row
Answer: A

20. DROP TABLE vs DELETE:

A. DROP deletes structure; DELETE deletes data
B. Both delete structure
C. DELETE deletes structure
D. Both delete rows only
Answer: A


🔶 SECTION E — DDL vs DML (VERY IMPORTANT)

21. DDL commands include:

A. CREATE, ALTER, DROP
B. SELECT, INSERT, UPDATE
C. COMMIT, ROLLBACK
D. GRANT, REVOKE
Answer: A

22. Which is NOT a DDL command?

A. CREATE
B. DELETE
C. DROP
D. ALTER
Answer: B (DELETE = DML)

23. Which is auto-committed?

A. INSERT
B. UPDATE
C. DELETE
D. DROP
Answer: D

24. Which cannot be rolled back?

A. ALTER
B. DROP
C. CREATE
D. All of the above
Answer: D

25. TRUNCATE belongs to:

A. DDL
B. DML
C. TCL
D. DCL
Answer: A


🔶 SECTION F

26. Create table Employee:

A. CREATE Employee TABLE;
B. CREATE TABLE Employee;
C. TABLE Employee CREATE;
D. ADD Employee TABLE;
Answer: B

27. Add column “Salary” of type INT:

A. ALTER TABLE ADD Salary INT;
B. ALTER TABLE Employee ADD Salary INT;
C. MODIFY TABLE Employee Salary INT;
D. INSERT COLUMN Salary;
Answer: B

28. Modify column Salary to DECIMAL:

A. ALTER TABLE Employee MODIFY Salary DECIMAL;
B. ALTER TABLE MODIFY Salary;
C. ALTER COLUMN Employee Salary;
D. TABLE MODIFY Salary;
Answer: A

29. Drop column Address:

A. DROP Employee COLUMN Address;
B. ALTER TABLE Employee DROP COLUMN Address;
C. DELETE COLUMN Address;
D. REMOVE COLUMN Employee;
Answer: B

30. Remove table permanently:

A. DELETE TABLE Employee;
B. DROP TABLE Employee;
C. REMOVE Employee;
D. TRUNCATE Employee;
Answer: B


🔶 SECTION G — BANKING SCENARIO

31. Add new column for AADHAAR number. Which command?

A. CREATE
B. ALTER ADD
C. ALTER DROP
D. DROP
Answer: B

32. To delete old BRANCH_MASTER table permanently, use:

A. DELETE
B. DROP
C. TRUNCATE
D. REMOVE
Answer: B

33. To modify AccountType length from 10 to 20 characters:

A. ALTER MODIFY
B. ALTER ADD
C. UPDATE LENGTH
D. CHANGE TYPE
Answer: A

34. To create CUSTOMER table:

A. CREATE TABLE
B. INSERT TABLE
C. MODIFY TABLE
D. BUILD TABLE
Answer: A

35. To remove ACCT_STATUS column, use:

A. ALTER TABLE DROP COLUMN
B. DELETE COLUMN
C. DROP STATUS ONLY
D. ALTER REMOVE
Answer: A


🔶 SECTION H

36. DROP removes:

A. Data only
B. Structure only
C. Both structure & data
D. Only constraints
Answer: C

37. ALTER command can:

A. Add constraints
B. Remove constraints
C. Modify constraints
D. All
Answer: D

38. Which command erases only data, not structure?

A. DROP
B. TRUNCATE
C. DELETE
D. REMOVE
Answer: C

39. CREATE command updates:

A. Data dictionary
B. Data table
C. Constraints only
D. User table
Answer: A

40. ALTER modifies:

A. Metadata
B. Data only
C. Logs only
D. Source code
Answer: A


🔶 SECTION I — TRUE / FALSE

41. DROP TABLE permanently deletes data.

True

42. ALTER TABLE can reduce column size.

True

43. CREATE TABLE can create multiple rows.

False

44. DROP cannot be rolled back.

True

45. ALTER TABLE only adds columns.

False


🔶 SECTION J — TRICKY

46. ALTER TABLE DROP COLUMN removes:

A. Column + its data
B. Only data
C. Only values
D. Only constraints
Answer: A

47. CREATE INDEX is used to:

A. Create new table
B. Improve search performance
C. Delete indexes
D. Create users
Answer: B

48. DROP INDEX removes:

A. Table
B. View
C. Index
D. Schema
Answer: C

49. Which command destroys table definition from memory?

A. DELETE
B. TRUNCATE
C. DROP
D. UPDATE
Answer: C

50. ALTER TABLE RENAME changes:

A. Table name
B. Column name
C. Both
D. None
Answer: C


🔶 SECTION K — ADVANCED QUESTIONS

51. CREATE TABLE AS SELECT creates:

A. Empty table
B. Table with data
C. Table structure + data
D. Constraintless table
Answer: C

52. If you drop a table referenced by FK, what happens?

A. Error
B. Automatically dropped
C. Column removed
D. Data duplicated
Answer: A

53. ALTER TABLE ADD CONSTRAINT is used to:

A. Add Primary Key
B. Add Foreign Key
C. Add Unique Key
D. All
Answer: D

54. DROP VIEW removes:

A. Only data
B. Only virtual table
C. Both
D. Related triggers
Answer: B

55. DROP SCHEMA removes:

A. Selected tables
B. All objects inside schema
C. Only indexes
D. Nothing
Answer: B

56. Which is safest command?

A. DROP
B. TRUNCATE
C. DELETE
D. RENAME
Answer: D

57. TRUNCATE removes:

A. Data only
B. Structure only
C. Constraints
D. Logs
Answer: A

58. ALTER TABLE MODIFY vs CHANGE:

A. Same
B. MODIFY changes datatype; CHANGE renames column
C. CHANGE changes datatype
D. None
Answer: B

59. Drop entire database:

A. DELETE DATABASE
B. DROP DATABASE
C. REMOVE DATABASE
D. TRUNCATE DATABASE
Answer: B

60. DROP fails when table has:

A. Primary key
B. Foreign key reference
C. Data
D. NULL values
Answer: B