SQL INSERT

SQL INSERT:

This statement is used to insert a value in the database.

METHOD 1:

SYNTAX:
INSERT INTO Table_Name Values('&column1','&column2','&column3');

EXAMPLE:
INSERT INTO student VALUES('&regno','&name','&dob');
enter the value for regno: 01
enter the value for name: om
enter the value for dob: 27-may-2000

  1 row created.  

here you are creating the columns and then inserting the values.
you can also insert the values in this format also.

METHOD 2:

SYNTAX:
INSERT INTO Table_Name('column1','column2','column3') VALUES('value1','value2','value3');

EXAMPLE:
INSERT INTO student (regno,name,dob) VALUES('02','prakash','28-may-2000');

METHOD 3:

SYNTAX:
INSERT INTO Table_Name VALUES(value1,value2,value3);

EXAMPLE:

INSERT INTO student VALUES('03','sharma','29-may-2000');

Here you can insert the values directly; columns are already created.

SELECT * FROM student;

The OUTPUT for the above code:

regno

name

dob

01

Om

27-may-2000

02

Prakash

28-may-2000

03

Sharma

29-may-2000