Re: [SQL] VARCHAR(50), CHAR(50) or TEXT ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: henrik(at)steffen(dot)stade(dot)net
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] VARCHAR(50), CHAR(50) or TEXT ?
Date: 1999-05-13 14:11:32
Message-ID: 8550.926604692@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Henrik Steffen <webmaster(at)city-map(dot)de> writes:
> But, what is the difference between VARCHAR and TEXT ?

Almost none. VARCHAR won't let you go beyond the stated maximum length,
whereas TEXT has no specific upper limit. Otherwise they are stored
in exactly the same way. (At least in Postgres ... dunno about other
DBMSs.)

I'd be inclined to use TEXT unless the maximum length were really an
important part of the semantics of the data for my application. If
you find yourself saying "Well, I *think* it'll never go beyond N
characters, but maybe I should add a little slop for safety" then
I'd say forget all about VARCHAR and use TEXT. If you find yourself
saying "it *had better not* go beyond N characters, because that
app over there will crash if it does" then use VARCHAR to enforce the
limit.

regards, tom lane

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 1999-05-13 16:07:58 Re: [SQL] VARCHAR(50), CHAR(50) or TEXT ?
Previous Message Engard Ferenc 1999-05-13 12:17:21 Re: [SQL] Slow Inserts Leads To Unable To Dump