By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
CRAIG SHASHI ------------ CANADA ...etc
My second row is having 20 blank bytes....like this. If my table has millions of rows am I wasting a lot of space by putting each NULL row with 20 blanks? How do I avoid this? I mean how do I make it one byte (Nullable) or blank instead of 20?
You might want to choose the VARCHAR data type for this column instead of the CHAR data type. This will enable you to store only the amount of bytes required for each column value - that is, 5 bytes for CRAIG, 6 bytes for SHASHI, 6 bytes for CANADA, etc. Of course, this is not 100% accurate because a variable column requires a 2 byte length indicator. So every row will always require the 2 byte length indicator, but if the column is set to null you can set the length indicator to 0 and save space. Keep in mind, though, that you will have to programmatically set the length of each column as it is inserted or updated into the table.
Using your example, to use variable length columns you would define the column as NAME VARCHAR(20). That would allow you to store up to 20 bytes for the NAME column.
Dig Deeper on IBM DB2 management
Related Q&A from Craig S. Mullins
Our expert suggests that the best way to pass the SAP BW exam is to have hands-on job experience. But that's not all he has to say about ...continue reading
To export data from a DB2 table to a flat file, you need to run an export specifying the proper file format. The export utility exports data from a ...continue reading
Craig Mullins recommends two specific resources for learning how to create and support Binary Large Objects (BLOB) in DB2.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.