You are on page 1of 25

ARAVALI COLLEGE OF ENGINEERING

AND MANAGEMENT

DEPARTMENT OF
CSE
3rdYear (5thSemester)

Database Management System


Practical file

Submitted To Submitted by
Ms. Antim Panghal Shivam Jha
20CSE72
INDEX

S. No. Program Date Signature

1. Introduction to Oracle, SQL and isqlplus

2. DDL and DML Commands

3. Use of Operators in SQL

Single Row Functions and Multiple Row Functions


4.
in SQL

5. Joins in SQL

6. Subqueries in SQL
PROGRAM 1:
Introduction to Oracle, SQL and isqlplus

ORACLE DATABASE

An Oracle database is a collection of data treated as a unit. The purpose of a database is tostore
and retrieve related information. A database server is the key to solving the problems of
information management. In general, a server reliably manages a large amount of data in a
multiuser environment so that many users can concurrently access the same data. All this is
accomplished while delivering high performance. A database server also prevents unauthorized
access and provides efficient solutions for failure recovery.

Oracle Database is the first database designed for enterprise grid computing, the most flexible
and cost-effective way to manage information and applications. Enterprise grid computing
creates large pools of industry-standard, modular storage and servers. With this architecture,
each new system can be rapidly provisioned from the pool of components. There is no need for
peak workloads, because capacity can be easily added or reallocated from the resource pools as
needed.

The database has logical structures and physical structures. Because the physical and logical
structures are separate, the physical storage of data can be managed without affecting the access
to logical storage structures.

OVERVIEW OF THE ORACLE

Each Oracle database has a data dictionary. An Oracle data dictionary is a set of tables and views
that are used as a read-only reference about the database. For example, a data dictionary stores
information about both the logical and physical structure of the database. A data dictionary also
stores the following information:

• The valid users of an Oracle database

• Information about integrity constraints defined for tables in the database

• The amount of space allocated for a schema object and how much of it is in use

A data dictionary is created when a database is created. To accurately reflect the status of the
database at all times, the data dictionary is automatically updated by Oracle in response to
specific actions, such as when the structure of the database is altered. The database relies on the
data dictionary to record, verify, and conduct ongoing work. For example, during database
operation, Oracle reads the data dictionary to verify that schema objects exist and that users have
proper access to them.

OVERVIEW OF APPLICATION ARCHITECTURE

There are two common ways to architect a database: client/server or multitier. As internet
computing becomes more prevalent in computing environments, many database management
systems are moving to a multitier environment.

Client/Server Architecture

Multiprocessing uses more than one processor for a set of related jobs. Distributed processing
reduces the load on a single processor by allowing different processors to concentrate on a subset
of related tasks, thus improving the performance and capabilities of the system as a whole.

An Oracle database system can easily take advantage of distributed processing by using its
client/server architecture. In this architecture, the database system is divided into two parts: a
front- end or a client, and a back-end or a server.

The Client

The client is a database application that initiates a request for an operation to be performed on
the database server. It requests, processes, and presents data managed by the server. The client
workstation can be optimized for its job. For example, it might not need large disk capacity, or it
might benefit from graphic capabilities.

Often, the client runs on a different computer than the database server, generally on a PC. Many
clients can simultaneously run against one server.

The Server

The server runs Oracle software and handles the functions required for concurrent, shared data
access. The server receives and processes the SQL and PL/SQL statements that originate from
client applications. The computer that manages the server can be optimized for its duties. For
example, it can have large disk capacity and fast processors.

MULTITIER ARCHITECTURE : APPLICATION SERVERS

A multitier architecture has the following components:

• A client or initiator process that starts an operation •

One or more application servers that perform parts of the operation. An application server
provides access to the data for the client and performs some of the query processing, thus
removing some of the load from the database server. It can serve as an interface between clients
and multiple database servers, including providing an additional level of security.

• An end or database server that stores most of the data used in the operation

This architecture enables use of an application server to do the following:

• Validate the credentials of a client, such as a Web browser

• Connect to an Oracle database server

• Perform the requested operation on behalf of the client

WHAT IS SQL?

SQL stands for Structured Query Language. SQL is used to communicate with a database.
According to ANSI (American National Standards Institute), it is the standard language for
relational database management systems. SQL statements are used to perform tasks such as
update data on a database, or retrieve data from a database.Some common relational database
management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres,
etc. Although most database systems use SQL, most of them also have their own additional
proprietary extensions that are usually only used on their system. However, the standard SQL
commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to
accomplish almost everything that one needs to do with a database. This tutorial will provide you
with the instruction on the basics of each of these commands as well as allow you to put them to
practice using the SQL Interpreter.

Common Uses of SQL on the Web

As a user of any database-driven software program, you’re probably using SQL, even if you
don’t know it. For example, a database-driven dynamic web page (like most websites) takes user
input from forms and clicks and uses it to compose a SQL query that retrieves information from
the database required to generate the next web page.

Consider the example of a simple online catalog with a search function. The search page might
consist of a form containing just a text box in which you enter a search term and then click a
search button. When you click the button, the web server retrieves any records from the product
database containing the search term and uses the results to create a web page specific to your
request.

For example, if you searched for products containing the term "Irish," the server might use the
following SQL statement to retrieve related products:

SELECT *FROM productsWHERE name LIKE '%irish%'


Translated, this command retrieves any records from the database table named "products" that
contain the characters "irish" anywhere within the product name.
PROGRAM 2:
DDL and DML Commands
(a) create table for bank database having following columns

Name Type
ACCOUNT_ID NUMBER
ACC_HOLDER_NAME VARCHAR2(20)
ACC_TYPE VARCHAR2(20)
DOB DATE
CONTACT_NUMBER NUMBER
ADDRESS VARCHAR2(100)
AMOUNT_AVAILABLE NUMBER
EMAIL_ID VARCHAR2(50)

The create table statement is used to create a new table. Here is the format of a simple create
table statement:

create table "tablename"("column1" "data type", "column2" "data type", "column3" "data type");
(b)Insert 15 row into the table customer_name with valid data

(C) Describe the structure of table customer_name


Program 3
Write the following queries using employee table.

Employee table –

1. Display the Name, Salary and EID of all the employees whose salary greater than 50000
and name starts with S.
2. Display the Name and salary of all the employees whose salary is between 2500 and
3500.

3. Display Annual salary of all the employee and name the column as “Annual Salary”.
4. Display the name and Id of all employees whose Id is not 20,10 or 40.

5. Display the name and department number of all employees in department 20 and 40 in
alphabetical order by name.
Program 4
1. Write a query to display the current date. Label the column Date.

2. Create a table named Employees_yourname having the following column names. The
datatype you can mention accordingly:
Employee_ID
First_Name
Last_Name
Salary
Department_ID
Date_of_Joining
Insert around 15 rows in the table. For each employee, display the Employee_ID,
Last_Name, Salary and Salary increased by 15% and expressed as a whole number. Label
the columNew Salary. Save your SQL Statement in a text file as Prog 3_2.sql
3. Modify your query Prog 3_2.sql to add a column that subtracts the old salary from the
new salary. Label the column Increase.

4. Write a query that displays the employee’s last name combined with first name. Label the
column Employee_Namewith the first letter capitalized and all other letters lowercase.

A) Find the length of the Employee Name.


B) Find first 5 characters of the Employee Name

C) Left Padding the Employee Name upto 15 characters.


D) Right Padding the Employee Name upto 15 characters.

5. Display the highest, lowest, sum and average salary of all employees. Label the columns
MAXIMUM, MINIMUM, SUM and AVERAGE respectively. Round your result to the
nearest whole number. Save your SQL Statement in a text file as Prog 3_7.sql
6. Modify the query in Prog 3_7.sql to display the maximum, minimum, sum and average
salary for each job type. Resave as Prog 3_8.sql
Program 5

Using the above tables solve the following queries:


1. Write a query to find those customers with their name and those salesmen with their
name and city who lives in the same city.

2. Write a SQL statement to find the names of all customers along with the salesmen who
works for them.

3. Write a SQL statement to display all those orders by the customers not located in the
same cities where their salesmen live.
4. Write a SQL statement that finds out each order number followed by the name of the
customers who made the order.

5. Write a SQL statement that sorts out the customer and their grade who made an order.
Each of the customers must have a grade and served by at least a salesman, who belongs
to a city.
6. Write a query that produces all customers with their name, city, salesman and
commission, who served by a salesman and the salesman works at a rate of the
commission within 12% to 14%.

7. Write a SQL statement that produces all orders with the order number, customer name,
commission rate and earned commission amount for those customers who carry their
grade is 200 or more and served by an existing salesman.
8. Write a SQL statement to make a join on the tables salesman, customer and orders in
such a form that the same column of each table will appear once and only the relational
rows will come.

9. Write a SQL statement to find the details of a order i.e. order number, order date, amount
of order, which customer gives the order and which salesman works for that customer
and how much commission he gets for an order.
10. Write a SQL statement to make a list in ascending order for the customer who works
either through a salesman or by own.
Program 6

The given tables are: -

Department: -

Employees_abhikansh_gupta: -
1. Write a subquery tofind all employees who locate in the location with the id 1700.

2. Write a subquery to find the employees who have the highest salary.

3. Write a subquery to find all employees who salaries are greater than the average salary of
all employees

You might also like