dbms_practice_questions[1]-1
dbms_practice_questions[1]-1
a) List dept no., Dept name for all the departments in which there are no employees in the
department.
1. Find the loan number of those loans with loan amounts between $90,000 and $100,000
(that is, $90,000 and $100,000)
2. Find the name, loan number and loan amount of all customers having a loan at the
Perryridge branch; rename the column name loan_number as loan_id.
3. Find the names of all customers whose street includes the substring “Main”.
4. List in alphabetic order the names of all customers having a loan in Perryridge branch
5. Find all customers who have an account but no loan.
6. Find the average account balance at the Perryridge branch.
7. Drop all the tables from the database.
a) List dept no., Dept name for all the departments in which there are no employees in the
department.
c) Select all records where ename may be any no of character but it should end with ‘R’.
B) Create a table
Its value is the sum of hrs of all employees working on that project.
eno and pno are primary keys, head_no is foreign key to emp relation.
b) Create a trigger to insert a new employee tuple and display the new total hours
from project table.
B) Database Schema for a Student Library scenario
a) List dept no., Dept name for all the departments in which there are no employees in the
department.
3. Modify the above table to add three more columns salary,mgr,comm to the emp
table. add salary column with constraint greater than zero.
B) Create the following constraints and put proper constraints wherever required:
Employee(eno,name,addr,qualification,course_id, dept, design,dob,doj)
Accounts(eno, basec_sal, DA,HRA,PF,gross_sal)
Training(course_id,course_name)
c)
d)
A) Write a query in sql to create a table employee and department.
Employee(empno,ename,deptno,job,hiredate)
Department(deptno,dname,loc)
a. Give list of emp name & their job spec who are working in dept no 20 ?
b. Compile the details of emp working in dept no 30 ?
c. To find the total number of employees.
d. To find the total number of clerk hired after 13-jan-81.
e. Determine which departments have more than two people holding a particular job?
f. Find all department that have at least two clerk?
g. Retrieve emp name and job who have the same job as that of allen?
h. List all emp name and their job of those departments that are located at Chicago?
B) Create the following constraints and put proper constraints wherever required:
Employee(eno,name,addr,qualification,course_id, dept, design,dob,doj)
Accounts(eno, basec_sal, DA,HRA,PF,gross_sal)
Training(course_id,course_name)
c)
d)
A) Create a table client master with the following fields
client_no, name, address1, address2, city, state, pin_code, remarks, balance due
B) Create the following constraints and put proper constraints wherever required:
Employee(eno,name,addr,qualification,course_id, dept, design,dob,doj)
Accounts(eno, basec_sal, DA,HRA,PF,gross_sal)
Training(course_id,course_name)
c)
d)
A) . Create the following constraints and put proper constraints wherever required:
Employee(eno,name,addr,qualification,course_id, dept, design,dob,doj)
Accounts(eno, basec_sal, DA,HRA,PF,gross_sal)
Training(course_id,course_name)
c)
d)
e)
d)
e)
c) List all the bills for the current date with the customer names and item numbers
d) List the details of the customer who have bought a product which has a price>200
e) Give a count of how many products have been bought by each customer
g) Create a view which lists out the bill_no, bill_date, cust_id, item_id, price, qty_sold,
amount
B) Create a table
Its value is the sum of hrs of all employees working on that project.
eno and pno are primary keys, head_no is foreign key to emp relation.
d) Create a trigger to insert a new employee tuple and display the new total hours
from project table.
A). Database Schema for a Student Library scenario
B) Create a table
Its value is the sum of hrs of all employees working on that project.
eno and pno are primary keys, head_no is foreign key to emp relation.
b) Create a trigger to change the project of an employee and display the new total
hours from project table.
A) . Database Schema for a Employee-pay scenario
B) Create a table
Its value is the sum of hrs of all employees working on that project.
eno and pno are primary keys, head_no is foreign key to emp relation.
b) Create a trigger to insert a new employee tuple and display the new total hours
from project table.
A) Database Schema for a Student Library scenario
1. Create query to display the last name and salary for all employees whose salary is not in the range
of $5,000 and $12,000.
2. Create a query to display the name and hire date of any employee hired after employee Kochhar.
3. Create a query to display the employee numbers and last names of all employees who earn more
than the average salary. Sort the result in descending order of salary.
4. Change the name of employee 101 to Drexler.
5. Modify the EMP table. Add a COMMISSION column of type float. Add a constraint to the
commission column that ensures that a commission value is greater than zero.
6. Create a view called EMPLOYEE_VU based on the employee_id, last_names, and dept_id from the
EMPLOYEE table. Changes the heading for the employee name to EMP_NAME. And Display the
contents of the EMPLOYEE_VU view.
7. Write compound query that lists the following:
Last names and department ID of all the employees from the EMPLOYEES table, regardless
of whether or not they belong to any department or not.
Department ID and department name of all the departments from DEPARTMENTS table,
regardless of whether or not they have employees working in them.
A) Create following tables and put proper constraints wherever required:
Employee(e_no,name,addr,qualification,course_id,dept,design,dob,date_join)
Accounts(e_no,basic_sal,DA,HRA,PF,gross_sal)
Training(Course_id,course_name)
Perform
a) List the job that have average annual salary greater than all manager?
b) Find the no of employees and job group by deptno?
c) List all emp names and their salaries who are working in dept no 10 ?
d) To find the minimum salary paid to any employee
e) To list the employee who heads the list alphabetically.
f) List all emp name, dept names and location whose deptno is common in both dept table and
emp table?
g) List all jobs in dept 10 and 20 or in both?
h) Change the data type of “job”from string to integer.
i) Create a trigger such that if hiredate of employee is less than 31/12/1970, then remove
that employee record.
j) Drop trigger
k) Create user “xyz” and add all priviledges to it.