Sei sulla pagina 1di 12

Name: Deepak Maurya

Class: SE-IT Batch: A Roll No: 22

Experiment No.5:
Perform DML Operations and also construct database keys

Q.1. Create and insert a single record into department table.

Ans:

Query:

create table dept22

deptno number(2) primary key,

dname varchar2(10),

loc varchar2(20)

);

Output:

Query:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

insert into dept22

values(1,'it','mumbai');

Output:

Query:

insert into dept22

values(2,'com','pune')

Output:

Query:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

select *

from dept22;

Output;

Q.2. Insert the following records in EMP table

Emp no ename Job Deptno Sal


11 Mahesh Ap 1 10000
12 Arjun Asp 2 12000
13 Gagan Asp 1 12000
14 Kartik Prof 2 30000
15 Akash Ap 1 10000
16 suresh Lect 1 8000

Ans:

Query:

create table emp22

empno number(2) primary key,

enam varchar2(10),

job varchar2(10),
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

deptno number(2) references dept22,

sal number(2)

);

Output:

Query;

insert into emp22

values(11,'mahesh','ap',1,10000);

insert into emp22

values(12,'arjun','aps',2,12000);

insert into emp22

values(13,'ganesh','aps',1,12000);

insert into emp22

values(14,'kartik','pro',2,30000);
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

insert into emp22

values(15,'aakash','ap',1,10000);

insert into emp22

values(16,'suresh','lect',1,8000);

select *

from emp22

Output:

Q.3. Update the EMP table to set the salary of all employees to 15,000 who are working as ASP

Ans:

Query:

update emp22

set Sal=15000

where Job='ASP';

Output:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

Q.4. Create a pseudo table Employee with the same structure as the table EMP and insert rows
into the table using select clause

Ans:

Query: create table Employee22 as

select * from emp22;

Output:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

Query: select *

from Employee22;

Output:

Q.5. Select Ename, job from the EMP table

Ans:

Query: select Enam,Job

from emp22;

Output:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

Q.6. Delete only those records who are working as lecturer

Ans:

Query:

delete

from emp22

where job='lect'

Output:

Query:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

select *

from emp22

output:

Q.7. List the records in the EMP table order by salary in ascending order

Ans:

Query:

select *

from emp22

order by sal;

Output:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

Q.8. List the records in the EMP table order by salary in descending order

Ans:

Query:

select *

from emp22

order by sal desc;

Output:

Q.9. Display only those employees whose Deptno is 1


Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

Ans:

select *

from emp22

where deptno=1;

Output:

Q.10. Display Deptno from the table EMP avoiding the duplicated values

Ans:

Query:

select distinct deptno

from emp22

Output:
Name: Deepak Maurya
Class: SE-IT Batch: A Roll No: 22

Potrebbero piacerti anche