Re: Default order of select datname from pg_database

From: Jason Mathis <jmathis(at)redzonesoftware(dot)com>
To: Elías David <elias(dot)moreno(dot)tec(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Default order of select datname from pg_database
Date: 2014-04-19 14:45:50
Message-ID: A26D6648-3548-4AD1-A09C-83F69E1E4EA4@redzonesoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi David,

Ordering can never be assumed in SQL. If you want a particular order then you need an order by.

Hope that hopes!

Jason

> On Apr 19, 2014, at 1:19 AM, Elías David <elias(dot)moreno(dot)tec(at)gmail(dot)com> wrote:
>
> Hi all,
>
> By any change, does the following query have an "order by" by default when omitted?:
>
> select datname from pg_database;
>
> I know you could pass and ORDER BY datname or similar but what I don't know is if by default there's some kind of sort when the order by is omitted.
>
> I executed that query against one of my servers and while looking at the names it seems complety random, the order is always the same, for instance:
>
> web2
> template0
> asdf
> basic
> postgres
> web3
> .....
>
> Does anybody know?
>
> Thanks in advance!
>
> --
> Elías David.

--

This transmission contains confidential and privileged information intended
solely for the party identified above. If you receive this message in
error, you must not use it or convey it to others. Please destroy it
immediately and contact the sender at (303) 386-3955 or by return e-mail to
the sender.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2014-04-19 15:17:35 Re: Default order of select datname from pg_database
Previous Message Elías David 2014-04-19 07:19:14 Default order of select datname from pg_database