Re: A modest proposal for a FAQ addition
От | Bruce Momjian |
---|---|
Тема | Re: A modest proposal for a FAQ addition |
Дата | |
Msg-id | 200301120517.h0C5HDN04339@candle.pha.pa.us обсуждение исходный текст |
Ответ на | A modest proposal for a FAQ addition (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: A modest proposal for a FAQ addition
|
Список | pgsql-hackers |
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. -- 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, Pennsylvania 19073 *** FAQ.html Sun Jan 12 00:15:28 2003 --- /bjm/FAQ.html Sun Jan 12 00:15:25 2003 *************** *** 1052,1066 **** stored out-of-line by <SMALL>TOAST</SMALL>, so the space on disk might also be less than expected.</P> ! <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 strings that are all the ! same length. <SMALL>CHAR(n)</SMALL> stores trailing spaces, while ! <SMALL>VARCHAR(n)</SMALL> trims them. <SMALL>BYTEA</SMALL> is for ! storing binary data, particularly values that include ! <SMALL>NULL</SMALL> bytes. These types have similar performance ! characteristics.</P> <H4><A name="4.15.1">4.15.1</A>) How do I create a serial/auto-incrementing field?</H4> --- 1052,1064 ---- stored out-of-line by <SMALL>TOAST</SMALL>, so the space on disk might also be less than expected.</P> ! <P><SMALL>CHAR(n)</SMALL> is best when storing strings that are ! usually the same length. <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. <SMALL>BYTEA</SMALL> is for storing binary data, ! particularly values that include <SMALL>NULL</SMALL> bytes. These ! types have similar performance characteristics.</P> <H4><A name="4.15.1">4.15.1</A>) How do I create a serial/auto-incrementing field?</H4>
В списке pgsql-hackers по дате отправления: