Hi,

Internally, the INSERT statements does support direct insert (class
Insert, field insertFromSelect). This is uses for CREATE TABLE AS
SELECT. The reason it's not used for INSERT INTO .. SELECT is: you
could create some kind of endless loop or (indirectly) modify the
source table in the INSERT part. The easiest example is:

INSERT INTO TEST SELECT * FROM TEST

Such simple cases could be detected, however it's not possible in more
complex cases. For example the insert in the target table could affect
the source table(s) using a trigger. I don't know yet how other
databases solve this problem.

Of course it can't happen in your case (except if you append to the
CSV file during the insert), so I think I will support a workaround
for now, similar to the INSERT INTO ... SORTED SELECT feature
documented here:
http://h2database.com/html/performance.html#fast_import

What about:

INSERT INTO <table> DIRECT SELECT * from CSVREAD('<file>')

I will document this in the performance documentation as well as in the grammar:

INSERT INTO ... [DIRECT] [SORTED] SELECT ...

When using DIRECT, then the results from the query are directly
applied in the target table without any intermediate step.

When using SORTED, b-tree pages are split at the insertion point. This
can improve performance and reduce disk usage.

Regards,
Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to