IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

insert null values into uncique key column


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Thu Nov 25, 2010 5:38 pm
Reply with quote

Hi,

I am creating a table g3 as below

create table g3( a int not null with default, b varchar (10),unique(a))

when i try to do the below insert

insert into g3 (a,b) values(3,null),,,it working fine .

If i am trying to insert null into the a column which is unique its gives me a -407 error saying " insert into not null field).

So the definition of unique key says" we can insert only one null value into the unique key column".

So how can null vaues be inserted into the unique column AS we can't create a unique column without not null with default as definition.

Please explain and let me know if am going wrong anywhere.

Thank in advance,
L.Nethaji
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Nov 25, 2010 5:53 pm
Reply with quote

depending on what you want :
Code:
create table g3( a int  with default, b varchar (10)) ;
create unique index g3x on test13(a);

or
Code:
create table g3( a int  with default, b varchar (10)) ;
create unique where not null index g3x on test13(a);
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top