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
Is it possible to Restore a Dropped Table using Rollback Command in Oracle SQL Plus ?
Explain 3 basic parts of a trigger.
How to use distinct and count in sql query? Explain
What are records give examples?
What is the difference between Union and Union all. Which is faster.
What is sql and also describe types of sql statements?
What is function and procedure?
How do I kill a query in postgresql?
Why trigger is used in sql?
What is the difference between nvl function, ifnull function, and isnull function?
what is bcp? When does it used? : Sql dba
What is the difference between clustered and non-clustered indexes?
How do you identify a primary key?
What is trigger in pl sql with examples?
What is use of package in pl sql?