SQL INSERT Statement Column names and values

SQL INSERT statement is used to insert a new row in a table with respective Database.

There is two Method using INSERT INTO statement for inserting rows:

  • Only Values
  • Column names and values both

SQL INSERT statement

Only Values: Syntax

INSERT INTO table_name VALUES (value1, value2, value3,.......);

table_name: name of the table.
value1, value2,.. : value of first column, second column,third column...

Column names and values both: Syntax

INSERT INTO table_name (column1, column2, column3,..) VALUES ( value1, value2, value3,..);
table_name: name of the table.
column1: name of first column, second column ...
value1, value2, value3 : value of first column, second column, third column... for the new records

SQL INSERT Statement

Student Table

RollNo Firstname Lastname Email Phone Subject
101 John Doe john@xy.com 6745896534 Science
102 Mariyam Dolly dolly@xy.com 6745896534 mathematics
103 David Jam jam@xy.com 4567895678 Science
104 Sarita Tripathi sarita@xy.com 6789564523 Science
105 Parihar Arrora parihar@xy.com 9067456786 Mathematics

Add a new record in Student Table

INSERT INTO Student (FirstName, LastName, City, Country, Phone)
VALUES ('Shaym', 'Shukla', 'London', 'USA', 6578964534)
Student
Id
FirstName
LastName
City
Country
Phone

Resource
SQL