Re: LENGTH function and trailing spaces
Posted in 1995
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...
Strange indeed. I've seen several.
: 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?
I think you are mistaken, June. I can do it with INSERT ... VALUES ...
from dbaccess!
: Hey, should I be answering questions for someone from Oracle? ;-)
They have to learn from somewhere I guess. :-)
--
graeme
--
Disclaimer: The author's opinions are his own, and not necessarily
those of Pyramid Technology Ltd. or Pyramid Technology Inc.
---------------------------------------------------------------------------
-m------- Graeme Sargent Voice: +44 (0)252 373035
---mmm----- Senior Database Consultant Fax : +44 (0)252 373135
-----mmmmm--- Pyramid Technology Ltd. Telex: Tell who???
-------mmmmmmm- Farnborough, Hants GU14 7PL Email: graeme@pyra.co.uk
---------------------------------------------------------------------------
We have the technology. The tricky bit is learning how to use it.