• Articles
  • Tutorials
  • Interview Questions

INSERT Query in SQL - Master the Basics

Tutorial Playlist

SQL INSERT INTO Query

The INSERT statement is used to insert records in a table. The table selected to insert data must have the same number of columns and values. In this tutorial section, we will discuss on the Insert statement syntax with an example.

Watch this Insert query in SQL video

Video Thumbnail

A Brief on the INSERT Query in SQL

Once the table is created, the next step is to insert values into it according to its constraints. The insert statement consists of two ways.

  • Only values:

    Value of the data to be inserted is specified with the column names.

  • Column names and values:

    Column name is mentioned, and then the values are inserted.

We are using the only values method in this tutorial section. In only values, the values entered must be in an order according to the column.

Become a Database Architect

Syntax

INSERT INTO tablename VALUES (value1, value2,….valueN);

where INSERT INTO and VALUES are the keywords and tablename is the name of the table; value1 to valueN are the set of values, followed by a semicolon.
Values are given for each of the columns, respectively. Whenever a variable length character appears, then the values are entered in a single quote. And when an integer appears, it is written just like that.

  • As our employee table is created, let’s insert values into it
    Insert into employee values(1,’sam’,30000,26,’male,’operation’);

A Brief on the Insert Statement

  • After writing the query, click on the execute button to check for errors
  • Once the query is executed, a message appears like ‘Commands completed successfully’
  • Repeat the procedure and create 5 more sets of entries. Once you enter the records, the employee table will be displayed as follows:
e_id e_name e_salary e_age e_gender e_dept
1 sam 30000 26 male operation
2 julia 940000 27 female operation
3 anne 125000 21 female analytics
4 bob 50000 24 male support
5 jeff 20000 43 male sales
6 matt 940000 29 male operation

Finally, our table is ready with the values. We have inserted six records and, this is the way Insert query in SQL works. In the next tutorial section, we will learn how to select individual records from a table.

Course Schedule

Name Date Details
SQL Training 04 Jan 2025(Sat-Sun) Weekend Batch View Details
11 Jan 2025(Sat-Sun) Weekend Batch
18 Jan 2025(Sat-Sun) Weekend Batch

About the Author

Data Engineer

As a skilled Data Engineer, Sahil excels in SQL, NoSQL databases, Business Intelligence, and database management. He has contributed immensely to projects at companies like Bajaj and Tata. With a strong expertise in data engineering, he has architected numerous solutions for data pipelines, analytics, and software integration, driving insights and innovation.