Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Any disadvantage to always using varchar?

3 views
Skip to first unread message

John

unread,
May 31, 2003, 4:48:21 PM5/31/03
to
I have a table setup and have set varchar for all columns.
Is there any real 'disadvantage' to using varchar even when some fields are
just numeric values etc.
It just seems simplier leaving everything as varchar.


Bart Van der Donck

unread,
Jun 1, 2003, 5:36:10 AM6/1/03
to
"John" <nos...@nospam.com> wrote in message news:<105441410...@eunomia.uk.clara.net>...

Alphanumeric: If your values don't vary much in length, CHAR is a
better choice than VARCHAR because tables with fixed-length rows can
be processed more efficiently than tables with variable-length rows.
Note: you can't mix VARCHAR with CHAR column types within the same
table -> MySQL then silently converts CHAR to VARCHAR! (eg. create a
table with CHAR and VARCHAR in it and then perform a DESCRIBE mytable,
you will see that they will be both indicated as VARCHAR)

Numeric: I would definitly use one of the INT flavours or FLOAT

I don't see any "urgent" disadvantages in your situation, but in case
of large tables this could result in weaker performance. Generally,
considering the idea of "good programming habits" (like transparency,
maintainance, efficiency...), I believe it's better to define your
columns more strictly.

Bart

0 new messages