0
0
DBMS Theoryknowledge~20 mins

DDL (CREATE, ALTER, DROP) in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DDL Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding CREATE TABLE syntax

What will be the result of executing the following SQL statement?

CREATE TABLE Employees (ID INT PRIMARY KEY, Name VARCHAR(50), Age INT);

Choose the correct description of what this statement does.

AAdds three new columns to an existing Employees table: ID, Name, and Age.
BDeletes the Employees table if it exists and creates a new one with the specified columns.
CCreates a new table named Employees with three columns: ID, Name, and Age, where ID is the primary key.
DRenames an existing table to Employees and sets ID as the primary key.
Attempts:
2 left
💡 Hint

Think about what the CREATE TABLE command does in SQL.

📋 Factual
intermediate
2:00remaining
Effect of ALTER TABLE ADD COLUMN

What happens when you execute the following SQL command?

ALTER TABLE Employees ADD COLUMN Salary DECIMAL(10,2);
ADeletes the Salary column from the Employees table.
BAdds a new column named Salary to the Employees table with decimal values up to 10 digits and 2 decimal places.
CChanges the data type of the Salary column to DECIMAL(10,2).
DCreates a new table named Salary with the specified decimal format.
Attempts:
2 left
💡 Hint

Consider what ALTER TABLE with ADD COLUMN does.

🔍 Analysis
advanced
2:00remaining
DROP TABLE consequences

What is the immediate effect of running this SQL command?

DROP TABLE Employees;

Choose the correct outcome.

ARemoves the Employees table and all its data permanently from the database.
BDeletes all data inside Employees but keeps the table structure intact.
CRenames the Employees table to a temporary name.
DLocks the Employees table for editing but does not delete it.
Attempts:
2 left
💡 Hint

Think about what DROP TABLE does compared to DELETE or TRUNCATE.

Comparison
advanced
2:00remaining
Difference between ALTER TABLE MODIFY and ALTER TABLE RENAME

Which statement correctly describes the difference between these two commands?

ALTER TABLE Employees MODIFY Age SMALLINT;
ALTER TABLE Employees RENAME TO Staff;
AMODIFY deletes a column; RENAME TO deletes the table.
BMODIFY renames the table; RENAME TO changes a column's data type.
CBoth commands rename the table but in different ways.
DMODIFY changes the data type of a column; RENAME TO changes the table's name.
Attempts:
2 left
💡 Hint

Consider what MODIFY and RENAME TO do in ALTER TABLE statements.

Reasoning
expert
2:00remaining
Predicting error from DROP COLUMN on non-existent column

What error will this SQL command produce if the column 'Salary' does not exist in the Employees table?

ALTER TABLE Employees DROP COLUMN Salary;
AAn error indicating that the column 'Salary' does not exist.
BThe command will succeed and do nothing.
CThe Employees table will be deleted.
DThe command will rename the 'Salary' column to NULL.
Attempts:
2 left
💡 Hint

Think about what happens when you try to drop a column that isn't there.