Home » SQL & PL/SQL » SQL & PL/SQL » NULL values & UNIQUE Key
NULL values & UNIQUE Key [message #251591] Sun, 15 July 2007 04:40 Go to next message
Messages: 62
Registered: July 2007
Location: Bangalore

I have some doubts regarding NULL values. Can any one help me in clearing my doubts.

I have created a table:-
create table suppliers
supplier_id number,
supplier_name varchar2(10)

Next, I will insert two records into this table.

insert into suppliers (supplier_id, supplier_name )
values ( 10565, null );

insert into suppliers (supplier_id, supplier_name )
values ( 10566, '' );

Q 1) Can any one tell which is the null value, whether it is supplier_name having 10565 or 10506.

2) Empty String is null value
NULL is null value

3) Because of this Null value doubts i have another doubt . How many null values can be their in a column if that column is defined as UNIQUE?

Re: NULL values & UNIQUE Key [message #251593 is a reply to message #251591] Sun, 15 July 2007 05:04 Go to previous message
Michel Cadot
Messages: 65153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Empty string is NULL and NULL is equivalent to an empty string.
NULL is not equal (nor not equal) to anything including NULL, so you can have as many NULL as you want in a UNIQUE constraint.

SQL> create table t (col integer unique);

Table created.

SQL> insert into t values ('');

1 row created.

SQL> insert into t values (null);

1 row created.

SQL> select count(*) from t where col is null;

1 row selected.

Previous Topic: SQL query needed
Next Topic: Grant - All objects in a schema to a new user
Goto Forum:

Current Time: Tue Aug 22 21:32:51 CDT 2017

Total time taken to generate the page: 0.01670 seconds