Search Postgresql Archives

Semantics around INSERT INTO with SELECT and ORDER BY.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux