SQL DML STATEMENT
DML :- Data Manipulation Language Data manipulation language is provides commands for updating, inserting, deleting, modifying data and tuples.
DML command are:
a) INSERT
b) UPDATE
c) DELETE
a) INSERT Statements :
SQL INSERT command is used to add a new tuple to a relation.
The relation name and list of values of the tuple must be specified.
The
values should be listed in the same order in which the corresponding
attributes where specified in the CREATE TABLE commands.
Syntax:
INSERT INTO <table_name>
VALUES <V1,V2, .....Vn);
Example:
Consider EMP table having columns empno,ename, salary and we want to insert row in the table.
INSERT INTO EMP
VALUES(101,'AMIT', 10000);
[Note: Character and Date values must be enclosed in the single quotation marks.]
b) UPDATE Statements :
SQL UPDATE STATEMENTS is used to modify attribute values of selected tuples to be modified are specified by a condition in a WHERE clause and the new values of the columns to be update is specified by a SET clause.
Syntax :
UPDATE TABLE <table _name>
SET column_name=new_values
[WHERE condition];
Examples:
i) UPDATE TABLE EMP
SET SALARY = 30000;
Command update all employees salary 30000;
ii) UPDATE TABLE EMP
SET JDATE='2-JAN-84'
WHERE EMPNO=101;
Command update employees jdate whose employees no is 101;
c) DELETE Statements :
DELETE STATEMENT is used to delete tuples row from the table.
Syntax:
DELETE FROM <table_name>
[WHERE <condition>];
Example :
DELETE FROM EMP;
Delete all rows of employees.
DELETE FROM EMP WHERE EMPNO=101;
Delete all rows of employees where empno is 101.
0 comments:
Post a Comment