Re: LENGTH function and trailing spaces
Posted in 1995
Topics: Data Types & Schema Design
Thanks.. the only source I have for this information is the published book form of the doc. It says that VARCHAR DOES store trailing blanks (if you put them in and I don't think it said specifically how you do that) but it sure doesn't tell you how to get the length as it is really stored on disk. The reason I'm asking all these questions is that we have a gateway to Informix and there are things that Oracle users take for granted that Informix does differently (and vice versa of course) and I figured I'd just ask the experts. June Tong (junet@informix.com) wrote: : Kirk Bradley (kbradley@130.35.1.6) wrote: : : Sorry.. I didn't mean the dictionary length. I meant the length for each : : row. i.e. the length of a column as stored on disk. If I store 'KIRK ' : : and 'KIRK' I'd expect length(name) to give me 4 in both cases (cause : : it ignores trailing spaces) but I'd like to know if there is a SQL : : expression I can use to return 5 and 4. i.e. the length I would get : : if I fetched this column into a C program. : Hmmm... I don't see a response to this yet... strange... : The length of the column as stored on disk is the same as the dictionary : length, if you're talking about CHAR type. If you define your column as : CHAR(10), both 'KIRK' and 'KIRK ' are stored as 'KIRK '. On disk, : they're both stored with a length of 10. length(colname) will return 4 on : both. In other words, they are the same. : If you define the column as VARCHAR, then both 'KIRK' and 'KIRK ' are : stored as 'KIRK', and take up 4 bytes on disk (plus one for the length). : length(colname) will return 4 on both. In other words, they are the same. : I believe there is a way to get 'KIRK ' into a VARCHAR, and have length : return 5, but I don't remember how. Maybe when you LOAD it? : : Kirk Bradley : : Oracle Corporation : Hey, should I be answering questions for someone from Oracle? ;-) : June : ---- June Tong Informix Asia/Pacific ---- : ---- On-Loan Engineer Singapore ---- : ---- junet@informix.com (65) 298-1716 ---- -- Kirk Bradley Oracle Corporation Mainframe and Integration Technologies Group