Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
SQL INSERT STATEMENT

SQL INSERT STATEMENT

Posted on February 13, 2025February 13, 2025 By Rishabh saini No Comments on SQL INSERT STATEMENT

SQL INSERT STATEMENT

The SQL INSERT statement is a powerful command in SQL that allows users to add data into a table. This statement enables inserting either a single record or multiple records simultaneously.

Ways to Insert Data into a Table:

  1. Using SQL INSERT INTO statement
    • By specifying column names
    • Without specifying column names
  2. Using SQL INSERT INTO SELECT statement

Complete Python Course with Advance topics:-Click Here
SQL Tutorial :-Click Here

1) Inserting Data Directly into a Table

The INSERT INTO statement is used to insert records into a table. There are two methods to insert values:

Method 1: Without Specifying Column Names

In this method, column names do not need to be specified; only their values are required.

INSERT INTO table_name  
VALUES (value1, value2, value3....);  

Method 2: With Specified Column Names

In this method, both the column names and the corresponding values must be mentioned.

INSERT INTO table_name (column1, column2, column3....)  
VALUES (value1, value2, value3.....);  

Example:

Let’s consider a table STUDENTS and insert five records into it.

INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)    
VALUES (1, 'RAHUL', 23, 'MUMBAI');    
INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)    
VALUES (2, 'PRIYA', 21, 'BANGALORE');    
INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)    
VALUES (3, 'KARAN', 22, 'HYDERABAD');    
INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)    
VALUES (4, 'SIMRAN', 20, 'PUNE');    
INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)    
VALUES (5, 'ARJUN', 24, 'CHENNAI');    

Final Table Output:

ROLL_NONAMEAGECITY
1RAHUL23MUMBAI
2PRIYA21BANGALORE
3KARAN22HYDERABAD
4SIMRAN20PUNE
5ARJUN24CHENNAI

Another way to add records to a table CUSTOMERS:

INSERT INTO CUSTOMERS     
VALUES (6, 'ANITA', 25, 'KOCHI');    

Updated Table Output:

ROLL_NONAMEAGECITY
1RAHUL23MUMBAI
2PRIYA21BANGALORE
3KARAN22HYDERABAD
4SIMRAN20PUNE
5ARJUN24CHENNAI
6ANITA25KOCHI

2) Inserting Data Through SELECT Statement

The INSERT INTO SELECT statement is used to copy data from one table to another.

SQL Syntax:

INSERT INTO table_name  
[(column1, column2, .... column)]  
SELECT column1, column2, .... Column N  
FROM another_table [WHERE condition];  

Important Notes:

  • Ensure the data types of the columns match the values being inserted.
  • Follow any integrity constraints (e.g., unique, not null) defined for the table.

Example:

Suppose we have an OLD_STUDENTS table with existing student records, and we want to copy some of them into NEW_STUDENTS.

INSERT INTO NEW_STUDENTS (ROLL_NO, NAME, AGE, CITY)  
SELECT ROLL_NO, NAME, AGE, CITY  
FROM OLD_STUDENTS  
WHERE AGE > 22;  

This query will insert only students older than 22 from OLD_STUDENTS into NEW_STUDENTS.

Download New Real Time Projects :-Click here
Complete Advance AI topics:- CLICK HERE

Conclusion

The SQL INSERT statement is an essential tool for adding records to a table efficiently. Whether inserting single or multiple records, using INSERT INTO with or without column names, or copying data with INSERT INTO SELECT, mastering these techniques helps in handling database operations effectively.

For more SQL tutorials, visit UpdateGadh.


sql insert statement with multiple values
sql insert statement postgresql
sql insert statement examples
sql insert statement from select
sql insert statement generator
sql insert statement from excel
sql insert statement with datetime
sql insert statement with auto increment field
sql insert statement multiple rows
sql insert statement example
insert into table sql multiple rows
insert into table sql from another table

Post Views: 478
SQL Tutorial Tags:beginner sql lesson, beginner sql video, database, databases, education, git, github, how to insert in sql, insert, insert into, it, learn sql, Programming, queries, query, relational database, socratica, socraticacs, sql, sql beginners, sql insert, sql insert command, sql insert query, sql insert statement, sql lesson, sql tutorial, sql tutorial video, sql video, structured query language, Tutorial, w3schools, what is insert in sql

Post navigation

Previous Post: Insertion Sort in Python
Next Post: Internship: Internship Management System in PHP with MySQL

More Related Articles

SQL OR Condition in SQL Queries SQL OR Condition in SQL Queries SQL Tutorial
HAVING Clause in SQL HAVING Clause in SQL SQL Tutorial
SQL DELETE Statement Understanding the SQL DELETE Statement and Its Variants SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Understanding the SQL DELETE Statement and Its Variants
  2. SQL SELECT TOP Clause: A Comprehensive Guide
  3. SQL ORDER BY LIMIT – Retrieve Specific Rows from a Database
  4. SQL UPDATE with JOIN
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,612)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,210)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,862)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme