Semantics around INSERT INTO with SELECT and ORDER BY. - Mailing list pgsql-general

From Steve Krenzel
Subject Semantics around INSERT INTO with SELECT and ORDER BY.
Date
Msg-id CADBwkHv1nUx5bqxqRLp26k8iUWSnY3uW-1_0EMYxKns0t2JnUA@mail.gmail.com
Whole thread Raw
Responses Re: Semantics around INSERT INTO with SELECT and ORDER BY.  (Ravi Krishna <sravikrishna3@gmail.com>)
List pgsql-general
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 <table2> SELECT <field> FROM <table1> ORDER BY <col> DESC;

And:

    FOR row IN SELECT <field> FROM <table1> ORDER BY <col> DESC LOOP
        INSERT INTO <table2> VALUES (row.<field>);
    END LOOP;

I read through the SQL spec on insertion but they don't address insertion ordering (perhaps, purposefully).

Any clarification here would be super helpful.

Thank you!
Steve

pgsql-general by date:

Previous
From: "a"
Date:
Subject: Does pgAgent support chinese, japanese characters?
Next
From: Ravi Krishna
Date:
Subject: Re: Semantics around INSERT INTO with SELECT and ORDER BY.