INSERT Statements

The INSERT statement is used to add new data to the database. It starts with the keywords INSERT INTO followed by the name of the table where you will be adding the record followed by a set of parentheses with the columns that you want to fill with information. The order of the columns is important.

Then comes the keyword VALUES and another set of parentheses. Inside the second set of parentheses comes the values that we are inserting. The values MUST be in the same order as the columns inside the first set of parentheses. Strings and dates get single quotes around them. Numbers do not need quotation marks.

INSERT INTO products (product_name, product_price, category_id) 
VALUES('Torque Wrench', 15.99, 2)

Remember

  1. The values have quotation marks, the column names do NOT.
  2. Use single quotes, not double quotes.
  3. The convention is to capitalize the SQL keywords like INSERT and INTO and VALUES
  4. The order of the columns has to match the order of the values.