Unique Index

If I run the following, what will happen?

CREATE TABLE myTable (someField int, UNIQUE (someField));
INSERT INTO myTable VALUES (null);
INSERT INTO myTable VALUES (NULL);

Answer: Two rows containing NULL will be inserted. NULL’s might be unique, so the unique index allows multiple.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.