After creating a database and table, the next important task is adding data to the table. SQL provides the INSERT INTO statement for this purpose. The INSERT INTO command allows users to add new records into database tables. Without data insertion, tables remain empty and cannot be used for meaningful operations such as searching, updating, reporting, or analysis.
The INSERT INTO statement is one of the most frequently used SQL commands because every database application requires data storage. Whether it is a student management system, hospital database, banking application, e-commerce platform, or social media website, data is continuously inserted into tables using this command.
Understanding INSERT INTO is essential for students, developers, database administrators, and data analysts because it forms the foundation of database operations.
INSERT INTO is a Data Manipulation Language (DML) command used to insert new records into an existing table. Each execution of the INSERT statement adds one or more rows to a table.
The command allows users to:
Databases are designed to store information. Without inserting data, database tables have no practical value.
The most common syntax is:
INSERT INTO TableName (Column1, Column2, Column3) VALUES (Value1, Value2, Value3);
Here:
Before inserting data, a table must exist.
CREATE TABLE Student ( StudentID INT, StudentName VARCHAR(100), Course VARCHAR(50), Age INT );
The Student table is now ready to receive records.
The simplest use of INSERT INTO is adding one row at a time.
INSERT INTO Student (StudentID, StudentName, Course, Age) VALUES (101, 'Rahul', 'BCA', 20);
This statement inserts one student record into the table.
| StudentID | StudentName | Course | Age |
|---|---|---|---|
| 101 | Rahul | BCA | 20 |
SQL allows multiple rows to be inserted using a single statement.
INSERT INTO Student (StudentID, StudentName, Course, Age) VALUES (102, 'Priya', 'B.Tech', 21), (103, 'Amit', 'MCA', 22), (104, 'Neha', 'B.Sc', 19);
This command inserts three records simultaneously.
After inserting records, the SELECT statement can be used to verify the stored data.
SELECT * FROM Student;
Output:
| StudentID | StudentName | Course | Age |
|---|---|---|---|
| 101 | Rahul | BCA | 20 |
| 102 | Priya | B.Tech | 21 |
| 103 | Amit | MCA | 22 |
| 104 | Neha | B.Sc | 19 |
If values are supplied in the exact order of the table columns, column names may be omitted.
INSERT INTO Student VALUES (105, 'Karan', 'BCA', 20);
Although valid, this approach is generally not recommended because future table changes may cause errors.
It is not mandatory to provide values for every column.
INSERT INTO Student (StudentID, StudentName) VALUES (106, 'Riya');
Only StudentID and StudentName receive values.
Other columns receive NULL values if allowed.
NULL represents missing or unknown information.
Example:
INSERT INTO Student (StudentID, StudentName, Course) VALUES (107, 'Ankit', NULL);
The Course value is currently unavailable and therefore stored as NULL.
Numeric values are inserted without quotation marks.
INSERT INTO Product (ProductID, Price) VALUES (1, 4999);
Numbers can be integers, decimals, or floating-point values depending on the column data type.
Text values must be enclosed within single quotes.
INSERT INTO Student
(StudentName)
VALUES
('Rohit');
SQL treats text enclosed within quotes as string data.
Date values must follow the format supported by the database system.
INSERT INTO Student (StudentID, StudentName, AdmissionDate) VALUES (108, 'Pooja', '2026-07-21');
The date is stored in the AdmissionDate column.
Boolean columns store TRUE or FALSE values.
INSERT INTO Users (UserID, IsActive) VALUES (1, TRUE);
Some database systems internally store TRUE as 1 and FALSE as 0.
Columns can be configured with default values.
CREATE TABLE Employee ( EmployeeID INT, EmployeeName VARCHAR(100), Country VARCHAR(50) DEFAULT 'India' );
Insert statement:
INSERT INTO Employee (EmployeeID, EmployeeName) VALUES (1, 'Aman');
Country automatically receives the value 'India'.
A college admission system stores student information whenever a new student registers.
INSERT INTO Student (StudentID, StudentName, Course, Age) VALUES (201, 'Rahul Sharma', 'B.Tech', 19);
The database immediately records the student's details.
When a patient visits a hospital, patient information is inserted into the database.
INSERT INTO Patient (PatientID, PatientName, Disease) VALUES (501, 'Anjali', 'Fever');
The patient record becomes available for future treatment and reporting.
Every time a customer places an order, order information is inserted into the Orders table.
INSERT INTO Orders (OrderID, CustomerName, Amount) VALUES (1001, 'Vikas', 2500);
The order is stored permanently for processing and tracking.
INSERT INTO Student
(StudentID, StudentName)
VALUES
('ABC', 123);
This statement may fail because StudentID expects a numeric value while StudentName expects text.
Sometimes data already exists in one table and needs to be copied into another table. Instead of manually inserting records one by one, SQL provides the INSERT INTO SELECT statement.
This command copies data from one table and inserts it into another table.
INSERT INTO NewTable (Column1, Column2) SELECT Column1, Column2 FROM OldTable;
INSERT INTO StudentBackup (StudentID, StudentName) SELECT StudentID, StudentName FROM Student;
This query copies student records from the Student table to the StudentBackup table.
Specific records can also be copied using conditions.
INSERT INTO TopStudents (StudentID, StudentName) SELECT StudentID, StudentName FROM Student WHERE Marks > 80;
Only students scoring more than 80 marks are copied into the TopStudents table.
Database administrators frequently create backup tables before performing major updates.
CREATE TABLE EmployeeBackup AS SELECT * FROM Employee WHERE 1=0;
After creating the structure:
INSERT INTO EmployeeBackup SELECT * FROM Employee;
The backup table now contains all employee records.
Many tables contain an AUTO_INCREMENT or IDENTITY column. These columns automatically generate unique values.
CREATE TABLE Student ( StudentID INT AUTO_INCREMENT PRIMARY KEY, StudentName VARCHAR(100) );
Insert statement:
INSERT INTO Student
(StudentName)
VALUES
('Rahul');
The database automatically assigns StudentID.
| StudentID | StudentName |
|---|---|
| 1 | Rahul |
Large organizations often insert thousands or millions of records daily. Efficient insertion techniques become extremely important.
INSERT INTO Sales (ProductID, Quantity) VALUES (101,10), (102,5), (103,12), (104,20), (105,8);
Using a single INSERT statement for multiple rows is generally faster than executing many separate INSERT commands.
Bulk insertion techniques are commonly used when importing data from CSV files, spreadsheets, or external applications.
Benefits include:
SQL allows insertion of values generated through calculations.
INSERT INTO EmployeeSalary (EmployeeID, TotalSalary) VALUES (101, 25000 + 5000);
The calculated result is stored in the database.
Built-in SQL functions can also be used while inserting data.
INSERT INTO Orders (OrderID, OrderDate) VALUES (1001, CURRENT_DATE);
The current system date is automatically inserted.
INSERT INTO LoginHistory (UserID, LoginTime) VALUES (101, CURRENT_TIMESTAMP);
The current date and time are stored automatically.
NULL represents missing or unknown information.
INSERT INTO Employee (EmployeeID, EmployeeName, Phone) VALUES (1, 'Amit', NULL);
The phone number is currently unavailable and therefore stored as NULL.
Constraints validate data before insertion.
CREATE TABLE Student ( StudentID INT PRIMARY KEY, StudentName VARCHAR(100) );
Duplicate StudentID values cannot be inserted.
INSERT INTO Student VALUES (1,'Rahul'); INSERT INTO Student VALUES (1,'Amit');
The second statement generates an error because the primary key already exists.
CREATE TABLE Users ( UserID INT, Email VARCHAR(100) UNIQUE );
Duplicate email addresses cannot be inserted.
CREATE TABLE Employee ( EmployeeID INT, EmployeeName VARCHAR(100) NOT NULL );
The EmployeeName column must always contain a value.
CREATE TABLE Student ( StudentID INT, Age INT CHECK (Age >= 18) );
The database rejects values that violate the condition.
INSERT INTO Student VALUES (1,'Rahul');
If ID 1 already exists, insertion fails.
INSERT INTO Student
VALUES ('ABC','Rahul');
Numeric columns cannot store invalid text values.
INSERT INTO Employee (EmployeeID) VALUES (1);
If EmployeeName is NOT NULL, the insertion fails.
Whenever a student takes admission, the system stores information in the Student table.
INSERT INTO Student (StudentID, StudentName, Course) VALUES (501,'Rahul Sharma','B.Tech');
The student becomes part of the institutional database.
When a customer opens a new account, the banking application inserts customer information.
INSERT INTO Customer (CustomerID, CustomerName) VALUES (1001,'Anjali Verma');
The customer account is immediately available for banking operations.
New patient records are inserted during registration.
INSERT INTO Patient (PatientID, PatientName) VALUES (3001,'Vikas Kumar');
Doctors and staff can now access the patient's information.
When customers place orders, order details are inserted into the Orders table.
INSERT INTO Orders (OrderID, Amount) VALUES (9001, 2500);
The order becomes available for shipping and tracking.
INSERT INTO is used to add new records into a database table.
INSERT belongs to Data Manipulation Language (DML).
Yes, multiple rows can be inserted using a single statement.
No, but it is highly recommended.
Values must be supplied in the exact order of table columns.
Yes, if the column allows NULL values.
It copies data from one table and inserts it into another table.
Yes, functions such as CURRENT_DATE and CURRENT_TIMESTAMP can be used.
The insertion operation fails.
The database automatically generates unique numeric values.
No, UPDATE is used to modify existing rows.
SELECT * FROM TableName;
Bulk insert is the process of inserting large amounts of data efficiently.
Yes, constraints validate data before insertion.
INSERT creates new records, while UPDATE modifies existing records.
CREATE TABLE Student ( StudentID INT PRIMARY KEY, StudentName VARCHAR(100), Course VARCHAR(50), Age INT ); INSERT INTO Student (StudentID, StudentName, Course, Age) VALUES (101,'Rahul','BCA',20), (102,'Priya','B.Tech',21), (103,'Amit','MCA',22); SELECT * FROM Student;
The above example creates a table, inserts records, and displays stored data.
The INSERT INTO statement is one of the most important SQL commands because it enables data storage within database tables. It supports single-row insertion, multi-row insertion, NULL values, default values, auto-increment columns, functions, and data transfer between tables using INSERT INTO SELECT.
Mastering INSERT INTO helps developers build efficient database applications, maintain data integrity, and handle real-world business operations effectively. A strong understanding of insertion techniques is essential for SQL interviews, academic studies, and professional database development.