pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
varchar vs. text
11+ messages / 8 participants
[nested] [flat]

* varchar vs. text
@ 1998-10-24 17:37  Leslie Mikesell <les@Mcs.Net>
  0 siblings, 0 replies; 11+ messages in thread

From: Leslie Mikesell @ 1998-10-24 17:37 UTC (permalink / raw)
  To: pgsql-sql

Is there any way to apply the text functions to a varchar field or
convert from varchar to text?  I set up a database with varchar
fields with unspecified sizes because at the time the odbc driver
didn't like to use text as a unique key.  Now pg_dump sets the
size as (-5) which won't reload unless I take it out, and I can't
use many of the text-style operators.  Using field::text gives:
'ERROR:  function text(varchar) does not exist'.  Is there any
reason to use varchar now that the ODBC driver works with text,
and is there any way to convert short of pg_dump'ing and editing
the structure?  

 Les Mikesell
   les@mcs.com



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* VARCHAR vs TEXT
@ 2001-10-10 23:32  Aasmund Midttun Godal <postgresql@envisity.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Aasmund Midttun Godal @ 2001-10-10 23:32 UTC (permalink / raw)
  To: pgsql-sql

I am sure this question has been answered in some form or another before, but I can't really find anything on exactly this issue.

Are there any differences between varchar and text other than

1. varchar has limited size
2. varchar is SQL 92 text is not?

Especially regarding performance.

Or am I correct to assume that if you need a place to store some text, and you are not sure how much (like an email address or a name) you are best off using text?


Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-11 00:18  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Aasmund Midttun Godal <postgresql@envisity.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Stephan Szabo @ 2001-10-11 00:18 UTC (permalink / raw)
  To: Aasmund Midttun Godal <postgresql@envisity.com>; +Cc: pgsql-sql

On Wed, 10 Oct 2001, Aasmund Midttun Godal wrote:

> I am sure this question has been answered in some form or another
> before, but I can't really find anything on exactly this issue.
> 
> Are there any differences between varchar and text other than
> 
> 1. varchar has limited size
> 2. varchar is SQL 92 text is not?
> 
> Especially regarding performance.
> 
> Or am I correct to assume that if you need a place to store some text,
> and you are not sure how much (like an email address or a name) you
> are best off using text?

Pretty much yes.  text and varchar are pretty equivalent other than
the fact that varchar specifies a maximum size.





^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-13 03:54  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 2 replies; 11+ messages in thread

From: Bruce Momjian @ 2001-10-13 03:54 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: Aasmund Midttun Godal <postgresql@envisity.com>; pgsql-sql

> On Wed, 10 Oct 2001, Aasmund Midttun Godal wrote:
> 
> > I am sure this question has been answered in some form or another
> > before, but I can't really find anything on exactly this issue.
> > 
> > Are there any differences between varchar and text other than
> > 
> > 1. varchar has limited size
> > 2. varchar is SQL 92 text is not?
> > 
> > Especially regarding performance.
> > 
> > Or am I correct to assume that if you need a place to store some text,
> > and you are not sure how much (like an email address or a name) you
> > are best off using text?
> 
> Pretty much yes.  text and varchar are pretty equivalent other than
> the fact that varchar specifies a maximum size.

I have added the following paragraph to the FAQ:

    <P>CHAR() is best when storing strings that are usually the
    same length.  VARCHAR() is best when storing variable-length strings,
    but you want to limit how long a string can be.  TEXT is for strings
    of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
    binary data, particularly values that include NULL bytes.</P>

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@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



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-15 16:03  Vivek Khera <khera@kcilink.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 2 replies; 11+ messages in thread

From: Vivek Khera @ 2001-10-15 16:03 UTC (permalink / raw)
  To: pgsql-sql

>>>>> "BM" == Bruce Momjian <pgman@candle.pha.pa.us> writes:

BM>     <P>CHAR() is best when storing strings that are usually the
BM>     same length.  VARCHAR() is best when storing variable-length strings,
BM>     but you want to limit how long a string can be.  TEXT is for strings
BM>     of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
BM>     binary data, particularly values that include NULL bytes.</P>

Could you add the length limitation for TEXT to the reference manual?
I searched high and low for that limit, but never found it.  Also,
what's the max VARCHAR() or CHAR() I can create?  Is that also 1Gb?

Thanks.


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-16 04:22  Frank Zhu <frankzyz@etang.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 11+ messages in thread

From: Frank Zhu @ 2001-10-16 04:22 UTC (permalink / raw)
  To: pgsql-sql

I want to store a long article in the Postgresql in Linux, how can I put the
content into it and withdraw it back to show? urgent. Thanks.
I use JSP.
I note that all database systems are very dull in BLOB, but we need it to
make a good system. At least, the documentation/faq should have much on it.
thanks

Frank Zhu.
========================
"Bruce Momjian" <pgman@candle.pha.pa.us> дÈëÏûÏ¢ÐÂÎÅ
:200110130354.f9D3sQH01372@candle.pha.pa.us...
> > On Wed, 10 Oct 2001, Aasmund Midttun Godal wrote:
> >
> > > I am sure this question has been answered in some form or another
> > > before, but I can't really find anything on exactly this issue.
> > >
> > > Are there any differences between varchar and text other than
> > >
> > > 1. varchar has limited size
> > > 2. varchar is SQL 92 text is not?
> > >
> > > Especially regarding performance.
> > >
> > > Or am I correct to assume that if you need a place to store some text,
> > > and you are not sure how much (like an email address or a name) you
> > > are best off using text?
> >
> > Pretty much yes.  text and varchar are pretty equivalent other than
> > the fact that varchar specifies a maximum size.
>
> I have added the following paragraph to the FAQ:
>
>     <P>CHAR() is best when storing strings that are usually the
>     same length.  VARCHAR() is best when storing variable-length strings,
>     but you want to limit how long a string can be.  TEXT is for strings
>     of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
>     binary data, particularly values that include NULL bytes.</P>
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org





^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-16 12:56  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Vivek Khera <khera@kcilink.com>
  1 sibling, 2 replies; 11+ messages in thread

From: Bruce Momjian @ 2001-10-16 12:56 UTC (permalink / raw)
  To: Vivek Khera <khera@kcilink.com>; +Cc: pgsql-sql

> >>>>> "BM" == Bruce Momjian <pgman@candle.pha.pa.us> writes:
> 
> BM>     <P>CHAR() is best when storing strings that are usually the
> BM>     same length.  VARCHAR() is best when storing variable-length strings,
> BM>     but you want to limit how long a string can be.  TEXT is for strings
> BM>     of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
> BM>     binary data, particularly values that include NULL bytes.</P>
> 
> Could you add the length limitation for TEXT to the reference manual?
> I searched high and low for that limit, but never found it.  Also,
> what's the max VARCHAR() or CHAR() I can create?  Is that also 1Gb?

TEXT limit is 1GB, as shown on the 'limits' FAQ item.  Is it worth
mentioning here?  CHAR()/VARCHAR() also 1GB limit.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@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



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-16 14:08  Vivek Khera <khera@kcilink.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 11+ messages in thread

From: Vivek Khera @ 2001-10-16 14:08 UTC (permalink / raw)
  To: pgsql-sql

>>>>> "BM" == Bruce Momjian <pgman@candle.pha.pa.us> writes:

>> Could you add the length limitation for TEXT to the reference manual?
>> I searched high and low for that limit, but never found it.  Also,
>> what's the max VARCHAR() or CHAR() I can create?  Is that also 1Gb?

BM> TEXT limit is 1GB, as shown on the 'limits' FAQ item.  Is it worth
BM> mentioning here?  CHAR()/VARCHAR() also 1GB limit.

My personal belief is that most FAQ entries could go away if the
reference documentation had the necessary information...



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-16 15:46  Frank Bax <fbax@sympatico.ca>
  parent: Vivek Khera <khera@kcilink.com>
  1 sibling, 1 reply; 11+ messages in thread

From: Frank Bax @ 2001-10-16 15:46 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>

Perhaps 'limits' should be part of FAQ, not separate entity?

Also a reference (or link) to 'limits' from other sections such as
mentioned below may be more appropriate than duplicating the information.

Frank

At 08:56 AM 10/16/01 -0400, you wrote:
>> >>>>> "BM" == Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> 
>> BM>     <P>CHAR() is best when storing strings that are usually the
>> BM>     same length.  VARCHAR() is best when storing variable-length
strings,
>> BM>     but you want to limit how long a string can be.  TEXT is for
strings
>> BM>     of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
>> BM>     binary data, particularly values that include NULL bytes.</P>
>> 
>> Could you add the length limitation for TEXT to the reference manual?
>> I searched high and low for that limit, but never found it.  Also,
>> what's the max VARCHAR() or CHAR() I can create?  Is that also 1Gb?
>
>TEXT limit is 1GB, as shown on the 'limits' FAQ item.  Is it worth
>mentioning here?  CHAR()/VARCHAR() also 1GB limit.
>
>-- 
>  Bruce Momjian                        |  http://candle.pha.pa.us
>  pgman@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
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-16 15:55  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: Frank Bax <fbax@sympatico.ca>
  0 siblings, 0 replies; 11+ messages in thread

From: Bruce Momjian @ 2001-10-16 15:55 UTC (permalink / raw)
  To: Frank Bax <fbax@sympatico.ca>; +Cc: pgsql-sql


There is a limits FAQ item, not a separate limits FAQ.  Sorry for the
confusion.

> Perhaps 'limits' should be part of FAQ, not separate entity?
> 
> Also a reference (or link) to 'limits' from other sections such as
> mentioned below may be more appropriate than duplicating the information.
> 
> Frank
> 
> At 08:56 AM 10/16/01 -0400, you wrote:
> >> >>>>> "BM" == Bruce Momjian <pgman@candle.pha.pa.us> writes:
> >> 
> >> BM>     <P>CHAR() is best when storing strings that are usually the
> >> BM>     same length.  VARCHAR() is best when storing variable-length
> strings,
> >> BM>     but you want to limit how long a string can be.  TEXT is for
> strings
> >> BM>     of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
> >> BM>     binary data, particularly values that include NULL bytes.</P>
> >> 
> >> Could you add the length limitation for TEXT to the reference manual?
> >> I searched high and low for that limit, but never found it.  Also,
> >> what's the max VARCHAR() or CHAR() I can create?  Is that also 1Gb?
> >
> >TEXT limit is 1GB, as shown on the 'limits' FAQ item.  Is it worth
> >mentioning here?  CHAR()/VARCHAR() also 1GB limit.
> >
> >-- 
> >  Bruce Momjian                        |  http://candle.pha.pa.us
> >  pgman@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
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 4: Don't 'kill -9' the postmaster
> >
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@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



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: VARCHAR vs TEXT
@ 2001-10-16 20:13  Peter Eisentraut <peter_e@gmx.net>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 11+ messages in thread

From: Peter Eisentraut @ 2001-10-16 20:13 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: Vivek Khera <khera@kcilink.com>; pgsql-sql

Bruce Momjian writes:

> TEXT limit is 1GB, as shown on the 'limits' FAQ item.  Is it worth
> mentioning here?  CHAR()/VARCHAR() also 1GB limit.

It is already mentioned there.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter




^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2001-10-16 20:13 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-10-24 17:37 varchar vs. text Leslie Mikesell <les@Mcs.Net>
2001-10-10 23:32 VARCHAR vs TEXT Aasmund Midttun Godal <postgresql@envisity.com>
2001-10-11 00:18 ` Re: VARCHAR vs TEXT Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-10-13 03:54   ` Re: VARCHAR vs TEXT Bruce Momjian <pgman@candle.pha.pa.us>
2001-10-15 16:03     ` Re: VARCHAR vs TEXT Vivek Khera <khera@kcilink.com>
2001-10-16 12:56       ` Re: VARCHAR vs TEXT Bruce Momjian <pgman@candle.pha.pa.us>
2001-10-16 14:08         ` Re: VARCHAR vs TEXT Vivek Khera <khera@kcilink.com>
2001-10-16 20:13         ` Re: VARCHAR vs TEXT Peter Eisentraut <peter_e@gmx.net>
2001-10-16 15:46       ` Re: VARCHAR vs TEXT Frank Bax <fbax@sympatico.ca>
2001-10-16 15:55         ` Re: VARCHAR vs TEXT Bruce Momjian <pgman@candle.pha.pa.us>
2001-10-16 04:22     ` Re: VARCHAR vs TEXT Frank Zhu <frankzyz@etang.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox