List of Practical Exercises (ORACLE)

Similar documents
Chapter 1. Writing Basic. SQL Statements

Producing Readable Output with SQL*Plus

Subqueries Chapter 6

SQL Introduction Chapter 7, sections 1 & 4. Introduction to SQL. Introduction to SQL. Introduction to SQL

Conversion Functions

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Displaying Data from Multiple Tables. Chapter 4

Aggregating Data Using Group Functions

Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language:

Displaying Data from Multiple Tables

SQL*Plus User s Guide and Reference

Data Models and Database Management Systems (DBMSs) Dr. Philip Cannata

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

SQL> SELECT ename, job, sal Salary. 1.4.Will the SELECT statement execute successfully? True/False

Oracle 12c New Features For Developers

Lab # 5. Retreiving Data from Multiple Tables. Eng. Alaa O Shama

Appendix A Practices and Solutions

Relational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )

Displaying Data from Multiple Tables. Copyright 2006, Oracle. All rights reserved.

Unit 10: Microsoft Access Queries

RDBMS Using Oracle. Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture. kamran.munir@gmail.com. Joining Tables

Oracle/SQL Tutorial 1

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved.

GUJARAT TECHNOLOGICAL UNIVERSITY

Displaying Data from Multiple Tables

Retrieval: Multiple Tables and Aggregation

There are five fields or columns, with names and types as shown above.

DECLARATION SECTION. BODY STATEMENTS... Required

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

Chapter 9, More SQL: Assertions, Views, and Programming Techniques

MONASH UNIVERSITY. Faculty of Information Technology

Presentation of database relational schema (schema 1) Create Universe step by step

Where? Originating Table Employees Departments

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved.

TO_CHAR Function with Dates

Creating QBE Queries in Microsoft SQL Server

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Oracle 10g PL/SQL Training

SQL, PL/SQL FALL Semester 2013

Performance Implications of Various Cursor Types in Microsoft SQL Server. By: Edward Whalen Performance Tuning Corporation

Lab Manual. Database Systems COT-313 & Database Management Systems Lab IT-216

Chapter 2: Security in DB2

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

Database CIS 340. lab#6. I.Arwa Najdi

A basic create statement for a simple student table would look like the following.

Procedural Extension to SQL using Triggers. SS Chung

Unit 3. Retrieving Data from Multiple Tables

Tune That SQL for Supercharged DB2 Performance! Craig S. Mullins, Corporate Technologist, NEON Enterprise Software, Inc.

Overview of Database Management

Microsoft Access Lesson 5: Structured Query Language (SQL)

Oracle SQL. Course Summary. Duration. Objectives

Data Big and Small: How Publisher gain Value out of Data in the Future

Excel 2010 Sorting and Filtering

Figure 4.12.Insurancedatabase.

Using Multiple Operations. Implementing Table Operations Using Structured Query Language (SQL)

Part 2 - The Database Environment

Mini User's Guide for SQL*Plus T. J. Teorey

Chapter 1 Overview of the SQL Procedure

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: Introduction to SQL

University of Massachusetts Amherst Department of Computer Science Prof. Yanlei Diao

Handling Exceptions. Copyright 2008, Oracle. All rights reserved.

In This Issue: Excel Sorting with Text and Numbers

Oracle Database 11g SQL

Handling Exceptions. Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 8-1

Distributed Database Systems. Prof. Dr. Carl-Christian Kanne

4. The Third Stage In Designing A Database Is When We Analyze Our Tables More Closely And Create A Between Tables

Overview of Database Management Systems

7. Databases and Database Management Systems

!"#"$%&'(()!!!"#$%&'())*"&+%

Introduction to SQL ( )

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: Introduction to SQL

Lecture 4: SQL Joins. Morgan C. Wang Department of Statistics University of Central Florida

Rochester Institute of Technology. Oracle Training: Preparing Journal Entries in the Oracle Applications

Using AND in a Query: Step 1: Open Query Design

The Power of DECODE()

Oracle Database: Introduction to SQL

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Word 2007: Mail Merge Learning Guide

How To Save Data On A Spreadsheet

Guide to Performance and Tuning: Query Performance and Sampled Selectivity

VARRAY AND NESTED TABLE

Chapter 5. Microsoft Access

Self Service Business Intelligence - how to bring Oracle and DB2 z/os data together

9.1 SAS. SQL Query Window. User s Guide

Objectives. Oracle SQL and SQL*PLus. Database Objects. What is a Sequence?

Mastering Mail Merge. 2 Parts to a Mail Merge. Mail Merge Mailings Ribbon. Mailings Create Envelopes or Labels

Database programming 20/08/2015. DBprog news. Outline. Motivation for DB programming. Using SQL queries in a program. Using SQL queries in a program

ICAB4136B Use structured query language to create database structures and manipulate data

Check out our website!

Using the SQL Procedure

Training Guide. PL/SQL for Beginners. Workbook

Transcription:

ASSIGNMENT Batch : 2010-12 Session : 2011-12 Programme: MBA Semester : III/IV Course Code : MS-251 Course Title : DBMS Lab List of Practical Exercises (ORACLE) (Set 1) Note: Consider the EMP and DEPT tables for the following queries. 1. Retrieve a list of MANAGERS. 2. Find out salary of both MILLER and SMITH. 3. Find out the names and salaries of all employees earning more than 1000 per month. 4. Display the names and salaries of all employees except JAMES. 5. Find out the details of employees whose names begin with S. 6. Find out the names of all employees that have A anywhere in their name. 7. Find out the names of all employees that have L as their third character in their name. 8. Find out the names of the employees whose name begin with A or M. 9. Compute yearly salary of SMITH. 10. Compute daily salary of JONES. 11. Calculate the total monthly salary of all employees. 12. Print the average annual salary. 13. Select the name, job, salary, department number of all employees except SALESMAN from department number 30. 14. List unique departments of the EMP table. SQL> select distinct deptno from emp; DEPTNO --------- 10 20 30 15. List the name and salary of employees who can earn more than 1500 and are in department 10 or 30. Label the columns Employee and Monthly Salary respectively.

SQL> SELECT ENAME "NAME",SAL "MONTHLY SALARY" FROM EMP WHERE SAL>1500 AND DEPTNO IN(10,30); NAME MONTHLY SALARY ---------- -------------- ALLEN 1600 BLAKE 2850 CLARK 2450 KING 5000 16. List the name and salary for all employees whose salary is not in the range of 1500 and 2850. SQL> SELECT ENAME, SAL FROM EMP WHERE SAL<1500 OR SAL>2850; ENAME ---------- --------- SAL SMITH 800 WARD 1250 JONES 2975 MARTIN 1250 SCOTT 3000 KING 5000 ADAMS 1100 JAMES 950 FORD 3000 MILLER 1300 10 rows selected. 17. Display the name and job of all employees who do not have a MANAGER. SQL> SELECT ENAME, JOB FROM EMP WHERE JOB IN ('MANAGER','PRESIDENT'); ENAME JOB ---------- --------- JONES MANAGER BLAKE MANAGER CLARK MANAGER KING PRESIDENT 18. Display the name, job, and salary of all the employees whose job is MANAGER or ANALYST and their salary is not equal to 1000, 3000, or 5000. SQL> SELECT ENAME,JOB,SAL FROM EMP WHERE JOB IN('MANAGER','ANALYST') AND SAL <> 1000 AND SAL <> 2000 AND SAL <> 3000; ENAME JOB ---------- --------- --------- SAL JONES MANAGER 2975 BLAKE MANAGER 2850 CLARK MANAGER 2450

19. Display the name, salary and commission for all employees whose commission amount is greater than their salary increased by 10%. SQL> select sal,comm from emp where sal/10=comm; no rows selected 20. Display the name of all employees who have two Ls in their name and are in department 30 or their manager is 7782. SQL> SELECT ENAME FROM EMP WHERE ENAME LIKE ('%L%L%') AND DEPTNO = 30 OR MGR = 7782; ENAME ---------- ALLEN MILLER 21. Display the names of employees with experience of over 10 years or und 0Count the total number of employees. 22. Retrieve the names of departments in ascending order and their employees in descending order. 23. Find out experience of MILLER. 24. How many different departments are there in the employee table. 25. Find out which employee either work in SALES or RESEARCH department. 26. Print the name and average salary of each department. 27. Select the minimum and maximum salary from employee table. 28. Select the minimum and maximum salaries from each department in employee table. 29. Select the details of employees whose salary is below 1000 and job is CLERK.

ASSIGNMENT Batch : 2010-12 Session : 2011-12 Programme: MBA Semester : III/IV Course Code : 251 Course Title : DBMS Lab List of Practical Exercises (ORACLE) (Set 2) Consider the relations given below: EMPLOYEE (EmployeeID, EmployeeName, Street, City) COMPANY (CompanyID, CompanyName, City) WORKS (EmployeeID, CompanyID, Salary) MANAGES (EmployeeID, ManagerID) I. Create above relations using your own data types and print the structure of the each relation. II. Insert at least 10 records in the relation EMPLOYEE and 5 records in the relation COMPANY. Insert appropriate records in the relations WORKS and MANAGES. III. Print the contents of the each relation. IV. Give an expression in SQL with output for each of the following queries: 1. Find the names of all employees who work for First Bank Corporation. 2. Find the names and cities of residence of all employees who work for the First Bank Corporation. 3. Find the names, street, and cities of residence of all employees who work for First Bank Corporation and earn more than Rs. 10,000/-. 4. Find the employees who live in the same cities as the companies for which they work. 5. Find all employees who live in the same cities and on the same streets as do their managers. 6. Find all employees who do not work for First Bank Corporation. 7. Find all employees who earn more than every employee of Small Bank Corporation. 8. Find all companies located in every city in which Small Bank Corporation is located.

9. Find all employees who earn more than the average salary of all employees of their company. 10. Find the company that has the most employees. 11. Find the company that has the smallest payroll. 12. Find those companies whose employees earn a higher salary, on average, than the average salary at First Bank Corporation.