SQL Insert into Statement


The INSERT INTO statement is used to insert new rows into a table. It is possible to write the insert into statement in two forms:
 INSERT INTO table
   VALUES ( value1, value2, .... )

 INSERT INTO table ( col1, col2, col3, ... )
   VALUES ( value1, value2, .... )
The following empty table Persons was created by the previous create table statement:

P_Id LastName FirstName Address City
         

Insert three persons into the table Persons:

 INSERT INTO  Persons
   VALUES (1, 'Hansen', 'Ola', 'Timoteivn 10', 'Sandnes');
 INSERT INTO  Persons
   VALUES (2, 'Svendson', 'Tove', 'Borgvn 23', 'Sandnes');
 INSERT INTO  Persons
   VALUES (3, 'Pettersen', 'Kari', 'Storgt 20', 'Stavanger');

The table Persons now becomes the following:

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger


Demonstration
The following is an SQL test area from W3Schools, which uses the well-known Northwind sample database and the tables are for read only.
For security reasons, the following demonstration may only work in Chrome.

SQL Statement:

Edit the SQL statement and click     to see the result, or    

Result:

Click “Run SQL” to execute the SQL statement above.
W3Schools has created an SQL database in your browser.
The menu to the right displays the database, and will reflect any changes.
Feel free to experiment with any SQL statement.
You can restore the database at any time.
The Database includes:
The Database includes:

TablenamesRecords
Customers91
Categories8
Employees10
OrderDetails518
Orders196
Products77
Shippers3
Suppliers29