DBMS Practical File
DBMS Practical File
MANAGEMENT
SYSTEM
PRACTICAL FILE
Q1: Write down the steps along with snapshots to open a SQL session
3. Select Oracle-orclient10g_home1
6. An SQL Plus window appear which asks for the user name, password and host string.
7. Enter the user name as bca17, password as 123456 and host string as orcl.
Q. 1 Create Table:
EMPLOYEE
Empcode integer
Empname varchar2(25)
Address varchar2(30)
Gender char(1)
Grade char(2)
Deptcode char(3)
Q. 2. Create Table:
STUDENT
Roll_no integer,
Name varchar2(30)
Course char(3)
Address varchar2(30)
Email_id varchar2(20)
Phone_no number(12)
Father_name varchar2(20)
Marks_X integer
Marks_XII integer
Q. 3. Create Table:
Q. 4. Create Table:
Q. 1 Create Table:
Use datatypes :
Use datatypes :
Use datatypes :
Use datatypes :
Q. 1 Create Table:
Queries:
(i) Display all the bill details of ‟24-jan-12‟
(ii) Display the bill details where total amount is greater than 6000.
(iii) Display the bill details where total amount is less than 500
(ii) Display the bill details where total amount is greater than 6000.
(iii) Display the bill details where total amount is less than 500
Q. 2 Create Table:
Queries:
Queries:
Q.1 To perform queries for the table “BILL” using various DDL,DML and DQL commands.
Queries performed:
(i) Add a column „number_of_items‟ to BILL table
(ii) Rename the table „BILL‟ to „BILL_DETAILS‟.
(iii) Update the bill amount of 24-JAN-12.
(iv) Display the bill no. and total amount multiplied by 3.
Q.2 To perform queries for the table “CAR” using various DDL,DML and DQL commands.
Table „CAR‟:
Queries Performed:
After Updating:
Q.3 To perform queries for the table “SUPPLIER” using various DDL, DML and DQL
commands.
Table „SUPPLIER‟:
Queries Performed:
(i) Display the bill details having bill amount less than 50000 or bill date with
28-jan-12.
(ii) Find all the bills where no. of items is not null.
(iii) Find all the bill details where Bill amount is between 1000 and 5000.
Queries performed:
(i) Display the bill details having bill amount less than 50000 or bill date with
28-jan-12.
(ii) Find all the bills where no. of items is not null.
(iii) Find all the bill details where Bill amount is between 1000 and 5000.
(iii) Find all the car details where car names have „u‟ in between.
(iv) Find the car details where car make not in the list [swift, innova, scorpio.
Table „CAR‟:
Queries Performed:
(ii) Find the list of cars whose owners have their names starting with „J‟ or „A‟ or
„S‟
(iii) Find all the car details where car names have „u‟ in between.
(iv) Find
the car
details
where car
make not
in the list
[swift,
innova,
scorpio.
Q.3 To perform queries for the table “SUPPLIER”.
(iii) Find all the supplier details where country is not given
Table „SUPPLIER‟:
Queries Performed:
(iii) Find all the supplier details where country is not given
Assignment – 7
(i) Display all the items manufactured in the year 2000 and 2010.
(ii) Display all the items whose price is between 500 and 1000.
(iii) Get the item details with price of every item added with 25.
Queries performed:
(i) Display all the items manufactured in the year 2000 and 2010.
(ii) Display all the items whose price is between 500 and 1000.
(iii) Get the item details with price of every item added with 25.
(iv) Get the item details with price of every item added with 25.
(i) Give the details of all patients whose first name starts with S.
(i) Give the details of all patients whose first name starts with S.
(i) Display all the test details except ECG and Liver Check.
(iii) Get the test details where the test_date is not null.
Creating the table:
Queries performed:
(i) Display all the test details except ECG and Liver Check.
(ii) Get the test details in descending order of Doctor_name.
(iii) Get the test details where the test_date is not null.
Assignment – 8
Q.1 To perform queries for the table “ITEM” using Aggregate Functions and DML
commands.
(i) Find the total price of all items in the ITEM table.
(ii) Change the item description and Stock on hand for the items manufactured in
the year 2010.
Queries performed:
(i) Find the total price of all items in the ITEM table.
(ii) Change the item description and Stock on hand for the items manufactured in
the year 2010.
Q.2 To perform queries for the table “PATIENT” using Aggregate Functions and
DML commands.
(i) Get the number of patients whose first starts with S.
Queries performed:
Q.3 To perform queries for the table “TEST” using Aggregate Functions and DML
commands.
Q.1 To perform queries for the table “ITEM” ,”PATIENT” and ”TEST” by the use
of different functions and to display the structure of DUAL TABLE.
(v) Display the patients names with 2 letters trimmed from left side
(vi) Display the patients names with 2 letters trimmed from right side.
(xii) Get the modulus, power, sign and square root of numbers and display the
output.
Queries performed:
(vi) Display the patients names with letters trimmed from right side.
To perform queries:
(ii) Alter the table to add Primary Key for column „ GuestID‟.
Now add some records which violate these constraints and note the error.
Creation of table:
Queries performed:
(ii) Alter the table to add Primary Key for column „ GuestID‟.
(iii) Include „UNIQUE‟ constraint to EmailID.
(iii) Delete the details of course „LLB‟. After that check records of both tables.
Creation of tables:
(i) ADD FOREIGN KEY „Course_code‟ to the STUDENT TABLE (with ON
DELETE CASCADE).
Before Deletion:
After Deletion:
Assignment – 12
Q.1 To perform queries for the table “STUDENT” using GROUP BY CLAUSE.
Queries performed:
(iii) Find the sum of credits, average of credits for different courses.
(iv) Find the subject having the maximum credits for course „BCA‟
Creation of table:
Queries performed:
(iv) Find the subject having the maximum credits for course „BCA‟.
(v) Create a view on SUBJECT selecting Subject_code, Subject_name and
Course_code.
Assignment – 13
Revision Exercise
Creation of table:
(ii) Find all the customers whose firstname has „a‟ in between.
(iii) Find the list of customers with their firstname and lastname together.
Creation of table:
Queries performed:
(ii) Find all the customers whose firstname has „a‟ in between.
(iii) Find the list of customers with their firstname and lastname together.
Assignment – 14
Revision Exercise
(i) Display customer names along with the length of the customer‟s firstnames.
(ii) Find all details of loans above 5 years or those loans with Fixed type.
(iii) Get the sum, average, maximum of loan amount with sum and average
rounded to 1 decimal place.
(v) Update the loan details of fixed type with loan period to 15.
(vi) Get the customer details of „Sharma‟ with customer code having one character
less from the left.
(vii) Get the Address of the customers with only a part of it.
Queris performed:
(i) Display customer names along with the length of the customer‟s firstnames.
(ii) Find all details of loans above 5 years or those loans with Fixed type.
(iii) Get the sum, average, maximum of loan amount with sum and average
rounded to 1 decimal place.
(v) Update the loan details of fixed type with loan period to 15.
(vi) Get the customer details of „Sharma‟ with customer code having one character
less from the left.
(vii) Get the Address of the customers with only a part of it.
INNER JOINS:
(i) Get the Loan details of customers whose name starts with „A‟.
(ii) Get the customer‟s firstname, lastname, address and phone number who have
taken a loan.
(iii) Get the loan_account_no, amount, type, customer‟s code, firstname and
lastname.
OUTER JOINS:
(v) Get all the LOAN records irrespective of whether customers have taken the
particular loans or not. (left outer join)
(vi) Get all the CUSTOMER records irrespective of whether customers have taken
loans or not. (right outer join)
Queries performed:
(i) Get the Loan details of customers whose name starts with „A‟.
(ii) Get the customer‟s firstname, lastname, address and phone numbers who have
taken a loan.
(iii) Get the loan_account_no, amount, type, customer‟s code, firstname and
lastname.
(v) Get all the LOAN records irrespective of whether customers have taken the
particular loans or not. (left outer join)
(vi) Get all the CUSTOMER records irrespective of whether customers have taken
loans or not. (right outer join)
(vii) Get the Cartesian product of LOAN AND CUSTOMER.
Assignment – 16
(i) Get all the Loan numbers from both the LOAN & CUSTOMER table.
(iii) Get the loan numbers which have not been allocated to customers.
CREATING INDEX
(ii) Create an index on the CUSTOMER table on customer‟s first and last name.
Queries performed:
(i) Get all the Loan numbers from both the LOAN & CUSTOMER table.
(ii) Get the Loan numbers common in both the tables.
(iii) Get the loan numbers which have not been allocated to customers.
CREATING INDEX
Q.1 To perform queries on Joins and Nested query and to create the following
tables.
DEPT_DETAILS(Deptno, Deptname, Managername)
Primary Key - Deptno
Queries:
(i) Get the details of employees whose salary is less than the average salary of
employees.
(ii) Get the details of employees whose salary is more than the average salary of
employees.
(iii) Get the details of employees whose salary is more than the salary of some of
the employees of „Marketing‟ dept.
(iv) Get the details of employees whose salary is more than the salary of all the
employees of „Marketing‟ dept.
(v) Get the details of employees who have at least one dependent.
(vi) Get the details of employees who have no dependents.
(vii) Get the details of employees who work in „Marketing‟ dept.
(viii) Get the sum, max, min, avg of salaries of employees of „Marketing‟ dept.
(ix) Get the count of employees in the „Marketing‟ dept.
Creation of tables:
“DEPT_DETAILS”:
“EMP_DETAILS”:
“DEPENDENT”:
Table “DEPT_DETAILS”:
Table “EMP_DETAILS”:
Table “DEPENDENT”:
Queries performed:
(i) Get the details of employees whose salary is less than the average salary of
employees.
(ii) Get the details of employees whose salary is more than the average salary of
employees.
(iii) Get the details of employees whose salary is more than the salary of some
of the employees of „Marketing‟ dept.
(iv) Get the details of employees whose salary is more than the salary of all the
employees of „Marketing‟ dept.
(v) Get the details of employees who have at least one dependent.