SQL
Efficiently Insert Multiple Rows into a Table
Optimize database performance by inserting several records at once using a single SQL INSERT statement for bulk data loading.
INSERT INTO products (name, price, stock) VALUES
('Laptop', 1200.00, 50),
('Mouse', 25.00, 200),
('Keyboard', 75.00, 100);
How it works: Instead of executing multiple `INSERT` statements for each new row, this snippet shows how to insert several rows in a single `INSERT` statement. This method is generally more efficient as it reduces the overhead of communication between your application and the database server, leading to faster bulk data insertion.