You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2009/11/03 22:47:32 UTC
[jira] Commented: (DERBY-4) "order by" is not supported for "insert
... select"
[ https://issues.apache.org/jira/browse/DERBY-4?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12773221#action_12773221 ]
Knut Anders Hatlen commented on DERBY-4:
----------------------------------------
Just to be clear, by the following
> and probably also forbid ORDER BY on VALUES at all
I take it you mean that it should be prohibited in an INSERT context,
and not generally for all VALUES clauses?
That is, this will be disallowed:
INSERT INTO T VALUES ('a','b'),('b','a') ORDER BY 2
Whereas this will still be allowed:
VALUES ('a','b'),('b','a') ORDER BY 2
If this is what you suggest, +1.
> Also, DEFAULT should be allowed only in simple VALUES clause, see
> DERBY-4426, ensuring it could never be the subject of sorting (e.g. in
> a UNION).
+1. I believe the current behaviour is just an unintended side-effect
of the implementation overloading UnionNode to represent both proper
UNIONs and multi-row VALUES clauses. Supporting this non-standard
extension of the syntax doesn't make much sense if it makes it harder
to get a consistent implementation of the syntax that the standard
actually defines. Also, I cannot imagine that "INSERT INTO ... VALUES
1 UNION VALUES DEFAULT" is widely used, if at all.
> "order by" is not supported for "insert ... select"
> ---------------------------------------------------
>
> Key: DERBY-4
> URL: https://issues.apache.org/jira/browse/DERBY-4
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Reporter: Christian d'Heureuse
> Priority: Minor
> Attachments: derby-4_dhw.diff, derby-4_dhw.stat, insertOrderBy.diff, insertOrderBy_v2.diff, insertOrderBy_v3.diff, samples.ij, samples.ij
>
>
> When filling a table with "insert ... select ...", "order by" cannot be specified.
> There is not method to copy a table sorted into another table (except using export/import). This would be useful to optimize performance for big tables, or to create identity values that are ascending (related to another column).
> Example:
> create table temp1 (
> s varchar(10));
> insert into temp1 values 'x','a','c','b','a';
> create table temp2 (
> i integer not null
> generated always as identity
> primary key,
> s varchar(10));
> insert into temp2 (s)
> select s from temp1 order by s;
> --> Error: "order by" is not allowed.
> -- trying to use "group by" instead of "oder by":
> insert into temp2 (s)
> select s from temp1 group by s;
> select * from temp2;
> --> "group by" did not sort the table.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.