Re: varchar vs char vs text - Mailing list pgsql-novice

From Tom Lane
Subject Re: varchar vs char vs text
Date
Msg-id 24880.1013550313@sss.pgh.pa.us
Whole thread Raw
In response to Re: varchar vs char vs text  ("Brett W. McCoy" <bmccoy@chapelperilous.net>)
Responses Re: varchar vs char vs text
List pgsql-novice
"Brett W. McCoy" <bmccoy@chapelperilous.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

pgsql-novice by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: "Hot Backups"
Next
From: "Brett W. McCoy"
Date:
Subject: Re: varchar vs char vs text