A database contains of many tables which has data stored in an order. To add up the rows, the user needs to use insert statement.
insert into table_name(column_list) values(values_list)
For better understanding, an example is given below.
A table named student must have values inserted into it. It has to be done as follows:
insert into student (varchar2 name(20), int rollnumber, varchar2 course(50)); values('Riya', 111, 'Computer Science');
1 row(s) inserted
To check whether the value is actually inserted, the query must be given as follows:
select * from student;
insert multiple rows :
A table can store upto 1000 rows in one insert statement. If a user want to insert multiple rows at a time, the following syntax has to written.
insert into table_name(column_list) values(value_list1) values(values_list2) . . . . values(values_listn)
If a user wants to insert more than 1000 rows, multiple insert statements, bulk insert or derived table must be used.
Consider a table student. If a user has to enter the data of 6 students at a time, the query must be given as follows-
insert into student(int rollnumber, varchar2(30) name, varchar2(20) course); values(111, 'Riya', 'CSE'); values(112, 'Apoorva', 'ECE'); values(113, 'Mina', 'Mech'); values(114, 'Rita', 'Biotechnology); values(115, 'Veena', 'Chemical'); values(116, 'Deepa', 'EEE');
6 row(s) inserted
To check whether the values are present in the table, the query must be given as follows:
select * from student;
The insert multiple rows statement was only available in the year 2008 and later on.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Insert Into Select statement in MS SQL Server
- SQL | INSERT INTO Statement
- SQL | INSERT IGNORE Statement
- Delete statement in MS SQL Server
- Reverse Statement Word by Word in SQL server
- Select statement in MS SQL Server
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | Case Statement
- SQL | DESCRIBE Statement
- SQL | MERGE Statement
- MERGE Statement in SQL Explained
- SELECT INTO statement in SQL
- CREATE and DROP INDEX Statement in SQL
- Performing Database Operations in Java | SQL CREATE, INSERT, UPDATE, DELETE and SELECT
- SQL Server Mathematical functions (SQRT, PI, SQUARE, ROUND, CEILING & FLOOR)
- SQL Server Identity
- SQL SERVER | Conditional Statements
- SQL Server | STUFF() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : khushboogoyal499