Data Manipulation Language - INSERT Statement

This statement is used for inserting the values into a specific table.
Syntax to INSERT Statement:

INSERT INTO TABLENAME [(column list)] VALUES (VALUE1,VALUE2….)

Note: While inserting the values into a specific table we should know that table definition (number of columns).

In the above syntax "column list" optional part specifies that "List of columns for which user supplying the values".

Example1:

INSERT INTO EMP VALUES (11,'RAM', 15000, 10);

Example2:

INSERT INTO EMP VALUES (22,'RAJ', 15000, 10);

Example3:

INSERT INTO EMP VALUES (33,'ANIL', 15000, 10);

Example4:

INSERT INTO EMP VALUES (44,'ABIRAM', 15000, 10);

Example5:

INSERT INTO EMP VALUES (EMPNO,'ENAME', DEPTNO) VALUES (66,'DP', 10);

Example6:

INSERT INTO EMP VALUES (EMPNO, ENAME, SAL) VALUES (77,'INDU', 12000);

In the above example 5 users was enables to supply the value for SAL column, then user have to mention the columns list for which he can supply the values.

In the above example 6 user was unable to supply the value for DEPTNO column, then user have to mention the columns list for which he can supply the values.

Note:

Whenever user unable to supply the values for any column then server will arrange an unpredictable or garbage value called NULL value. NULL is different from Zero and empty. We cannot compare null with any other values.

In the above example5 and example6 case SAL and DEPTNO column values is NULL.
Share/Bookmark

No comments: