Home » SQL

SQL - INSERT INTO Statement (to insert/add record into table)

SQL - INSERT INTO statement: In this article, we are going to learn everything about ‘INSERT INTO’ statement in SQL with syntax and examples.
Submitted by Shubham Singh Rajawat, on November 13, 2017

INSERT INTO statement is used to add/insert a new row into the table. There are two ways of using INSERT INTO.

1) To insert data in the specified columns of the new row/to insert a new record in the table

Syntax:

INSERT INTO table_name(column1, column2, ...) VALUES(value1, value2, ...);

Here,

  • table_name : name of the table into which we want to insert data.
  • column1, column2, ... : names of the columns/fields.
  • value1, value2, ... : values of the column/fields specified.

2) To insert data in all the columns/fields in the table

Syntax:

INSERT INTO table _name VALUES( value1, value2, ...);

Here,

  • table_name : name of the table into which we want to insert data.
  • value1, value2, ... : values of all the column/fields in the table.
SQL - insert into example

Example:

1) Insert a new record

INSERT INTO Student VALUES(5, 'Shubham','1998-12-16',88,87,78, 'Gwalior');

It will insert a new record in the table with Enroll_No:5, Student_name: Shubham, DOB: 1998-12-16 ...

SQL - Insert into example 1

2) Insert values in some specified columns

INSERT INTO Student ( Enroll_No, Student_name, city) VALUES (5, 'Shubham', 'Bhopal');

It will insert a new record in the table with Enroll_No:5, Student_name: Shubham, DOB: 1998-12-16 ...

SQL - Insert into example 1


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.