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 strings that 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, particularly values that include <SMALL>NULL</SMALL> bytes. These types have similar performance characteristics.</P> -- Bruce Momjian | http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly