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.

We have the perfect professional SQL Training Course for you!

Watch this Insert query in SQL video

Insert query in SQL – INSERT INTO SQL 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. We have the perfect professional

A Brief on the Insert Command 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.

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.

Wish to get certified in SQL! Learn SQL from top SQL experts and excel in your career with intellipaat’s SQL certification.

  • 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_ide_namee_salarye_agee_gendere_dept
1sam3000026maleoperation
2julia94000027femaleoperation
3anne12500021femaleanalytics
4bob5000024malesupport
5jeff2000043malesales
6matt94000029maleoperation

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.

Come to Intellipaat’s SQL Community if you have more queries on SQL!

Leave a Reply

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