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 > Which one to choose from CHAR or DECIMAL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-10, 06:38
tkk tkk is offline
Registered User
 
Join Date: Mar 2010
Posts: 2
Which one to choose from CHAR or DECIMAL

Hi,

I am using Db2 v8.x. One of new table has "ID" column which will store 11 digits max. It is an Identifier.
In version 8.x BIGINT is not supported. Please suggest which one should I prefer BIGINT(19,0) or char(12) store 11 digit value in ID coulmn and why?
Reply With Quote
  #2 (permalink)  
Old 03-29-10, 08:08
DB2Plus DB2Plus is offline
Registered User
 
Join Date: Jul 2009
Posts: 150
Lightbulb Varchar(12)

Quote:
Originally Posted by tkk View Post
Hi,

I am using Db2 v8.x. One of new table has "ID" column which will store 11 digits max. It is an Identifier.
In version 8.x BIGINT is not supported. Please suggest which one should I prefer BIGINT(19,0) or char(12) store 11 digit value in ID coulmn and why?
If BIGINT is not supported you have to use Varchar(12), not a char(12)... Also you can use DECIMAL(11, 0).

Kara+
Reply With Quote
  #3 (permalink)  
Old 03-29-10, 08:49
tkk tkk is offline
Registered User
 
Join Date: Mar 2010
Posts: 2
Hi DB2Plus
Can you please explain which one will fit best Varchar(12) or DECIMAL(11, 0) and WHY ?
Reply With Quote
  #4 (permalink)  
Old 03-29-10, 08:55
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
BIGINT is supported in DB2 V8.x.

Decimal (11,0) takes up 6 bytes[(n+1)/2 rounded to next highest byte if necessary], and CHAR(11) takes up 11 bytes. BIGINT takes up 8 bytes.

Varchar has a 2 byte overhead for the actual number of bytes stored, plus the number of bytes (not sure why CHAR cannot be used).
__________________
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; 03-29-10 at 08:58.
Reply With Quote
  #5 (permalink)  
Old 03-29-10, 16:11
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
V8 (DB2 LUW) is out of service, so the whole product version is "not supported".
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Tags
bigint, db2 8

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