Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
>> This is an interesting idea. We don't allow ORDER BY in
>> INSERT INTO ...
>> SELECT because it doesn't make any sense, but it does make sense if
>> LIMIT is used:
> An "order by" also makes sense if you want to create a presorted table
> for faster access. I don't see why we should disallow it.
In current sources:
regression=# insert into int4_tbl select * from int4_tbl order by f1;
INSERT 0 5
regression=# select * from int4_tbl; f1
------------- 0 123456 -123456 2147483647-2147483647-2147483647 <<= insertion starts here
-123456 0 123456 2147483647
(10 rows)
LIMIT won't work without some further code-rejiggering, but I think
it should be made to work eventually.
regards, tom lane