0
0
SQLquery~5 mins

Unique index behavior in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a unique index in a database?
A unique index ensures that all values in the indexed column(s) are different. It prevents duplicate values in those columns.
Click to reveal answer
intermediate
How does a unique index differ from a primary key?
A primary key is a unique index that also uniquely identifies each row and cannot contain NULL values. A unique index allows NULLs unless specified otherwise.
Click to reveal answer
beginner
What happens if you try to insert a duplicate value into a column with a unique index?
The database will reject the insert and return an error because the unique index prevents duplicate values.
Click to reveal answer
intermediate
Can a unique index be created on multiple columns? What does it enforce?
Yes, a unique index can cover multiple columns. It enforces that the combination of values across those columns is unique for each row.
Click to reveal answer
beginner
Does a unique index improve query performance? How?
Yes, a unique index helps the database find rows faster when searching by the indexed column(s), because it organizes data for quick lookups.
Click to reveal answer
What does a unique index prevent in a database table?
ADuplicate values in the indexed column(s)
BNULL values in any column
CAll rows from being deleted
DMultiple tables from being joined
Which of the following is true about a unique index?
AIt can be created on multiple columns
BIt allows duplicate values
CIt automatically creates a primary key
DIt disables data insertion
What error occurs if you insert a duplicate value into a unique indexed column?
ASyntax error
BDuplicate key error
CConnection error
DTimeout error
Does a unique index allow NULL values by default?
AOnly if the column is a primary key
BNo, it never allows NULLs
COnly in MySQL
DYes, usually it allows NULLs
How does a unique index affect query speed?
ASlows down queries
BHas no effect
CSpeeds up searches on indexed columns
DPrevents queries from running
Explain what a unique index is and how it helps maintain data integrity.
Think about how a unique index stops repeated values in a column.
You got /3 concepts.
    Describe the difference between a unique index and a primary key.
    Consider NULL values and row identification.
    You got /4 concepts.