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: 1281
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 BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 1 Tue Jul 25, 2017 12:12 am
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm


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