Re: Limited varchar, unlimited varchar, or text?

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: Curtis Hawthorne <mr_person(at)mrperson(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Limited varchar, unlimited varchar, or text?
Date: 2003-07-24 15:12:20
Message-ID: Pine.LNX.4.33.0307240910570.25376-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 24 Jul 2003, Dmitry Tkach wrote:

> >
> >
> > After looking at the docs on the
> >character datatypes I noticed that if you don't specify a limit on the varchar
> >type it will accept strings of any length. If that's the case, what's the
> >difference between it and text?
> >
> >
> Actually, I'd like to know this too :-)
> I think that there is no difference really...
>
> But what confuses me is - why are there two completely separate types?
> Is it just to keep the standards happy?
> Or is there some hidden difference in the behaviour?
> For example, there used to be a 'datetime' in 7.2, that was just an
> alias for timestamp without timezone -
> so that:
> create table times (t timestamp without time zone, d datetime);
> \d times
> Column | Type | Modifiers
> --------+-----------------------------+-----------
> t | timestamp without time zone |
> d | timestamp without time zone |
>
>
> But if I try the same thing with text and varchar, I get two different
> type - text and character varying...
>
> Could somebody who knows shed some light on this?

They are the same, internally to postgresql. But, they retain their
unique type identifier (i.e. text versus varchar).

The primary difference is that things like access or odbc stuff usually
works better with varchar than text, so I often use varchar for things
windows boxes will be connecting to and using, and text for unix stuff
(i.e. php, perl, C code on unix interacting with the database.)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message tom dyson 2003-07-24 15:29:38 optimum postgres server configuration
Previous Message btober 2003-07-24 15:12:07 Re: List last value of all sequences