[KLUG Programming] questions on picking data types

bill bill at billtron.com
Wed Jul 14 15:13:45 EDT 2004


On Wed, 2004-07-14 at 13:53, Adam Tauno WIlliams wrote:

> Yep.  I usually just use INT since it is generic, and use some other
> mechanism to constrain the value.  

Exactly.

> Be aware that in MANY cases something
> like a smallint (which also exists in PostgreSQL, Informix, etc...) will
> just get 'thunked up' to a 32 bit integer by the application environment
> anyway.  PHP does this, and so do most others.  Reading a smallint just
> creates an int (in RAM on the client), so very little (if anything) is
> effectively gained.

One gotcha: if you create the field as tinyint(6) it won't work (that
is, the field will exist and work fine, but it won't be that big in the
db).  So, when you get db errors that you can't put anything bigger than
127 in that field you'll be stumped for a while.  Change the field to
int(6) and it will work fine.  Thus, I find it best to get out of the
habit of using anything other than INT for integers (unless they're
really big).


kind regards,

bill



More information about the Programming mailing list