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: 1278
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 DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am


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