bing
Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up
×
UPTO
50%
OFF!
Intellipaat
Intellipaat

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

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.

  • 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.

Previous Next

Download Interview Questions asked by top MNCs in 2019?

"0 Responses on Insert query in SQL - INSERT INTO SQL"

    100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.
    top

    Sales Offer

    Sign Up or Login to view the Free Insert query in SQL - INSERT INTO SQL.