Re: A modest proposal for a FAQ addition
От | Bruce Momjian |
---|---|
Тема | Re: A modest proposal for a FAQ addition |
Дата | |
Msg-id | 200301121454.h0CEsdb12481@candle.pha.pa.us обсуждение исходный текст |
Ответ на | Re: A modest proposal for a FAQ addition (Ian Barwick <barwick@gmx.net>) |
Ответы |
Re: A modest proposal for a FAQ addition
|
Список | pgsql-hackers |
Ian Barwick wrote: > On Sunday 12 January 2003 06:17, Bruce Momjian wrote: > > Tom Lane wrote: > > > Q: Why do I get strange results with a CHAR(n) field? > > > > > > A. Don't use CHAR(n). VARCHAR(n) has the behavior you are probably > > > expecting; on top of which it's more compact and usually faster. > > > > > > > > > I suppose the above needs some fleshing out, but man am I getting tired > > > of explaining about significant vs non-significant trailing blanks. > > > > OK, good point. I was mentioning CHAR() in the FAQ entry first, while > > it should have been mentioned later. I also added a specific mention of > > the trailing spaces issue. Patch attached. > > Err, from the patch: > > "CHAR(n) stores trailing spaces, while VARCHAR(n) trims them." > > Surely this should read something like: > > "CHAR(n) automatically pads strings with trailing blanks to the defined > column length." OK, new text is: <SMALL>VARCHAR(n)</SMALL> is best when storing variable-length strings but it limits how long a string can be. <SMALL>TEXT</SMALL> is for strings of unlimited length, maximum 1 gigabyte. <P><SMALL>CHAR(n)</SMALL> is for storing stringsthat are all the same length. <SMALL>CHAR(n)</SMALL> pads with blanks to the specified length, while <SMALL>VARCHAR(n)</SMALL>only stores the characters supplied. <SMALL>BYTEA</SMALL> is for storing binary data, particularlyvalues that include <SMALL>NULL</SMALL> bytes. These types have similar performance characteristics.</P> -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001+ If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania19073
В списке pgsql-hackers по дате отправления: