0% found this document useful (0 votes)
117 views4 pages

SQL INSERT INTO Statement

The SQL INSERT INTO statement is used to insert new records into a database table. There are two basic syntaxes: (1) specifying only values to insert values sequentially into columns, and (2) specifying both column names and values to insert specific data into particular columns. The document provides examples of inserting records into a Student table using both syntaxes of the INSERT INTO statement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views4 pages

SQL INSERT INTO Statement

The SQL INSERT INTO statement is used to insert new records into a database table. There are two basic syntaxes: (1) specifying only values to insert values sequentially into columns, and (2) specifying both column names and values to insert specific data into particular columns. The document provides examples of inserting records into a Student table using both syntaxes of the INSERT INTO statement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL INSERT INTO Statement

SQL INSERT INTO statement is used to add new records in a table.

Syntax 1
You can sequentially insert values into columns according to table structure without
mentioning column names.

INSERT INTO TableName
VALUES (value1, value2, …, valueN)

Syntax 2
You can mention specific columns and their values to insert in table.

INSERT INTO TableName (column1, column2, …, columnN)
VALUES (value1, value2, …, valueN)
You can use specific syntax according to your business requirements. We will see couple
of examples how to use INSERT INTO statements.
We will use Student table to insert records. You can refer Student table as given below.
SQL query to insert record in Student table is:

INSERT INTO Student


VALUES (9999, 'Mr.', 'Brian', 'T', 'Lee', 'China')
As mentioned above record number 16 is inserted in Student table.

We will take one more example where we will try to insert specific column values for
RollNumber, FirstName and LastName.

INSERT INTO Student (RollNumber, FirstName, LastName)


VALUES (8888, 'Chin', 'Xing')
Here we have inserted record number 17, make sure while inserting specific columns,
remaining columns are allowing NULL values or constraint is not referencing other table(s).

You might also like