Learn how to use MySQL insert commands for working with tables and scripts.
SQL Insert Statement
When programming with SQL, one may use the Insert Into statement to insert new records into a selected table or change the configuration of the table’s rows. Programmers may use the same Insert Into statement and syntax for inserting rows into a table and for inserting records into a table, though the programmers must specify the type of data inserted into the table. There are two different forms in SQL programming for the Insert Into statement and the two different forms of code are:
The first form of SQL Insert Into syntax does not specify the column that contains the records; the only characteristics that one has to specify are the table name and the values one is placing in the table.
INSERT INTO table_name
VALUES (value1, value2, value3,…)
The second form of SQL Insert Into syntax allows one to specify the table name, the information one is inserting into the table and the columns designated to contain the values one enters.
INSERT INTO table_name (column1, column2, column3,…)
VALUES (value1, value2, value3,…)
Inserting Rows with SQL
One may add any number of rows to a table using the SQL Insert Into statement in the same manner as before, but with a different goal. Previously we learned how to enter information into a table and more specifically enter information into the columns one chooses. To add rows to a table using SQL Insert, one must insert the same syntax mentioned above though one must insert the statement into a table that is currently containing information in every cell. Upon entering a new SQL Insert statement, the table will expand to allow the newly defined values one is inserting. The only difference between the statements explained in the beginning of the article and the statements currently in use now is the amount of space in the table. For example, a full table with a three by three formation of cells and columns would expand with the addition of another SQL Insert Into statement to include the values specified in the Insert Into statement. One may also insert rows of information into specific columns with the second form of syntax mentioned in the beginning of this article. The syntax for the different forms always remains the same, though one must specify the parameters to add rows and information to a table. The following example shows how one may add an extra row to a table and insert the information into specific columns:
INSERT INTO Categories(Item_Number, Fruit, Color)
VALUES (4, ‘Strawberry’, ‘Red’)
The above statement would result in the addition of a fourth row to a table, with the information one is adding being placed into the columns that created to contain the information one is inserting.










