Can we use more than one null value for unique key?
Answer Posted / dqm
In theory, a unique key may not contain any nulls. The
reason is simple: the key, by definition is an identifier
and it is illogical to identify something by an unknown.
In practice, some SQL databases permit nulls in unique
keys. Oracle, in particular, allows nulls as long as no
duplicate indices are created in the underlying unique
index. Since Oracle does not create a indices if all
columns are null, the floodgates are open.
For example, for a single column key, this is acceptable
because only the first row makes it to the index:
1
null
null
For a two column key, this is acceptable because in the
first two rows, the first column is unique and the last two
rows, being entirely null, are not represented in the index.
1, null
2, null
null, null
null, null
However, with the same two-column index, this is
unacceptable because the first two rows produce duplicate
inices:
1, null
1, null
null, null
null, null
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is inner join in sql?
How do you write an index?
When are we going to use truncate and delete?
What is scalar data type in pl sql?
What are the conditions an underlying table must satisfy before a cursor can be used by a positioned update or delete statement? : Transact sql
What are dml commands?
How to run pl/sql statements in sql*plus?
What is the non-clustered index in sql?
explain the delete statements in sql
How do I view tables in sql developer?
What does over partition by mean in sql?
What is the mutating table and constraining table?
What is a primary key example?
explain the difference between delete , truncate and drop commands? : Sql dba
Does sql between include endpoints?