DBMS
DBMS
Branch
BNAME CITY
VRCE NAGPUR
KAROLBAGH DELHI
CHANDI DELHI
DHARAMPETH NAGPUR
M.G.ROAD BANGLORE
INSERT INTO branch VALUES ('vrce', 'nagpur'), ('karolbagh', 'delhi'), ('chandi', 'delhi'),
('dharampeth', 'nagpur'), ('m.g.road', 'banglore');
CUSTOMERS
CNAME CITY
ANIL CALCUTTA
SUNIL DELHI
MEHUL BARODA
MANDAR PATNA
MADHURI NAGPUR
PRMOD NAGPUR
INSERT INTO customers VALUES ('anil', 'calcutta'), ('sunil', 'delhi'), ('mehul', 'baroda'), ('mandar',
'patna'), ('prmod', 'nagpur');
BORROW
Create the below given table and insert the data accordingly
Create Table Job (job_id varchar(15), job_title varchar(30), min_sal float(7,2), max_sal
float(7,2));
Column Name Datatype
Emp_no Number(3)
Emp_name Varchar2(30)
Emp_sal Number(8,2)
Emp_comm Number(6,1)
Dept_no Number(3)
INSERT INTO `deposit` (`a_no`, `cname`, `bname`, `amount`, `a_date`) VALUES ('101', 'anil',
'andheri', '7000', '2006-01-01'), ('102', 'sunil', 'virar', '5000', '2006-07-15'), ('103', 'jay',
'villeparle', '6500', '2006-03-12'), ('104', 'vijay', 'andheri', '8000', '2006-09-17'), ('105', 'keyur',
'dadar', '7500', '2006-11-19'), ('106', 'mayur', 'borivali', '5500', '2006-12-21');
(1) Retrieve all data from employee, jobs and deposit.
SELECT * FROM epmloyee,job,deposit;
(2) Give details of account no. and deposited rupees of customers having account opened
between dates 01-01-06 and 25-07-06.
SELECT A_no,Amount FROM deposit WHERE a_date > '2006-01-01' and a_date <
'2006-07-25';
(3) Display all jobs with minimum salary is greater than 4000.
SELECT * FROM job WHERE min_sal > 4000;
(4) Display name and salary of employee whose department no is 20. Give alias name to
name of employee.
SELECT emp_name as name,emp_sal FROM employee where dept_no = 20;
(5) Display employee no,name and department details of those employee whose
department lies in(10,20)
SELECT emp_no,emp_name,dept_no FROM employee where dept_no IN
(10,20);
(1) Display all employee whose name start with ‘A’ and third character is ‘ ‘a’.
(2) Display name, number and salary of those employees whose name is 5 characters long and
(3) Display the non-null values of employees and also employee name second character should be
‘n’ and string should be 5 character long.
(4) Display the null values of employee and also employee name’s third character should be ‘a’.
(5) What will be output if you are giving LIKE predicate as ‘%\_%’ ESCAPE ‘\’
Practical - 3.
To Perform various data manipulation commands, aggregate functions and sorting concept on all
created tables.
(2) Give name of customer who are borrowers and depositors and having living city nagpur
(3) Give city as their city name of customers having same living branch.
(4) Write a query to display the last name, department number, and department name for all
employees.
(5) Create a unique listing of all jobs that are in department 30. Include the location of the department
in the output
(6) Write a query to display the employee name, department number, and department name for all
employees who work in NEW YORK.
(7) Display the employee last name and employee number along with their manager’s last name and
manager number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively.
(8) Create a query to display the name and hire date of any employee hired after employee SCOTT.
(1) List total deposit of customer having account date after 1-jan-96.
(4) Display the highest, lowest, sum, and average salary of all employees. Label the columns Maximum,
Minimum, Sum, and Average, respectively. Round your results to the nearest whole number.
(5) Write a query that displays the difference between the highest and lowest salaries. Label the column
DIFFERENCE.
(6) Create a query that will display the total number of employees and, of that total, the number of
employees hired in 1995, 1996, 1997, and 1998
(7) Find the average salaries for each department without displaying the respective department
numbers.
(8) Write a query to display the total salary being paid to each job title, within each department.
(9) Find the average salaries > 2000 for each department without displaying the respective department
numbers.
(10) Display the job and total salary for each job with a total salary amount exceeding 3000, in which
excludes president and sorts the list by the total salary.
(11) List the branches having sum of deposit more than 5000 and located in city bombay.
7. To solve queries using the concept of sub query.
(1) Write a query to display the last name and hire date of any employee in the same department as
SCOTT. Exclude SCOTT
(2) Give name of customers who are depositors having same branch city of mr. sunil.
(3) Give deposit details and loan details of customer in same city where pramod is living.
(4) Create a query to display the employee numbers and last names of all employees who earn more
than the average salary. Sort the results in ascending order of salary.
(5) Give names of depositors having same living city as mr. anil and having deposit amount greater than
2000
(6) Display the last name and salary of every employee who reports to ford.
(7) Display the department number, name, and job for every employee in the Accounting department.
(9) Give the name of cities where in which the maximum numbers of branches are located.
(10) Give name of customers living in same city where maximum depositors are located.
8. Manipulating Data
(3) Give 10% interest to all depositors living in nagpur and having branch city bombay.
(4) Write a query which changes the department number of all employees with empno 7788’s job to
employee 7844’current department number.
(5) Transfer 10 Rs from account of anil to sunil if both are having same branch.
(6) Give 100 Rs more to all depositors if they are maximum depositors in their respective branch.
(9) Delete borrower of branches having average loan less than 1000.
9. To apply the concept of security and privileges.