Can we use more than one null value for unique key?

Answer Posted / amit rajoria

Yes, we can use multiple Null values in case of Unique Key
Column. This is one the main difference between Unique Key
and Primary Key that Unique Key always allows multiple
entries of Null Statement where as Primary Key never allows
this.

I am hereby giving you a very very basic example which
suggests that Unique Key can have more than one Null
Statement :-

SQL> create table abcd(name varchar2(10) unique);

Table created.

**********************

Now insert the values :-

SQL> insert into abcd(name)values('amit');

1 row created.

SQL> insert into abcd(name)values('ami');

1 row created.

SQL> insert into abcd(name)values(null);

1 row created.

SQL> insert into abcd(name)values(null);

1 row created.

SQL> insert into abcd(name)values(null);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from abcd;

NAME
----------
amit
ami



Here blank space above represents the entries of null
statements..!!

Is This Answer Correct ?    14 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is sql in mysql? : Sql dba

571


How do you modify a trigger?

527


What does inner join mean?

558


Which data type is a composite type?

533


what is dbms? : Sql dba

545






What is a ddl command?

540


How do I enable sql encryption?

519


What is relationship? How many types of relationship are there?

592


What is the difference between cross join and natural join?

567


Explain what is table in a database?

582


Is primary key clustered or nonclustered?

568


What is schema in sql?

518


What is the difference between microsoft access and sql?

500


what is the use of double ampersand (&&) in sql queries?

627


What is rollback?

586