SQL -Structured Query Language - SQL Insert - Insert Record Tutorial
To insert single or multiple records in an already-created table. Then we can use an ' INSERT ' Statement.
Syntax-
- To insert record in the table without defining column name.
INSERT INTO table_name VALUES
(‘colname1_value’,’ colname2_value’,…,’ colnameN_value’);
For example-
INSERT INTO user_detail VALUES
(1,'Fresherbell','support@fresherbell.com','2021-02-01');
In Mysql Workbench-
- To insert a record in the table by defining the column name.
INSERT INTO table_name(colname1,colname2,…,colnameN) VALUES
(‘colname1_value’,’ colname2_value’,…,’ colnameN_value’);
For example-
INSERT INTO user_detail(id,name,email,dateofbirth) VALUES
(2,'Fresher bell','support@fresherbell.com','2022-08-02');
In Mysql Workbench-
- To insert multiple records at a time in the table.
INSERT INTO table_name(colname1,colname2,…,colnameN) VALUES
(‘colname1a_value’,’ colname2a_value’,…,’ colnameNa_value’),
(‘colname1b_value’,’ colname2b_value’,…,’ colnameNb_value’),
(‘colname1c_value’,’ colname2c_value’,…,’ colnameNc_value’),
(‘colname1d_value’,’ colname2d_value’,…,’ colnameNd_value’);
For example-
INSERT INTO user_detail(id,name,email,DOB) VALUES
(1,"Fresherbell1","support1@fresherbell.com",2020-18-01),
(2,"Fresherbell2","support2@fresherbell.com",2020-19-01),
(3,"Fresherbell3","support3@fresherbell.com",2020-17-01),
(4,"Fresherbell4","support4@fresherbell.com",2020-16-01);
In Mysql Workbench-