Re: varchar vs char vs text

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brett W(dot) McCoy" <bmccoy(at)chapelperilous(dot)net>
Cc: Singer Wang <swang(at)cs(dot)dal(dot)ca>, pgsql-novice(at)postgresql(dot)org
Subject: Re: varchar vs char vs text
Date: 2002-02-12 21:45:13
Message-ID: 24880.1013550313@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Brett W. McCoy" <bmccoy(at)chapelperilous(dot)net> writes:
> I'd go with text. It's not SQL92, though.

Check.

> varchar is technically supposed to have a limit of 255,

Certainly not; the spec says

The maximum value of <length> is implementation-defined.

There may be implementations that are lame enough to limit it to 255,
but Postgres isn't one of them. IIRC, we set a rather arbitrary upper
limit of 10000000 on the length (mainly on the theory that anything
larger is either a typo, or you really don't want a limit at all, in
which case you oughta be using text).

At least in 7.2, it also works to say just "varchar" with no length
limit; this is functionally equivalent to "text" except perhaps for
some corner cases involving ambiguous-data-type resolution. But
this is not SQL-spec-compliant either.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Brett W. McCoy 2002-02-12 22:44:41 Re: varchar vs char vs text
Previous Message Josh Berkus 2002-02-12 21:43:10 Re: "Hot Backups"