If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > unique key

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-09, 07:54
Mathew_paul Mathew_paul is offline
Registered User
 
Join Date: Oct 2007
Posts: 200
unique key

hi

unique key won,t allow null values
more than one unique key can be created in a table
unique key won,t allow duplicate values
unique key default creates a indexe

What is the major difference unique and primary key ??

regds
Paul
Reply With Quote
  #2 (permalink)  
Old 12-30-09, 08:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by Mathew_paul View Post
unique key won,t allow null values
are you sure?

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-30-09, 09:48
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
Quote:
Quote:
Originally Posted by Mathew_paul
unique key won,t allow null values
are you sure?
Yes, unique constraint don't allow null values.
unique constraint and unique index are different things.

Descriptions of UNIQUE (column-name,...) and PRIMARY KEY (column-name,...)
in TABLE statement in "DB2 SQL Reference" are essentialy same, except...
Quote:
Only one primary key can be defined on a table.
Another use of PRIMARY KEY is...
Quote:
REFERENCES table-name or nickname

.....
.....

(column-name,...)

.....
.....

The list of column names must match the set of columns (in any
order) of the primary key or a unique constraint that exists on T2
(SQLSTATE 42890). If a column name list is not specified, then T2
must have a primary key
(SQLSTATE 42888). Omission of the
column name list is an implicit specification of the columns of that
primary key in the sequence originally specified.

Last edited by tonkuma; 12-30-09 at 09:55.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On