8
1. A. Create the Two tables based on the following table instance charts. Choose the appropriate data types and be sure to add integrity constraints and perform manipulate operations. Table name: EMPLOYEE Column Name Emp name Emp_id Joining date Dept name salary address Key type PK Null/ unique NN NN NN Check IT,ECE,EE E Data type Varchar2 number date Varchar2 number Varchar2 length 100 10 100 20 100 Table name: Email_id Column Name Email_id Emp_id Key type PK,FK Null/ unique NN,U NN Check Data type Varchar2 number length 100 10 B. Write a stored procedure to retrieve common details of Emp_id, Emp_name, dept name, salary, email _id in both the tables.(Use Emplolyee, Email tables) 2. A. Employee(empname, empno, salary, joiningdate, deptno, designation) Department(deptno, deptname) i. Write a SQL Query to display the department no, maximum average salary in department wise from the employee table.

dbms lab

Embed Size (px)

Citation preview

Page 1: dbms lab

1. A. Create the Two tables based on the following table instance charts. Choose the appropriate data types

and be sure to add integrity constraints and perform manipulate operations.

Table name: EMPLOYEE

Column

Name

Emp

name

Emp_id Joining

date

Dept name salary address

Key type PK

Null/unique NN NN NN

Check IT,ECE,EEE

Data type Varchar2 number date Varchar2 number Varchar2

length 100 10 100 20 100

Table name: Email_id

Column

Name

Email_id Emp_id

Key type PK,FK

Null/unique NN,U NN

Check

Data type Varchar2 number

length 100 10

B. Write a stored procedure to retrieve common details of Emp_id, Emp_name, dept name, salary, email

_id in both the tables.(Use Emplolyee, Email tables)

2. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

Department(deptno, deptname)

i. Write a SQL Query to display the department no, maximum average salary in department

wise from the employee table.

ii. Write a SQL Query to count the number of employees with the same designation.

iii. Write a SQL query to retrieves all rows in the EMPLOYEES table, even if there is no match

in the DEPARTMENTS table. It also retrieves all rows in the DEPARTMENTS table, even if

there is no match in the EMPLOYEES table.

iv. cross products of two tables.

B. Execute a VB Program to perform purchase control for any application.

Page 2: dbms lab

3. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

Department(deptno, deptname)

i. Create a query to display the employee numbers and employee names of all employees who earn

more than the average salary. Sort the results in ascending order of salary.

ii. Write a SQL Query to display the maximum and minimum marks in department wise from the student

table.

iii. Retrieve the data from the view.

B. Write a PL/SQL Function Program to find a netpay for a given basic salary(payroll processing)

4. A. Create the tables based on the following table instance charts. Choose the appropriate data types and

be sure to add integrity constraints and perform manipulate operations.

Table name: MEMBER

1. Write a SQL Query to display the number of phone number values in the MEMBER tables.

2. Write a SQL Query to displays the number of distinct phone number values in the MEMBER

table.

B. To create a simple wordpad application using menu editor.

5. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

Department(deptno, deptname)

i. Create a view called SALARY_VU based on the employee names, department names, salaries, and designation for all employees. Use the EMPLOYEES, DEPARTMENTS tables. Label the columns Employee, Department, Salary, and designation, respectively.ii. Write a SQL Query to displays the average, highest, lowest, and sum of monthly salaries for all Lecturer.iii. Write a SQL query to retrieves all rows in the EMPLOYEES table, which is the left table even if there is no match in the DEPARTMENTS table.iv. Write a SQL Query to displays the details of all employees whose salary is equal to the minimum salary.v. Retrieving Records with natural join.B. Execute a VB Program to perform inventory control for any application and generate the reports.

Page 3: dbms lab

6. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

Department(deptno, deptname)

i. Show the structure of the DEPARTMENTS table. Select all data from the table.

ii. The SELECT statement on the slide returns rows from the EMPLOYEES table for any employee whose

salary is between $2,500 and $3,500.

iii. Write a query to displays employee numbers, employee names, salaries, and dept numbers for all the

employees whose dept number is 100, 101, or 201

iv. Write a query to displays the employee names and joining dates of all employees who joined between

January 2008 and December 2009:

v. Write a query that displays the difference between the highest and lowest salaries. Label the

column DIFFERENCE.

vi. Write a query to display the current date. Label the column Date.

B. Write a PL/SQL Procedure to calling a Function whether to find the employee no

7. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

i. Display the employee name, salary, and department no for all employees . Sort data in descending order

of salary and department no.

ii. Display the employee names of all employees where the third letter of the name is an a.

iii. Display the employee employee name, job ID, and start date of employees hired between February 20,

1998, and May 1, 1998. Order the query in ascending order by start date.

iv. Display the employee name and salary of employees who earn between $5,000 and $12,000, and are in

department 20 or 50. Label the columns Employee and Monthly Salary, respectively

V. Display the employee name, designation, and salary for all employees whose designation is lecture or

clerk and whose salary is not equal to $2,500, $3,500, or $7,000.

vi. Display the employee name and department number of all employees in departments 20 and 50 in

alphabetical order by name.

B. Write a two trigger program(before ,after update)

8. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

i. create a view employee_view that contains details of employees in department “80”ii. create a view by using column aliases in the sub query.iii. Display the structure and contents of the employee_view view.iv. Attempt to reassign employee name =’sam’ in department no 80.v. . Create a query to display the employee name and salary of employees earning more than $12,000.vi. Create a query to display the employee name and department number for employee number 176.vii. Write a SQL query to display the employee name and salary for all employees whose salary is not in the range of $5,000 and $12,000.

B. Write a PL/SQL Function Program to find a given no is odd or even.

Page 4: dbms lab

9. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

Department(deptno, deptname)

i. Write a query to display the employee name, department number, and department name for all

employees.

ii. Display the employee name and department name for all employees who have an ‘a’

(lowercase) in their employee names.

iii. Mark an intermediate point in the processing of the transaction.

iv. Empty the entire table.

v. Discard the most recent DELETE operation without discarding the earlier INSERT operation.

vi. Write a query to displays all columns and all rows of the DEPARTMENTS table:

B. Write a PL/SQL Procedure to calling a Function whether to find a average marks for a given set of

marks.

10. A. Write a PL/SQL Function Program to find a average marks for a given set of marks.

B. Execute a VB Program to perform inventory control for any application and generate the reports.

11. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

Department(deptno, deptname)

i. . Write a SQL query to retrieves all rows in the DEPARTMENTS table, which is the right table even if

there is no match in the EMPLOYEES table.

ii. Write a SQL Query to displays the details of all employees whose salary is equal to the maximum salary.

iii. Find the employees who earn the same salary as the minimum salary for each department.

vi. Create a query to display the employee name and department number for employee number 176.

vii. Write a SQL query to display the employee name and salary for all employees whose salary is not in

the range of $5,000 and $12,000.

B. Write a PL/SQL Program to retrieve common details of empno, empname, departmentno, deptname,

joining date, designation in both the tables.

Page 5: dbms lab

14. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

i. Display the employee name, salary, and department no for all employees . Sort data in descending order of salary and department no. ii. Display the employee names of all employees where the third letter of the name is an a.iii. Display the employee employee name, job ID, and start date of employees hired between February 20, 1998, and May 1, 1998. Order the query in ascending order by start date.iv. Display the employee name and salary of employees who earn between $5,000 and $12,000, and are in department 20 or 50. Label the columns Employee and Monthly Salary, respectivelyV. Display the employee name, designation, and salary for all employees whose designation is lecture or clerk and whose salary is not equal to $2,500, $3,500, or $7,000.vi. Display the employee name name and department number of all employees in departments 20 and 50 inalphabetical order by name.

B. Write a PL/SQL Cursor Program to retrieve employee numbers , names and populate a database table,

temp_list with this information.

8. A. Employee(empname, empno, salary, joiningdate, deptno, designation)

i. create a view employee_view that contains details of employees in department “80”ii. create a view by using column aliases in the sub query.iii. Display the structure and contents of the employee_view view.iv. Attempt to reassign employee name =’sam’ in department no 80.v. . Create a query to display the employee name and salary of employees earning more than $12,000.vi. Create a query to display the employee name and department number for employee number 176.vii. Write a SQL query to display the employee name and salary for all employees whose salary is not in the range of $5,000 and $12,000.

B. Write a PL/SQL Function Program to find a given no is odd or even.

10. A. Write a PL/SQL Function Program to find a average marks for a given set of marks.

B. Execute a VB Program to perform inventory control for any application and generate the reports.

10. A. Write a PL/SQL Function Program to find a average marks for a given set of marks.

B. Execute a VB Program to perform inventory control for any application and generate the reports.

10. A. Write a PL/SQL Function Program to find a average marks for a given set of marks.

B. Execute a VB Program to perform inventory control for any application and generate the reports.

10. A. Write a PL/SQL Function Program to find a average marks for a given set of marks.

B. Execute a VB Program to perform inventory control for any application and generate the reports.

10. A. Write a PL/SQL Function Program to find a average marks for a given set of marks.

B. Execute a VB Program to perform inventory control for any application and generate the reports.

Page 6: dbms lab