SQL INSERT INTO Statement
INSERT INTO Statement
The INSERT INTO statement is used to insert new rows into the table.
Syntax
INSERT INTO Table Name VALUES (Value1, Value2,...)
We can also specify the columns to insert the data into:
INSERT INTO table_name (Column1, Column2,...) VALUES (Value1, Value2,...)
Insert a new row
"Persons" Table:
LastName |
FirstName |
Address |
City |
Carter |
Thomas |
Changan Street |
Beijing |
SQL Statement:
INSERT INTO Persons VALUES ('Gates', 'Bill', 'Xuanwumen 10', 'Beijing')
Result:
LastName |
FirstName |
Address |
City |
Carter |
Thomas |
Changan Street |
Beijing |
Gates |
Bill |
Xuanwumen 10 |
Beijing |
Insert data in the specified column
"Persons" Table:
LastName |
FirstName |
Address |
City |
Carter |
Thomas |
Changan Street |
Beijing |
Gates |
Bill |
Xuanwumen 10 |
Beijing |
SQL Statement:
INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
Result:
LastName |
FirstName |
Address |
City |
Carter |
Thomas |
Changan Street |
Beijing |
Gates |
Bill |
Xuanwumen 10 |
Beijing |
Wilson |
|
Champs-Elysees |
|