Insert data in a table in SQL

Following is the syntax for insert statements in SQL :

INSERT INTO TableName
(Column1,Column2……)
VALUES
(Value1,Value2…..)

For Example we want to insert data in a table named People with the following columns :

Following will be the insert query for inserting a record inside the table :

Insert into People(PersonID,LastName,FirstName,Address,City) Values (1,’TestLastName’,’TestFirstName’,’TestAddress’,’TestCity’)

This insert statement will insert a record in the table People with the provided values :

For inserting values in multiple rows at once, the following syntax can be used:

INSERT INTO TableName
(Column1,Column2……)
VALUES
(Value1,Value2…..),(Value1,Value2…..)

Example for the same table People we will have the following insert query if we want to insert data in more than one row:

Insert into People(PersonID,LastName,FirstName,Address,City) Values
(2,’TestLastName1′,’TestFirstName1′,’TestAddress1′,’TestCity1′),(3,’TestLastName2′,’TestFirstName2′,’TestAddress2′,’TestCity2′)

Leave a Comment

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