Elias BAIS Database Manual2
Elias BAIS Database Manual2
SAWLA CAMPUS
2023 G.C
Lab Manual
Prepared by : Mr.Elias P
Course code
B.Sc. (BAIS)
PRACTICAL PAPER - I
Course Code : ……
Manager_Id, Department_Id)
( a) Find out the employee id, names, salaries of all the employees
( c) Find the names of the employees who have a salary greater than or equal to 4800
( e) Find the names of the employees who works in departments 60,70 and 80
Employees table:
(Emp_id,First_name,Last_name,Phone_No,Hire_date,Job_id,Emp_Salary,Comission_Pct,manager
_id,Department_id)
Query:
Query:
1 row created.
1 row created.
1 row created.
2006',304,36520,604,100,90);
1 row created.
1 row created.
Find out the employee id, names, salaries of all the employees Query:
Query:
Find the names of the employees who have a salary greater than or equal to 4800 Query:
Find the names of the employees who works in departments 60,70 and 80 Query: sql>select * from
employees where DEPARTMENT_ID IN(60,70,80);
Query:
(Exercise on updating records in table)Create Client_master with the following fields(ClientNO, Name,
Address, City, State, bal_due)
(Client_no,Client_Name,Client_Address,Client_City,Client_State,Balance_Due)
'Telangana',6000);
sql>insert INTO CLIENT_MASTER Values('C125','Vignesh','Saroor nagar', 'Hyderabad',
'Telangana',3500);
'Telangana',4500);
Create Teacher table with the following fields(Name, DeptNo, Date of joining, DeptName, Location,
Salary)
Create Teacher table with the following fields(Id,Name, DeptNo, Date of joining, DeptName, Location,
Salary)
Query :
SQL> create table teacher(Id number(2) primary key, name varchar2(20) not null, Deptno number(2) not
null, Deptname varchar2(20) not null, joinDate date not null, location varchar2(20) not null, salary
number(10,2) not null);
SQL> insert into teacher values(13,'manirathnam',6,'commerce', '18-Dec-2006', 'abids', 30000); SQL> insert
into teacher values(14,'sita',6,'commerce', '28-Aug-2016', 'kingkoti', 23000);
Sql> update teacher set salary= salary+(salary * 0.25) where Deptname= ‘mathematics';
Sql>rollback;
Sql> update teacher set salary= salary+(salary * 0.15) where Deptname= ‘commerce';
Sql>commit;
Lab Practical No: 4 Question:
4 . (Exercise on order by and group by clauses) Create Sales table with the following fields( Sales No,
Salesname, Branch, Salesamount, DOB)
( b ) Calculate total salesamount in each branch ( c ) Calculate average salesamount in each branch .
( d ) Display all the salesmen, DOB who are born in the month of December as day in character format i.e.
21-Dec-09
( e ) Display the name and DOB of salesman in alphabetical order of the month.
Sales Table:
(Sales_No,Sales_Name,Branch,Sales_Amount,DOB)
Query:
( b ) Calculate total salesamount in each branch ( c ) Calculate average salesamount in each branch .
( d ) Display all the salesmen, DOB who are born in the month of December as day in character format i.e.
21-Dec-09
( e ) Display the name and DOB of salesman in alphabetical order of the month.
Query:
( d ) Display all the salesmen, DOB who are born in the month of December as day in character format
i.e. 21-Dec-09
( e ) Display the name and DOB of salesman in alphabetical order of the month.
5. Create an Emp table with the following fields:(EmpNo, EmpName, Job,Basic, DA, HRA,PF,
GrossPay, NetPay)
( c ) If NetPay is less than <Rs. 10,000 add Rs. 1200 as special allowances . ( d ) Display the employees
whose GrossPay lies between 10,000 & 20,000 ( e ) Display all the employees who earn maximum salary .
Employee Table
(Emp_No,Emp_ Name, Designation, basic, DA, HRA, PF, Gross pay, Net pay); Query:
Sql> create table Employee (Emp_No number(6) primary key, Emp_Name char(25) not null , Designation
varchar(25),Emp_Basic number(10,2));
Query:
( c ) If NetPay is less than <Rs. 10,000 add Rs. 1200 as special allowances .
Query:
( d ) Display the employees whose GrossPay lies between 10,000 & 20,000
Query:
Query:
6. Employee Database An Enterprise wishes to maintain a database to automate its operations. Enterprise is
divided into certain departments and each department consists of employees. The following two tables
describes the automation schemas
a)Update the employee salary by 15%, whose experience is greater than 10 years.
b)Delete the employees, who completed 30 years of service.
c)Display the manager who is having maximum number of employees working under him?
Sql> create table dept(deptno number(3) primary key, dname varchar2(30) not null, loc varchar2(30) not
null);
Create Dept table : Emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
Sql>create table emp(empno number(3) primary key, ename varchar2(20) not null, job varchar2(20) not
null, mgr number(3) references emp(empno), hiredate date not null, sal number(10,2) not null, comm
Number(10,2), deptno number(3));
Sql>insert into dept values(103, ‘MARKETING’,’ PERTH’); Sql>insert into dept values(104,
‘PRODUCTION’,’ BRISBANE’); Sql>insert into dept values(105, ‘Humanresource’,’ hyderabad’);
Sql> insert into emp (empno, ename ,job, hiredate, sal, deptno) values
(68319,’KAYLING’,’PRESIDENT’,’18-Nov-1991’,6000.00,101);
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
(67832,’ CLARE’,’ MANAGER’,68319,’18-Nov-1991’, 2550.00,101);
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal,comm, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal,comm, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal,comm, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal,comm, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Sql> insert into emp (empno, ename ,job,mgr, hiredate, sal, deptno) values
Query
c)Display the manager who is having maximum number of employees working under him?
Create view
Sql> create view mgrcount as select mgr, count(empno) total from emp group by mgr;
Sql> select mgr from mgrcount where total in (select max(total) from mgrcount);
Sql> create view employee_manager as select e1.ename ,e2.ename from emp e1, emp e2 where
e1.mgr=e2.empno;