Direct path inserting
In this recipe we will see how to insert many rows in a table using a particular INSERT
statement to boost performance.
How to do it...
The following steps demonstrates multiple row insertions in the same INSERT
statement:
- Connect to the
SH
schema:CONNECT sh@TESTDB/sh
- Create an empty table
MY_SALES
with theSALES
table structure:CREATE TABLE MY_SALES AS SELECT * FROM SALES WHERE ROWNUM < 1;
- Insert all the rows from
SALES
table in the newly-created table:SET TIMING ON INSERT INTO MY_SALES SELECT * FROM SALES; COMMIT; SET TIMING OFF
- Empty the
MY_SALES
table:TRUNCATE TABLE MY_SALES;
- Insert all of the rows from the
SALES
table in the newly-created table using direct path inserting:SET TIMING ON INSERT /*+ APPEND */ INTO MY_SALES ...
Get Oracle Database 11gR2 Performance Tuning Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.