
On Sun, Apr 24, 2011 at 11:45:38PM +0200, Ying Zhang wrote:
Hi,
I'm wondering if the following results of querying values of the type char(n) (here n = 50), is expected or an error, since char(n) defines a fixed-length, blank padded string:
sql>create table a2 (c1 char(5), c2 char(50)); operation successful sql>insert into a2 values ('abc', 'abc'), ('defg', 'defg'); 2 affected rows (2.848ms) sql>select c1, c2 from a2; +-------+----------------------------------------------------+ | c1 | c2 | +=======+====================================================+ | abc | abc | | defg | defg | +-------+----------------------------------------------------+ 2 tuples (1.655ms) sql>select '#' || c1 || '#' || c2 || '#' from a2; +------------------------------------------------------------+ | concat_single_value | +============================================================+ | #abc#abc# | | #defg#defg# | +------------------------------------------------------------+ 2 tuples (2.242ms) LQL The result of the first SELECT shows that c1 and c2 are blank padded (according to the SQL standard).
Not really. Only the rendering appears to be "blank padded" as the max. allowed string length is used as columns width for rendering; the values are not blank padded; cf. sql>\f Current formatter: sql sql>select c1, c2 from a2; +-------+----------------------------------------------------+ | c1 | c2 | +=======+====================================================+ | abc | abc | | defg | defg | +-------+----------------------------------------------------+ 2 tuples (1.281ms) sql>\fraw sql>select c1, c2 from a2; % sys.a2, sys.a2 # table_name % c1, c2 # name % char, char # type % 5, 50 # length [ "abc", "abc" ] [ "defg", "defg" ] Stefan
The result of the second SELECT looks a bit strange, are the padding space characters removed or added after the last '#'? Is this the expected result or an error?
Thanks,
Jennie ------------------------------------------------------------------------------ Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Stefan.Manegold @ CWI.nl | DB Architectures (INS1) | | http://CWI.nl/~manegold/ | Science Park 123 (L321) | | Tel.: +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |