0% found this document useful (0 votes)
146 views3 pages

Mid Term Exam DB2

The document provides instructions for copying database tables from an Oracle HR schema into new tables and then performing various queries on those tables. It asks the user to copy table structures and data from the HR schema into new tables with DB2 suffixes. It then provides several questions asking the user to write SQL queries to retrieve and display data from the copied tables based on various conditions. The questions cover topics like adding constraints, inserting data, displaying employee details, and writing joins across multiple tables.

Uploaded by

Pardeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views3 pages

Mid Term Exam DB2

The document provides instructions for copying database tables from an Oracle HR schema into new tables and then performing various queries on those tables. It asks the user to copy table structures and data from the HR schema into new tables with DB2 suffixes. It then provides several questions asking the user to write SQL queries to retrieve and display data from the copied tables based on various conditions. The questions cover topics like adding constraints, inserting data, displaying employee details, and writing joins across multiple tables.

Uploaded by

Pardeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: __________________________________________________________________ ID ____________________________________

The following is the structure of the tables provided by Oracle in Human Resource Schema (HR).

Figure 1- Human Resource Schema (HR) structure

1. Connect to HR user and create tables in Figure 1 as a full copy from HR Schema tables (structure + data). The
table name, which you will create are: REGIONS_DB2, DEPARTMENTS_DB2, EMPLOYEES_DB2,
COUNTRIES_DB2, JOBS_DB2, LOCATIONS_DB2, JOB_HISTORY_DB2).

For the rest of questions, you will be using tables created in Question #1
2. Add a constraint ( table level) to table EMPLOYEES_DB2 where Column « Phone_number » must include at
least 8 numbers.
3. Add a constraint ( table level) to table JOBS_DB2 so MIN_SALARY will be always inferior to MAX_SALARY
4. Insert the next fields in JOBS_DB2 and show the answer
Job_id: 890 , Job_Title: DB_Exam, MIN_SALARY: 3500, MAX_SALARY: 2300
5. Display details of employee with ID 150 or 160.

Using the last number in your ID, select your questions:

xx1. Display employees who joined (HIRE_DATE) in 2000 and doing job that has maximum salary more than
10000.
xx1. Write a query in SQL to display the first name, last name, department number, and department name for each
employee.
xx1. Write a query in SQL to display the first name, last name, and department number for those employees who
works in the same department as the employee who holds the last name as Taylor.

xx2. Display departments where the name of the manager is MICHAEL.


xx2. Write a query in SQL to display the first and last name, department, city, and state province for each employee.
xx2. Write a query in SQL to display the job title, department name, full name (first and last name ) of employee,
and starting date for all the jobs which started on or after 1st January, 1993 and ending with on or before 31
August, 1997

xx3. Display jobs where the minimum salary is less than salary of employee 105.
xx3. Write a query in SQL to display the first name, last name, department number and department name, for all
employees for departments 80 or 40.
xx3. Write a query in SQL to display job title, full name (first and last name ) of employee, and the difference
between maximum salary for the job and salary of the employee.
xx4. Display employees who have underscore in their email address
xx4. Write a query in SQL to display those employees who contain a letter z to their first name and also display
their last name, department, city, and state province.
xx4. Write a query in SQL to display the name of the department, average salary and number of employees
working in that department who got commission.

xx5. Display employee name and manager name of the employee.


xx5. Write a query in SQL to display all departments including those where does not have any employee.
xx5. Write a query in SQL to display the full name (first and last name ) of employees, job title and the salary
differences to their own job for those employees who is working in the department ID 80.

xx6. Display number of employees joined in each year into department 30.
xx6. Write a query in SQL to display the first and last name and salary for those employees who earn less than the
employee earn whose number is 182
xx6. Write a query in SQL to display the name of the country, city, and the departments which are running there.

xx7. Display job id, department id and sum of salary by including al possible dimensions.
xx7. Write a query in SQL to display the first name of all employees including the first name of their manager.
xx7. Write a query in SQL to display department name and the full name (first and last name) of the manager.

xx8. Display employee name and job title of jobs where salary of employee is between minimum and maximum
salary for job.
xx8. Write a query in SQL to display the department name, city, and state province for each department
xx8. Write a query in SQL to display job title and average salary of employees.

xx9. Display how many employees have commission percentage and how many do not have.
xx9. Write a query in SQL to display the first name, last name, department number and name, for all employees
who have or have not any department
xx9. Write a query in SQL to display the sum of salaries of all employees grouped by department

xx0. Display first name, job title, department name of employees who joined on 28th Feb.
xx0. Write a query in SQL to display the details of jobs which was done by any of the employees who is presently
earning a salary on and above 12000.
xx0. Write a query in SQL to display the first name of all employees and the first name of their manager including
those who does not working under any manager

ANNEXE:

You might also like