From: | "David Johnston" <polobo(at)yahoo(dot)com> |
---|---|
To: | "'Gauthier, Dave'" <dave(dot)gauthier(at)intel(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: insert order question |
Date: | 2011-05-12 20:02:24 |
Message-ID: | 004b01cc10df$83744b90$8a5ce2b0$@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
See here:
http://www.postgresql.org/docs/9.0/static/sql-values.html
Implied is that the supplied data set will be returned in the same order as
written unless an ORDER BY is used to re-order the listing prior to it being
spit out the other end.
1, 3, 2 = > VALUES = > 1, 3, 2
1, 3, 2 = > VALUES ORDER ASC = > 1, 2, 3
The only time you end up with ordering issues is the "FROM 'physical table'"
because there is no defined order for how those records are stored into
memory; but when you explicitly list a set of data that explicit order is
maintained as long as possible.
David J.
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Gauthier, Dave
Sent: Thursday, May 12, 2011 3:37 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] insert order question
Hi:
Does...
insert into mytbl (col1) values ('a'),('b'),('c');
... insert records 'a','b','c' in that order while...
insert into mytbl (col1) values ('c'),('b'),('a');
... insert the records in the opposite order?
The order matters because there are triggers on the table which will react
differently depending on what's already in the table.
Thanks in Advance !
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-05-12 20:05:32 | Re: insert order question |
Previous Message | Tomas Vondra | 2011-05-12 20:00:17 | Re: Massive delete from a live production DB |