Thread: VARCHAR vs TEXT
I am sure this question has been answered in some form or another before, but I can't really find anything on exactly thisissue. 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 addressor a name) you are best off using text? Aasmund Midttun Godal aasmund@godal.com - http://www.godal.com/ +47 40 45 20 46
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.
> 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-lengthstrings, but you want to limit how long a string can be. TEXT is for strings of unlimited length, maximum1 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, Pennsylvania19026
>>>>> "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/
> >>>>> "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, Pennsylvania19026
>>>>> "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...
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, Pennsylvania19026
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
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 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