Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can a primary key have null values? If we try to insert a
null value in a primary key column, will it work or give an
error code?

Answer Posted / ratheesh nellikal

In DB2 you can not create a primary key on a column which
is not 'not null'.
If you are trying to create a primary key on a column which
is not 'not null' then dbb2 will return an error like this

SQL0542N "feild_name" cannot be a column of a primary key
or unique key because it can contain null values.
SQLSTATE=42831

But once u alter the table and set the column to 'NOT NULL'
then you can make it as primary key.

Now if u r trying to insert an null value to ur primary key
column then db2 will trows an error like

SQL0407N Assignment of a NULL value to a NOT NULL
column "TBSPACEID=5, TABLEID=404, COLNO=0" is not allowed.
SQLSTATE=23502.

In short you can not make a column which can hold 'NULL'
value as your primary key and you can not insert a 'NULL'
value into your primary key feild.

Cheers,
Ratheesh Nellikal

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you find the maximum value in a column in db2?

1150


What type of database is db2?

1015


What is universal database?

1117


File not opened because library is *PROD and debug is UPDPROD(*NO). ? what may be the reason? how to solve it..?

3002


What is load utility in db2?

1227


What are sqlcodes –803,-805, -811, -818,-904,-911,-913,-101, +100?

1232


Define db2 and its databases?

1108


What's The Error Code For Unique Index Voilation?

1296


Explain various types of locks in db2?

1204


Is it possible using max on a char column?

1189


What is db2 and what is the use of db2 optimizer?

1108


I have a subprogram B calling from mainprogram A.I have opened a cursor in A ,Can i fetch the same cursor in subprogram B , If yes , Please explain the reason?

2433


Explain how can you do the explain of a dynamic sql statement?

1173


What are the 2 sqlcodes that are returned?

1230


What is database reorganization?

1179