SQL INSERT Statement

SQL INSERT statement is a type of statement in Structured Query Language (SQL) used to insert data into a database table. The INSERT statement allows us to insert a single row or multiple rows of data into a table.

Orders Table:

OrderIDCustomerID
110
220
330

Single row insert

Suppose we want to insert a new order with OrderID 4 and CustomerID 40 into the Orders table. In that case, we can use the following INSERT statement:

1INSERT INTO Orders (OrderID, CustomerID) 2VALUES (4, 40);

The output of the above query for Orders Table:

OrderIDCustomerID
110
220
330
440

As we can see from the output, the INSERT statement successfully inserts a new row of data into the Orders table.

Multiple row insert

In addition to inserting a single row, the INSERT statement can also be used to insert multiple rows of data into a table using the following syntax:

1INSERT INTO Orders (OrderID, CustomerID) 2VALUES (5, 50), (6, 60), (7, 70);

The output of the above query for Orders Table:

OrderIDCustomerID
110
220
330
440
550
660
770

As we can see from the output, the INSERT statement successfully inserts multiple rows of data into the Orders table.