In MySQL given a table and an index:
CREATE table table_1 (col1 int, col2 int);
create UNIQUE INDEX index_1_2 on table_1 (col1, col2);
We start filling the table with data executing following queries one after another, top to bottom. Select all queries that will execute correctly.
Explanation
It is obvious that fifth query will fail because of UNIQUE constraint violation.
What is not obvious though is that forth query will be executed correctly. The thing is that UNIQUE constraint allows multiple NULL values to be inserted.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback