Questions: SQL: ALTER TABLE and Schema Modification

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Your team wants to add a NOT NULL column with a DEFAULT value to a 50-million-row orders table during peak business hours. Which outcome should you expect?

AThe operation completes instantly because adding a default is a metadata-only change
BThe operation rewrites every row to store the default value, locking the table for potentially minutes and blocking all reads and writes
CThe operation fails immediately because NOT NULL columns cannot have defaults
DThe operation succeeds but existing rows get NULL instead of the default value
Question 2 Multiple Choice

An ALTER TABLE command attempts to change a column from VARCHAR(100) to VARCHAR(50). Under what condition will this operation fail?

AAlways — data type changes require dropping and recreating the table
BNever — the database silently truncates values that exceed the new length
COnly if the column has a foreign key referencing another table
DIf any existing row contains a value longer than 50 characters in that column
Question 3 True / False

An ALTER TABLE operation that adds a nullable column with no default value is always a fast, metadata-only change regardless of table size.

TTrue
FFalse
Question 4 True / False

Dropping a column with ALTER TABLE DROP COLUMN is a reversible operation because the data remains in the table's storage pages until the next VACUUM.

TTrue
FFalse
Question 5 Short Answer

Why do some ALTER TABLE operations lock the table for seconds or minutes on large tables, while others complete almost instantly? What determines which category an operation falls into?

Think about your answer, then reveal below.