Data Definition Language (DDL) Flashcards
7 cards from real SQL practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Data Definition Language (DDL) flashcards as text
Which constraint ensures a column cannot contain duplicate values but allows one NULL in many systems?
Answer: UNIQUE
A UNIQUE constraint forbids duplicate values while typically permitting a single NULL.
What does a FOREIGN KEY constraint enforce?
Answer: Referential integrity between two tables
A FOREIGN KEY ensures values in one table match values in a referenced table, maintaining referential integrity.
Which clause defines a column that automatically gets a value when none is supplied on INSERT?
Answer: DEFAULT
The DEFAULT clause provides a value automatically when an INSERT omits that column.
A CHECK constraint is used to do what?
Answer: Limit the range of values allowed in a column
A CHECK constraint restricts column values to those satisfying a specified Boolean condition.
How can you add a constraint to an existing table?
Answer: ALTER TABLE ... ADD CONSTRAINT
ALTER TABLE ... ADD CONSTRAINT attaches a new constraint to an already-existing table.
What happens by default when you try to insert a NULL into a column defined as NOT NULL?
Answer: The statement fails with an error
A NOT NULL column rejects NULL values, causing the insert to fail unless a value is provided.
Which combination of properties best describes a PRIMARY KEY?
Answer: Unique and NOT NULL
A PRIMARY KEY is both unique and NOT NULL, uniquely identifying each row.