I have the following table (created and populated them in Oracle and PostgreSQL):
> create table foo (a varchar(10));
I populated them with values, and order by
clause is behaving differently in PostgreSQL and Oracle (I don't think versions are relevant to this question):
Oracle:
> select a, length(a) from foo order by a;
A LENGTH(A)
---------- ----------
.1 2
01 2
1 1
1#0 3
1#1 3
1.0 3
1.1 3
10 2
11 2
9 rows selected.
I get what I expect. .1
before 01
, since .
is before 0
in ascii table.
However, in PostgreSQL I have:
=> select a, length(a) from foo order by a;
a | length
-----+--------
01 | 2
1 | 1
.1 | 2
10 | 2
1.0 | 3
1#0 | 3
11 | 2
1.1 | 3
1#1 | 3
(9 rows)
Why the difference? I know it probably has something to do with collate order or similar, but I would like some pointers on where to read more about it.
UPDATE: collate info on the PostgreSQL database:
Encoding: UTF8
Collante: en_US.UTF-8
Ctype: en_US.UTF-8 |
Thanks!