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?

Answers were Sorted based on User's Feedback



Can a primary key have null values? If we try to insert a null value in a primary key column, will..

Answer / sangeetha

There cannot be null values in a Primary Key column.
It will result in error code.

Is This Answer Correct ?    26 Yes 3 No

Can a primary key have null values? If we try to insert a null value in a primary key column, will..

Answer / 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

Can a primary key have null values? If we try to insert a null value in a primary key column, will..

Answer / satya prasad n

The PRIMARY KEY cannot be null. you can insert ZERO into
that but should not be null. It will throw an error if you
try to inserts a NULL.

Is This Answer Correct ?    8 Yes 4 No

Can a primary key have null values? If we try to insert a null value in a primary key column, will..

Answer / guest

A primary key can have a NULL value. The error will be
shown only when NOT NULL is defined in the table creation.

Is This Answer Correct ?    10 Yes 10 No

Can a primary key have null values? If we try to insert a null value in a primary key column, will..

Answer / sachin borase

May be it will throws the -803 error (803 means index
violation )

Is This Answer Correct ?    1 Yes 4 No

Can a primary key have null values? If we try to insert a null value in a primary key column, will..

Answer / priya

Can you please clarify what kind of error code/sqlcode will
be returned if we try to insert a null value in a primary
key using a DB2 insert query?

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More DB2 Interview Questions

What is the purpose of the SDSNLOAD dataset in the STEPLIB while running DB2 programs?

2 Answers  


In my table having 100 Rec. How can I delete the 7th row?? (we don't know what is data inside the table)

9 Answers   IBM,


what is a trigger and types of triggers

3 Answers   HSBC,


What is isolation level in db2?

0 Answers  


How does one bind 2 versions of a CICS transaction with the same module name in two different CICS regions that share the same DB2 subsystem?

2 Answers  


What's The Error Code For Unique Index Voilation?

0 Answers   IBM,


What are the contents of dclgen?

0 Answers  


what are extents?

5 Answers  


What is the difference between cursor stability and repeatable read isolation levels?

0 Answers  


What is collection in db2 bind?

0 Answers  


What is Call attach facility? How does it work?

1 Answers   Syntel,


Give the COBOL definition of a VARCHAR field.

2 Answers  


Categories