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 > CHECK CONSTRAINTS and NOT NULL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-12-04, 16:09
soundharya_s soundharya_s is offline
Registered User
 
Join Date: May 2002
Posts: 30
CHECK CONSTRAINTS and NOT NULL

What is the difference between the following two definitions ... How do they differ in performance.

1) CREATE TABLE TAB1(COL1 INT NOT NULL,COL2 CHAR(8),COL3 CHAR(100))

2) CREATE TABLE TAB1(COL1 INT,COL2 CHAR(8),COL3 CHAR(100))
ALTER TABLE TAB1 ADD CONSTRAINT CHECK1 CHECK COL1 IS NOT NULL


TIA

Soundh
Reply With Quote
  #2 (permalink)  
Old 06-12-04, 18:48
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Not 100% sure, but I believe that option 2 still retains the extra null byte in the row, and does the normal null indicator processing for it (in the database engine and the application program), and then checks whether the null indicator is set to null. Processing is probably more expensive for option 2, but maybe not measurable.

In theory, disk storage and memory is more expensive for option 2 because of the null indicator byte. However, having just one column in a table with an extra byte may not decrease the number of rows that fit on a page, so it might not have any practical effect on disk or memory.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 06-12-04 at 18:53.
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