Re: Which one should I use: varchar() or char()?
Date: Mon, 05 Oct 2009 16:54:23 -0400
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.
- never use varchar.
- use char only when you really want fixed-width character strings (which is almost never, and in my situation *is* never)
- DO use varchar2 whenever you want to store string data
- 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