If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to add a not null constraint to an existing column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-04, 10:18
prithvi_raj prithvi_raj is offline
Registered User
 
Join Date: Apr 2004
Posts: 36
Angry How to add a not null constraint to an existing column

Vesrion 8.1 FP5

OS : Solaris 2.8


Can we add a not null constratint to an existing column?
If not what is the solution for this?
Reply With Quote
  #2 (permalink)  
Old 06-07-04, 10:22
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Talking

You have to drop the table and recreate it.

Newbie
Reply With Quote
  #3 (permalink)  
Old 06-07-04, 11:46
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
The other option you have is to add a check constraint by ALTERing the table ...

ALTER TABLE TABLE1 ADD CONSTRAINT constraint1 check (col1 is not null)

But, I do not have a definitive idea on the performance difference between a not null check constraint and a base table column definition ...

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On