SQL INSERT INTO Statement


The SQL INSERT INTO statement is used to add a new record or rows of column data in a specific table.

It is also is used to add one or multiple new rows or records at once in a table.

Note: Most of the databases will not supports inserting multiple records at once.


Search Keys

  • insert into sql
  • insert into table
  • t sql insert into
  • insert into values select
  • insert into select sql server
  • insert into multiple rows
  • insert into table sql
  • insert into values
  • insert into syntax
  • insert into table values
  • insert command in sql
  • oracle insert statement
  • insert query in sql
  • sql insert multiple rows
  • how to insert multiple rows in sql
  • insert values in table
  • how to insert data in sql
  • sql insert syntax
  • multiple insert sql
  • insert query in sql server
  • insert command sql
  • insert row sql
  • insert data sql
  • insert example
  • sql insert row

SQL INSERT INTO Syntax

There are two ways to insert a row or records to a table.

  • Insert Data Only in Specified Columns
  • Insert Data in All Columns

Insert Data Only in Specified Columns

The first way provides both the column names and the data values to be inserted:


INSERT INTO table_name (column_name1, column_name2, column_name3,...column_nameN)
VALUES (value1, value2, value3,...valueN);

NOTE: When inserting rows into a table using the SQL INSERT INTO statement, you must specify a value for every NOT NULL column. You can omit a column name from the SQL INSERT INTO statement if the column name allows NULL values.

Insert Data in All Columns

The second way does not provide the column names where the data will be inserted, only their values:

You may not need to provide the column names in the SQL INSERT INTO query statement if you are adding values for all the column names of the table.


INSERT INTO tablename
VALUES (value1, value2, value3,...valueN);

Note: Make sure the order sequence of the values is in the same sequence as the column names in the table.


Sample Database Table - Employee

ID EmpName Designation Dept JoinYear Salary
1 Chandra Project Lead PHP 2014 19010.3
2 Sakunthala Sql Team Adminstrator PHP 2015 18380
3 Rishi Keshan Developer Java 2012 15650.6
4 Padmavathi Sql Team Adminstrator MySQL 2014 2420
5 Varshini Kutty Big Data PHP 2015 20900
6 Nirmala Database Developer C#.Net 2015 10400

Sample Database Table Structure - Employee

Column Name Data Type
ID Number
EmpName Text
Designation Text
Dept Text
JoinYear Number
Salary Number

Text Column Vs Numeric Column

SQL requires single or double(most database support) quotes around text or string values. However, we write numeric fields without quotes:


SQL INSERT INTO Example - Insert Data Only in Specified Columns

The following SQL statement will insert a new row, but only insert data in the "ID", "EmpName", "Dept" and "Salary" columns in the "Employee" table:


INSERT INTO Employee (ID, EmpName, Dept, Salary)
VALUES (7, 'Dharan', 'Data Designer', 18000);

In the above query, we have not inserted on the "Designation" and "JoinYear" columns.

One more SQL query, The following SQL statement will insert a new row, but only insert data in the "ID" and "JoinYear" columns in the "Employee" table:


INSERT INTO Employee (ID, JoinYear)
VALUES (8, 2015);

In the above query, we have not inserted on the "EmpName, "Designation", and "Salary" columns.

The result of above both query is:

ID EmpName Designation Dept JoinYear Salary
1 Chandra Project Lead PHP 2014 19010.3
2 Sakunthala Sql Team Adminstrator PHP 2015 18380
3 Rishi Keshan Developer Java 2012 15650.6
4 Padmavathi Sql Team Adminstrator MySQL 2014 2420
5 Varshini Kutty Big Data PHP 2015 20900
6 Nirmala Database Developer C#.Net 2015 10400
7 Dharan Data Designer 18000
8 2015

SQL INSERT INTO Example - Insert Data in All Columns

The following SQL statement will insert a new row for all columns in the "Employee" table:


INSERT INTO Employee 
VALUES (9, 'Suresh Babu', 'Sql Programmer', 'SQL Server', 2012, 13500);

INSERT INTO Employee (ID, EmpName, Designation, Dept, JoinYear, Salary) 
VALUES (10, 'Rishi Kesan', 'Project Leader', 'Java', 2014, 25000);

The result of above both query is:

ID EmpName Designation Dept JoinYear Salary
1 Chandra Project Lead PHP 2014 19010.3
2 Sakunthala Sql Team Adminstrator PHP 2015 18380
3 Rishi Keshan Developer Java 2012 15650.6
4 Padmavathi Sql Team Adminstrator MySQL 2014 2420
5 Varshini Kutty Big Data PHP 2015 20900
6 Nirmala Database Developer C#.Net 2015 10400
7 Dharan Data Designer 18000
8 2015
9 Suresh Babu Sql Programmer SQL Server 2012 13500
10 Rishi Kesan Project Leader Java 2014 25000

Search Keys

  • t sql insert multiple rows
  • insert row into table sql
  • sql insert values into table
  • query to insert values into table
  • insert all into sql
  • sql insert multiple records
  • sql batch insert
  • postgresql insert
  • insert multiple rows in sql
  • insert column sql
  • sql insert column
  • insert multiple records in sql
  • multiple insert query in sql
  • create new row sql
  • sql query add values
  • sql add command
  • sql add statement
  • add row to sql table
  • sql insert statement multiple rows
  • insert multiple values in sql
  • insert query in sql with where condition
  • insert select from
  • sql insert values from select
  • sql insert where
  • insert from select sql