"rAinDeEr" <ta**********@gmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
Hi,
I have a web application with a table to store terms and
conditions of a Company.
This may some times run into many pages and some times it may be just a
few sentences. It is a character text field. I want to know which Data
type I need to use so that it doesnt waste memory.
I'm going to assume that you are worried about wasting disk space, not
memory, since most DBAs care much more about disk space than memory.
VARCHAR is a good choice for text fields of varying lengths if the lengths
aren't too great; DB2 stores only the actual amount of data desired in the
field, plus two bytes of overhead for the length. Therefore, if the terms
and conditions of one company is 100 bytes, only 102 bytes of storage are
needed and if the terms and conditions of another company are 5000 bytes,
only 5002 bytes are needed.
Stay away from CHAR and LONG VARCHAR for the terms and conditions data. CHAR
fields are probably not going to be long enough in many cases - they can
only be 254 bytes long at most and if you store your data in a CHAR(254)
field, every value in that column will occupy the full 254 bytes because
CHAR values are always padded with spaces to bring them up the maximum
length of the column. That can waste a lot of space. Avoid LONG VARCHAR
because those columns have their sizes calculated by the system and DB2 will
always make the column as big as it can possibly be. This has the
unfortunate side effect of making it impossible to add new columns to the
table without dropping and recreating the table.
Please note that VARCHAR columns cannot be more than 32,672 bytes long and
LONG VARCHARs cannot be more than 32,700 bytes long (assuming you are using
DB2 for Windows, Unix, and Linux and are running Version 8). If you expect
the terms and conditions for some companies to be longer than that, you will
want to use the CLOB datatype, which can store up to 2,147,483,647 bytes. If
your terms and conditions are even bigger than that, you will need to use
multiple columns to store it all or you will have to store the terms and
conditions separately from the data tables. When you use the LOB (Large
Object) datatypes, which include BLOB, CLOB, and DBCLOB, it is possible to
simply store a link to a document in the table column, rather than storing
the data itself; you might find that this approach makes your database
significantly smaller but it can also complicate the administration and
programming side of things for you.
--
Rhino