06.using DMLs
06.using DMLs
Chapter Content :
- Insert Statement
- Update Statement
- Delete Statement
Chapter 07 : Data Manipulation Language (DMLs)
Insert Statement
syntax:
.......
Examples:
.........
Insert Statement
With Complete Row its optional to write
column list
Insert Statement
With In-Complete Rows we have to write
column list
Example
Insert Statement
Special Values
Example
Update Statement
syntax :
........
update table_name
set column = value [ , column = value ] [ , column = value ]
[where condition ] ;
Chapter 07 : Data Manipulation Language (DMLs)
Update Statement
Examples :
----------
update emp set sal = 1000 ;
Without Where
All rows will be updated
Update Statement
Example:
update emp set sal = 2000 where deptno = 20 ;
Update Statement
Example
update emp set sal = 3300 where empno = 7788 ;
Chapter 07 : Data Manipulation Language (DMLs)
Update Statement
Example
update emp set sal = 4000 , job='ANALYST' where empno = 7900 ;
Chapter 07 : Data Manipulation Language (DMLs)
Update Statement
Example
update emp
set sal = ( select sal from emp where empno=7788)
where empno = 7782 ;
Delete Statement
syntax :
........
delete from table_name
[where condition ];
Examples
-------
delete from emp ; == delete emp ;
delete from emp where deptno = 10 ;
delete from emp where empno = 7788 ;
delete from emp where deptno = ( select deptno from emp
where ename='SCOTT' );
Chapter 07 : Data Manipulation Language (DMLs)
Delete Statement
Example
delete from emp ; == delete emp ;
Delete Statement
delete from emp where deptno = 10 ;
Chapter 07 : Data Manipulation Language (DMLs)
Delete Statement
delete from emp where empno = 7788 ;
Chapter 06 : Data Manipulation Language (DMLs)
Delete Statement
delete from emp where deptno = ( select deptno from emp where ename='SCOTT' );
Chapter 07 : Data Manipulation Language (DMLs)
Practices
1. Insert into dept table new department :with these Values deptno = 60 , dname = Inventory , dept Location = Alexandria
2. Insert into employee table new row with employee number = 1112 and employee name =‘New Emp’ , hiredate = today
3. Update emp table such that all employees in dept = 10 will have salary = 1000
4. Update emp table set the salary of employee no 7788 = the salary of employee no = 7782
5. Update emp set the min salaray in deptno 10 to be = min salary in deptno no 20
6. Update emp table set the salary of employee no = 7788 to be = 3000 and his job =‘Clerk’ and deptno=10 in one update ST.
7. Delete from emp table all employees work as analyst
8. Delete from emp all employees in the same department as employee scott
9. Delete from emp the employee who has minimum salary
10. Update emp set the job for the employee with maximum salary to be Salesman