INSERT INTO statement is used to insert a new row in a table. The
INSERT INTO statement can be written in many forms to insert data into a table.
If the statement does not specify the order of the columns, the values are added beginning with the first column. Alternatively, the columns could be specified, in any order, some or all.
SQL INSERT INTO Syntax
INSERT INTO table_name VALUES (value1, value2, value3,...)
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)
SQL INSERT INTO Examples
INSERT INTO Customers VALUES (1015,'Smith', 'John', 'Georgia', 'Atlanta')
INSERT INTO Customers (CustId, LastName, FirstName) VALUES (1015, 'Smith', 'John')
INSERT INTO also allows multiple rows to be inserted at one time. Unlike the previous example, where a single row of data was inserted into the table, we can also use the
SELECT statement to specify the data that we want to insert into the table, from another table.
INSERT INTO StoreData (storeName,Date,CustID) SELECT storeName, Date, CustID FROM AllSales