Received: from candle.pha.pa.us (maillist@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA73235 for ; Thu, 13 May 1999 12:09:30 -0400 (EDT) (envelope-from maillist@candle.pha.pa.us) Received: (from maillist@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id MAA16686; Thu, 13 May 1999 12:07:58 -0400 (EDT) From: Bruce Momjian Message-Id: <199905131607.MAA16686@candle.pha.pa.us> Subject: Re: [SQL] VARCHAR(50), CHAR(50) or TEXT ? In-Reply-To: <8550.926604692@sss.pgh.pa.us> from Tom Lane at "May 13, 1999 10:11:32 am" To: Tom Lane Date: Thu, 13 May 1999 12:07:58 -0400 (EDT) CC: henrik@steffen.stade.net, pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL56 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > Henrik Steffen 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. Don't forget, char() has a performance benefit over varchar()/text. varchar() allows you to document/clip a field to a specific lenght. Some people like that for fixed-type fields, like "A" for active, "R" for retired. char(1) documents it is only on character too. See the FAQ for info on this. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026