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.
Syntax:
Form1 :
INSERT INTO "tableName"
values (value1, value2, .... ,valueN);
OR
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.
DIRECT INSERT INTO is below :
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');