Re: select statement sorting - Mailing list pgsql-general

From Steve Atkins
Subject Re: select statement sorting
Date
Msg-id 20040331164447.GA12609@gp.word-to-the-wise.com
Whole thread Raw
In response to select statement sorting  (Alexander Cohen <alex@toomuchspace.com>)
List pgsql-general
On Wed, Mar 31, 2004 at 10:31:43AM -0500, Alexander Cohen wrote:
> is it possible to have postgres return a "SELECT * FROM table ORDER BY
> table_column" query that is not case sensitive order?

> Is this possible or do i need to sort them myself after the query
> returns?

SELECT * FROM table ORDER BY lower(table_column)

will do what you want.

[ If you start using this idiom for larger tables then remember that order
  by lower(something) won't take any advantage of an index on something -
  but may use a functional index on lower(something) ]

> Also, i noticed that postgres will let me create groups, databases and
> users with spaces in their names, is this ok or should i check this
> beforehand and not allow this?

I'd avoid it. It may well be acceptable within postgresql (I see no reason
why it wouldn't be) but I'd bet that it'll confuse or break some third
party tools.

Cheers,
  Steve

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Documentation clairification?, CHECK constraints
Next
From: "Karl O. Pinc"
Date:
Subject: Re: How can I change type of column