What is INSERT Statement And Example of INSERT Query ?

SQL INSERT INTO Statement :

The SQL INSERT INTO Statement is used to add new rows of data to a table in the database.

SQL INSERT statement inserts one or more rows of data into a table. You can also see INSERT written as INSERT INTO, but both behave the same. The inclusion of INTO is optional in most variants of SQL

 Syntax :

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

Example

The following statements add six records in the CUSTOMERS table.

INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Ram', 34, 'Ahmedabad', 3000.00 );

INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2, 'Rahul', 24, 'Patna', 1600.00 );

INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3, 'Harsh', 23, 'Mumbai', 4000.00 );

INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4, 'Raj', 27, 'Delhi', 7500.00 );

INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (5, 'Hemant', 29, 'Kanpur', 7500.00 );

INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6, 'Megha', 21, 'UP', 4500.00 );

All the above statements would produce the following records in the CUSTOMERS table as shown below.




| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
   1 | Ram      |  34 | Ahmedabad |  3000.00 
   2 | Rahul    |  24 | Patna     |  1500.00 
   3 | Harsh    |  23 | Mumbai    |  4000.00 
   4 | Raj      |  27 | Delhi     |  7500.00 
   5 | Hemant   |  29 | Kanpur    |  7500.00 
   6 | Megha    |  21 | UP        |  4500.00 

Leave a Reply