SQL Commands : INSERT

The INSERT command is used to add new rows of data to an existing table in the database. There are two basic syntax of the INSERT statement :

Syntax 1 :
INSERT INTO table_name (column1, column2, column3,...columnN) 
    VALUES (value1, value2, value3,...valueN);
at above column1, column2, column3,...columnN are the names of the columns in the table into which you want to insert the data.

Example :
INSERT INTO Employee (EmpId, EmpName, Salary, Addr, PIN)
    VALUES (101, 'John', 2000, 'Boston', 300987);
Syntax 2 :
INSERT INTO table_name VALUES (value1, value2, value3, ....valueN);
Example :
INSERT INTO Employee VALUES (102, 'Marry', 3000, 'Chicago', 788067);
At here, we are directly inserting values at the columns, because we are adding values for all the columns of the table, so we do not need to specify the columns name in SQL query. But make sure the order of the values is in the same order as the columns in the table.

Next Topic :