Subject | Re: [firebird-support] Value '' in varchar column |
---|---|
Author | Ann W. Harrison |
Post date | 2010-10-28T14:49:13Z |
On 10/28/2010 3:29 AM, crizoo4712 wrote:
whose value is the number of significant characters. So
in a column defined as varchar(6), an empty string is
represented as 0x0, 0x0, plus 6 bytes of whatever happens
to be in the buffer, normally zeros.
Just so people don't get confused, in memory and in messages,
varchar fields are stored at their full declared length. Before
the memory format of a record goes to disk, it suffers run length
compression, so - ignoring everything around it - the empty
varchar(6) is stored as two bytes with binary values of -8 and 0.
Cheers,
Ann
> Hi all,That's easy. A varchar is stored as two bytes of length
> what is the value stored in a varchar() column by:
> update tab1 set col1 = '' ?
whose value is the number of significant characters. So
in a column defined as varchar(6), an empty string is
represented as 0x0, 0x0, plus 6 bytes of whatever happens
to be in the buffer, normally zeros.
> It can be selected the same way (select * from tab1 where col1 = ''Right. The length is zero, so nothing is returned.
>
> But..
>
> ..select cast(col1 as varchar(128) character set octets) from tab1
> ..doesn't show anything (even not<NULL> or hex low value)!?!
Just so people don't get confused, in memory and in messages,
varchar fields are stored at their full declared length. Before
the memory format of a record goes to disk, it suffers run length
compression, so - ignoring everything around it - the empty
varchar(6) is stored as two bytes with binary values of -8 and 0.
Cheers,
Ann