How to Insert Data?

his command is used to insert a tuple in a relation. We must specify the name of the relation in which tuple is to be inserted and the values. The values must be in the same order as specified during the Create Table command.

Insert all column & single row
Syntax
INSERT INTO table_name VALUES(data1,data2,...);
Example
mysql> INSERT INTO employee values (1023,'Kalid',null);
Query OK, 1 row affected (0.05 sec)
insert all column & multiple row
Syntax
INSERT INTO table_name VALUES(data1,...), (data2,...), ... ;
Example
mysql> INSERT INTO college values
-> (1024,'Kajal',null),
-> (1025,'Komal',null),
-> (1026,'Rohit','M');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql>
Insert specified column & single row
Syntax
INSERT INTO table_name(field1,field2,...) VALUES(data1,data2,...);
Example
mysql> INSERT INTO employee(fname,id,gender) values
-> ('Nisha',1027,'F');
Query OK, 1 row affected (0.01 sec)

mysql>
insert specified column & multiple row
Syntax
INSERT INTO table_name(field1,field2,...) VALUES(data1,...), (data2,...), ... ;
Example
mysql> INSERT INTO college values(fname,id,gender)
-> ('Mala',1028,null),
-> ('Pooja',1029,'F');
-> ('Rohan',1030,'M');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql>

Note that the values entered are ordered with respect to the attributes mentioned. If an attribute value is not explicitly specified its DEFAULT value is used. If DEFAULT value is also not specified then NULL value is used.