Learn how to use SQL INSERT INTO statement with the tutorial and explained examples given here. Find out how to insert data using SQL INSERT INTO statement.

You have to specify column names for and the respected values which you want to insert. Specify the column names and its values in the exact sequence as it is in the column is in the table. If you specify the wrong sequence, your data may insert incorrectly or will not insert into the database.

If you want to insert multiple values in one go, you have to specify the value in brackets and comma separated as given in the example below.

How to Use SQL INSERT INTO Statement to insert data

There are two syntaxes you can use to insert the values in the table of the database. You can insert values for the specified columns or you can insert values for all the columns. Follow the syntax given below to get the exact rule and insert the values.

Syntax1: Insert Values to the Specified Columns Only

The above syntax inserts only the specified column values. If you want to insert a value for 4 columns, you have to specify the 4 values for those columns. Specify the exact sequence of values in which you have entered the columns in sequence.
Syntax2: Insert Values for All the Columns

If you want to insert values for all the columns, you don’t need to specify the column names. In that case, specify the values only and don’t forget to specify them in the exact sequence as it is in the tables.

Parameter Descriptions

Sr.No Parameter Name Description
1 column1, column2, column3,…columnN Enter the column names you want to insert the values into the table.
2 tablename Specify the table name to which you want to insert the data or rows.
3 value1, value2, value3,…valueN You have to specify the values in the sequence as it is in the table.

You must also learn.

Reference

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.