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

how to enter binary numbers in sql statements? : Sql dba

708


Why procedure is used in sql?

754


What is rank function in sql?

724


name 3 ways to get an accurate count of the number of records in a table? : Sql dba

790


Is json a nosql?

723






what are properties of a transaction? : Sql dba

760


What is auto increment?

733


When is the update_statistics command used?

769


How much does sql cost?

735


How many types of triggers are there in pl sql?

781


What are the qualities of 2nf?

747


how to create a test table in your mysql server? : Sql dba

686


Can we use the cursor's to create the collection in PL/SQL?

700


Under what condition it is possible to have a page level lock and row lock at the same time for a query? : Transact sql

748


What type of join is sql join?

719