Home >Database >Mysql Tutorial >What are the Optimal Methods for Multi-row Inserts in Oracle?
Efficiently inserting multiple database records simultaneously is vital for database performance. Oracle offers several methods for achieving this.
INSERT ALL
(Oracle 9 and Earlier)For older Oracle versions (9 and below), the INSERT ALL
statement provides a viable solution:
<code class="language-sql">INSERT ALL INTO t (col1, col2, col3) VALUES ('val1_1', 'val1_2', 'val1_3') INTO t (col1, col2, col3) VALUES ('val2_1', 'val2_2', 'val2_3') INTO t (col1, col2, col3) VALUES ('val3_1', 'val3_2', 'val3_3') . . . SELECT 1 FROM DUAL;</code>
Oracle 23c simplifies multi-row inserts with a more concise syntax:
<code class="language-sql">INSERT INTO t(col1, col2, col3) VALUES ('val1_1', 'val1_2', 'val1_3'), ('val2_1', 'val2_2', 'val2_3'), ('val3_1', 'val3_2', 'val3_3');</code>
This method is particularly beneficial for high-volume data insertion, offering significant performance improvements.
For substantial data sets, consider these best practices:
The above is the detailed content of What are the Optimal Methods for Multi-row Inserts in Oracle?. For more information, please follow other related articles on the PHP Chinese website!