ORDER BY is case insensitive

From: Bryan White <nicktook(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: ORDER BY is case insensitive
Date: 2010-06-22 20:52:23
Message-ID: AANLkTimupyTgU-h-LKkV9VprzFopMMBKqsoO2RVpAzgL@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I was suprised to find out that ORDER BY is case insensitive. Is
there a way to do a case sensitive ORDER BY clause?

This transcript demonstrates what I am seeing:

$ createdb bryan
$ psql bryan
psql (8.4.4)
Type "help" for help.

bryan=# create table t (f text);
CREATE TABLE
bryan=# insert into t (f) values ('a');
INSERT 0 1
bryan=# insert into t (f) values ('b');
INSERT 0 1
bryan=# insert into t (f) values ('c');
INSERT 0 1
bryan=# insert into t (f) values ('B');
INSERT 0 1
bryan=# select * from t order by f;
f
---
a
b
B
c
(4 rows)

bryan=# \q
~ $ psql -l
List of databases
Name | Owner | Encoding | Collation | Ctype |
Access privileges
-----------------+----------+----------+-------------+-------------+-----------------------
bryan | bryan | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
:
postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
:
postgres=CTc/postgres
(4 rows)

--
Bryan White

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gerardo Herzig 2010-06-22 21:32:08 Re: ORDER BY is case insensitive
Previous Message Pavel Stehule 2010-06-22 14:40:23 Re: [SQL] How to Insert and retrieve multilingual (Hindi "an Indian language") into PostgreSQL