Re: Which one should I use: varchar() or char()?

From: Walt <>
Date: Mon, 05 Oct 2009 16:54:23 -0400
Message-ID: <42tym.687$>

Ramon F Herrera wrote:
> I inherited a bunch of database tables and just noticed that for
> historical reasons, one of the important tables has records based on
> varchar(), and the other on char().
> What are the trade-offs between char() and varchar()? Which one should
> I use?

Don't use either. Use varchar2 or CLOB. Really.

  1. never use varchar.
  2. use char only when you really want fixed-width character strings (which is almost never, and in my situation *is* never)
  3. DO use varchar2 whenever you want to store string data
  4. If you're storing numerical or time data, do not use varchar2, use the appropriate datatype (integer, date, etc.)

As for whether it's worth fixing the old data design, that's a tradeoff that I'm not in a position to assess. But going forward, do it right. Don't use char or varchar.

//Walt Received on Mon Oct 05 2009 - 15:54:23 CDT

Original text of this message