If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. The INSERT INTO syntax would be as follows:
INSERT INTO table_nameVALUES (value1, value2, value3, ...);
Demo Database
Below is a selection from the "Customers" table :
INSERT INTO Example
The following SQL statement inserts a new record in the "Customers" table:
The selection from the "Customers" table will now look like this:
Did you notice that we did not insert any number into the CustomerID field?
The Customer ID column is an auto-increment field and will be generated automatically when a new record is inserted into the table.
Insert Data Only in Specified Columns
It is also possible to only insert data in specific columns.
The following SQL statement will insert a new record, but only insert data in the "Customer Name", "City", and "Country" columns (CustomerID will be updated automatically):
The selection from the "Customers" table will now look like this: