Multiple Dynamic Inserts with SQL
Published on August 30, 2005
By Pete Freitag
By Pete Freitag
If you have ever had to do lots of SQL INSERT
statements you will know that they can get pretty slow. When looking for ways to speed up some inserts, I noticed that you can use a SELECT
subquery to provide the values. Like this:
INSERT INTO foo_archive (id, title) SELECT id, title FROM foo
This should work on Microsoft SQL Server, MySQL, PostgreSQL, and Oracle.
Multiple Dynamic Inserts with SQL was first published on August 30, 2005.
If you like reading about sql, insert, select, or subquery then you might also like:
- SELECT a random row with SQL
- Faster Inserts with PostgreSQL
- Insert Delayed with MySQL
- Multiple Inserts with MySQL
Discuss / Follow me on Twitter ↯
Tweet Follow @pfreitagComments
I WANT TO INSERT 100 RECORDS AT A TIME ..HOW CAN I BUILD THIS QUERY??
by SHAIIN on 07/20/2007 at 2:37:44 AM UTC