Subject | Re: [firebird-support] blank character |
---|---|
Author | Michael Ludwig |
Post date | 2011-05-12T20:19:40Z |
Mark Rotteveel schrieb am 09.05.2011 um 17:52 (+0200):
SQL> insert into chartest values ( 'abc ', 'abc ');
SQL> select c, char_length(c), vc, char_length(vc) from chartest;
C CHAR_LENGTH VC CHAR_LENGTH
========== ============ ========== ============
abc 10 abc 6
This is:
Firebird/x86/Windows NT (access method),
version "WI-V2.5.0.26074 Firebird 2.5"
select
c, char_length(c),
vc, char_length(vc)
from chartest
where c = vc;
--
Michael Ludwig
> So if I insert a String 'A ' in VARCHAR of length 5 or larger, ISQL> create table chartest (c char(10), vc varchar(10));
> should get that exact same string back when queried it should not trim
> the spaces. Firebird BTW does exactly that.
SQL> insert into chartest values ( 'abc ', 'abc ');
SQL> select c, char_length(c), vc, char_length(vc) from chartest;
C CHAR_LENGTH VC CHAR_LENGTH
========== ============ ========== ============
abc 10 abc 6
This is:
Firebird/x86/Windows NT (access method),
version "WI-V2.5.0.26074 Firebird 2.5"
> I would sooner say that if you want to save trailing spacesIn the above example, the two values do compare equal:
> consistently (as in: what goes in comes out again), then you use
> VARCHAR, if you want everything to have the same length (padded with
> spaces), then you use CHAR.
>
> I do agree with you that trailing spaces are considered insignificant
> in comparisons (SQL92 section 8.2).
select
c, char_length(c),
vc, char_length(vc)
from chartest
where c = vc;
--
Michael Ludwig