SQL INSERT Statement

How to store data in a Table?

Answer is very simple, Use INSERT  query. There are two ways to insert data in table.


Form1 :
INSERT INTO "tableName"
values (value1, value2, ....  ,valueN);


Form2 :
INSERT INTO "tableName" (column1, column2, ...., columnN)
values (value1, value2, ....  ,valueN);

Parameters :

tableName : Name of the table in which we are going to insert data.

column1, column2, columnN : Columns name of the table which will have specified data in it.

value1, value2, valueN : Values which are going to stored in table for e.g. column1 will have value1, column2 will have value2 and so on columnN will have value valueN.

INSERT INTO with columns name  is below :

INSERT INTO `tutorialsmines`.`employee` (`id`, `name`, `salary`, `age`) VALUES (‘3’, ‘Jyoti’, ‘55000’, ’32’);


Using Select to see all the records.



INSERT INTO `tutorialsmines`.`employee` VALUES (‘5’, ‘Leena’, ‘52000’, ’35’);


Using Select to see all the records.


INSERT INTO for adding multiple rows at a same time  is below :

INSERT INTO `tutorialsmines`.`employee` (`id`, `name`, `salary`, `age`) VALUES ('1', 'Arnav', '50000', '27'), ('2', 'Urmila', '45000', '29');

Note : You should provide values for all the NON NULL defined columns.
Please remember about the datatypes of your column to avoid errors while inserting data in table.
Do not forgot about integrity constraints applies on your coulmns definition.

You may also like...

Leave a Reply

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