Multiple Dynamic Inserts with SQL
August 30, 2005
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.
Related Entries
- SQL to Select a random row from a database table - September 14, 2005
- Faster Inserts with PostgreSQL - August 31, 2005
- Insert Delayed with MySQL - August 2, 2005
- Multiple Inserts with MySQL - June 10, 2005



add to del.icio.us



