Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

insert null values into uncique key column

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: insert null values into uncique key column
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: 1280
Location: Belgium

PostPosted: Thu Nov 25, 2010 5:53 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us