INSERT Statement In Database

Insert Statement In Database: The INSERT INTO statement is used to insert or add new row or record into the database. The new record is appended or added at the end of the database table.

The general syntax of the INSERT INTO statement to insert one row at a time into database table is written as:

INSERT INTO table-name [(field list)] VALUES (value list)

For example, to insert a row with values (16, ‘Fozia’, ‘Karachi’, 650) into the STUDENT table the INSERT statement will be

INSERT INTO Student (Roll_No, Name, City, Marks) VALUES (16, ‘Fozia’, ‘Karachi’, 650)

You can also insert multiple rows extracting from one table to another table. In this case, both the values should have the same data structures. For example, to copy all those rows of ‘STUDENT_1’ table that have value greater than 700 in the ‘Marks’ column into the ‘STUDENT_2’ table , the statement is written as

INSERT INTO VALUES (select * FROM student_1 WHERE Marks > 700)