Inserting rows into a table is not complex task. Below, you’ll find sample queries that help you use in your project readily.

SQL Inserting Multiple Rows
Photo by Anete Lusina on Pexels.com

Here is an SQL query to insert a single row at a time

INSERT INTO MY_TABLE 
VALUES('RAMA', 20000, 'HYDERABAD', 1001);

Here’s a process of inserting values into a table with multiple columns in a single line is called a single-row insert. The example given is a table named my_table with four columns: Name, Salary, City, and EmpCode.

And you can insert a NULL value into a table. The optional thing is you can avoid the column names if the values are in the same order as Table columns.

INSERT INTO MY_TABLE 
(Name, Salary, City, EmpCode)
VALUES('RAMA', 20000, 'HYDERABAD', 1001);

Here is an SQL query to insert multiple rows at a time

Example-1

Inserting multiple rows saves you time, and you can avoid using the VALUES keyword multiple times when writing. After each value line, you need to use the comma ,. The semi-colon should be used only once (at the end of the SQL query).

INSERT INTO MY_TABLE 
(Name, Salary, City, EmpCode)
VALUES('RAMA', 20000, 'HYDERABAD', 1001),
        ('RAVI', 30000, 'DELHI', 1002),
           ('RANI', 40000, 'LUKNOW', 1003);

Example-2

Checkout inserting rows using Select and Insert Into here.

References