If I insert using the results of a select statement, are the inserts
guaranteed to happen in the order of the rows returned from the select?
That is, are these two equivalent:
INSERT INTO SELECT FROM ORDER BY DESC;
And:
FOR row IN SELECT FROM ORDER BY DESC LOOP
INSERT INT
This is relevant for tables that have a column with a SERIAL type, I need
to guarantee that the relative ordering remains the same as the ordering of
the selected result set.
More concretely, given:
> CREATE TABLE foo (id SERIAL, val TEXT);
> CREATE TABLE bar (id SERIAL, val TEXT);
>
Thank you all! Your answers cleared this up for me.
Tom, in particular, that reference commit removed any ambiguity for me.
Thank you. It's much appreciated.
On Tue, Jun 12, 2018 at 7:27 AM Tom Lane wrote:
> "David G. Johnston" writes:
> > On Tuesday, June 12, 20