SQL – Insert Into Statement

Table Of Contents:

  1. What Is SQL Insert Statement?
  2. Syntax Of Insert Statement.
  3. Examples Of Insert Statement.

(1) What Is SQL Insert Statement ?

  • The INSERT INTO  statement is used to insert new records in a table.

(2) Syntax Of SQL Insert Statement ?

Syntax-1:Specify both the column names and the values to be inserted:

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

Syntax-2: Only Specify The Values

INSERT INTO table_name
VALUES (value1, value2, value3, ...);

Note:

  • Make sure the order of the values is in the same order as the columns in the table.

(3) Examples Of Insert Into Statement

Demo Data:

Example-1:

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway');

Example-2: Insert Data Only in Specified Columns

INSERT INTO Customers (CustomerName, City, Country)
VALUES ('Cardinal', 'Stavanger', 'Norway');

Leave a Reply

Your email address will not be published. Required fields are marked *