Uploaded by Merin Chacko

DBMS Lab Questions

advertisement
Experiment No: 1
Employee Database
Date: 13/02/2014
Aim:
Create the following Tables
Tab1
COLUMN
DATATYPE
LENGTH
ID
CHAR
20
NAME
CHAR
20
AGE
NUMBER
2,0
Tab2
COLUMN
DATATYPE
LENGTH
SID
CHAR
10
SALARY
NUMBER
5,2
DESTINATION
CHAR
20
COLUMN
DATATYPE
LENGTH
TAB1.ID
CHAR
20
TAB1.NAME
CHAR
20
TAB2.SALARY
NUMBER
25,2
Tab3
1) Add new column into tab3named dept char(20)
2) Modify name with kname
3) Delete tab1
4) Delete tab2
5) Delete tab3
Experiment No: 2
Employee Database
Date: 13/2/2014
Aim:
Create the following table
TAB1
COLUMN
DATATYPE
LENGTH
EMPID
NUMBER
3,0
EMPNAME
CHAR
30
EMPADD
CHAR
30
EMPPHONE
CHAR
10
DOB
DATE
TAB2
COLUMN
DATATYPE
LENGTH
EMPSID
NUMBER
3,O
EMPBP
NUMBER
8,2
EMPHRA
NUMBER
8,2
EMPDEPT
CHAR
30
DATATYPE
LENGTH
TAB3
COLUMN
TAB1.EMPID
TAB2.EMPSID
TAB1.EMPNAME
TAB2.EMPDEPT
1) Modify the size empname in TAB3 to 50
2) Add new column salary in TAB3 with data type number(8,2)
3) Add 5 records of data in TAB3
4) List all data from TAB3
5) List all data from TAB3 where salary>=50000
6) List empid and empname from tab3 where empname= ram and salary=9000
7) List all data from tab3 where salary between 5000 and 9000;
Experiment No: 3
Customer Database
Date: 15/2/2014
Aim:
Create a table customer with the following fields:customer_id,name,branch,acc_no and
balance.customer_id is the primary key.All the other fields cannot enter null value and the balance
should not be less than 5000.
(1) Find out the details of all customers whose balance is between 10,000 & 20,000.
(2) Show all branches of the bank and eliminate duplicate records.
(3) Find out the details of all customers whose branch is kottayam and balance greater than 10,000.
(4) Find out all the customer_id ,acc_no,name of all customers in the bank.
(5) Show the details of customers whose name starts with ‘A’.
(6) Find the total balance of the bank.
(7) Retrieve the branch name values as city.
(8) Find the average balance of the bank.
(9) Find the maximum value for balance.
(10) Find the minimum balance of the bank.
(11) Count number of records in the table.
Experiment No: 4
Student Database
Date: 18/2/2014
Aim:
Create a table Student with the following fields:rollno,name,mark1,mark2,mark3 and place.
rollno is the primary key.All the other fields should not contain null ,maximum mark is 100.
(1) Print the list of students whose mark3>80.
(2) Find the names of all students having ‘A ‘as their second letter in their names.
(3) Delete the details of students who come from Kollam.
(4) Add a new attribute tele_no of datatype char and size 10.
(5) Count and show the number of distinct names in student table.
(6) List the name,rollno of students who are not in Trivandrum.
(7) Find the list of all students whose all mark>=60 & <80.
(8) Sort students according to their names.
(9) Print name,mark1,mark2,mark3 and total of each student.
(10) Print rollno,name and total of all students whose average mark>=80.
EXPERIMENT N0: 5
Staff Database
Date: 18/3/14
Aim
Create staff table with the following fields staff_name,staff_id,department,and age.Staff id is the
primary key, age field should greater then 25 and less than 75, all field not be null.Insert the data.
Staff_name
Staff_id
Department
Age
Arun
A101
CS
Ajesh
A201
IT
50
Anil
A403
EC
45
Sunil
A901
EE
58
Aji
A501
CS
34
Harish
A106
ME
33
1)
30
Alter the table by adding a colum DOB and insert into that field.
2) Change the staff table and set age field to 60 corresponding staff id is A403.
3) Display the staff information only in CS department.
4) Delete records from the table whose age <35.
5) Display staff id,staff name from staff table in reverse order of their age.
6) Display all staff information from the table renaming the field staff_name as name and
department as dept.
7) Display all staff name whose age>35.
8) Display the average of the total age of the staff.
9) Display all staff name in upper case and department in lower case.
10) Increment the age of all staff with 1.
Experiment No: 6
Student Database
Date: 19/2/2014
Aim:
Create a table student with following fields roll no int (primary key), Name char (20) not null, sex char (1)
accept only m or f, dob date not null, course (values must be MCA, CSE ME), sem(values must be S3, S4).
Create second table marks with following data Mid in (primary key), roll no int (foreign key) referencing
student tables). Sub_code char (5) not null and marks int not null (>=0 & <=100). Insert the data into
these tables.
1) List the name of students joined in mca.
2) List the name of students who are not in CS department.
3) List the names of students whose names start with ‘E’ and ‘P as 3rd character
4) List all marks of the students Robert from MCA.
5) List all roll no from two table (avoid duplicate roll no).
6) List all roll no which is common in both tables.
7) List name from student table and all marks from marks of roll no 23 in student table.
8) List the roll no and total marks of each roll no from mark table.
9) Display name and roll no of students, where marks are entered in marks table.
10) Display the name, roll no, sex, dob, sub_code and mark of highest subject mark.
Experiment No:7
Customer Sale Database
Date: 23/3/2014
Aim:
Database schema for a customer sale database scenario
customer(cust_id,cust_name) primary key(cust_id).
Item(item_id,item_name,price) primary key(item_id)
Sale(bill_no,bill_date,cust_id,item_id,qty_sold) primary key(bill_no),foreign key(cust_id),foreign
key(item_id).
1) Create the tables with appropriate integrity constraints.Insert around 10 records in each of the
tables.
2) List all the bills for the current date with the customer name and item_no.
3) List the total bill detail with the quantity sold,price of the item and final amount.
4) List the details of the customer who have brought a product which has a price>200.
5) Give a count of how many product have been brought by each customer.
6) Give a list of product brought by a customer having cust_id as 5.
7) List the item details which are sold as of today.
Experiment No : 8
S3MA Student Database
Date: 25/03/14
Aim:
Create table S3MCA (rollno,name,sex,age,phone,f_name,m_name,m1,m2,m3,m4,m5) primary key
(rollno).
Create table HouseDetails (rollno,housename,hid,place,dist,pin) primary key (hid),foreign key( rollno)
1) Insert 4 rows of data in each table
2) Create a view view1 from S3MCA (rollno,name,phone)
3) Describe the view view1
4) Insert one row of data in view1
5) Create a view view2 S3MCA with all columns with condition sex=’m’
6) Create a view view3 from S3MCA and housedetails (rollno,name,housename,place,dist)
7) Describe view3
8) Create a view view4from view3(rollno,plce,dist)
9) Describe view4
Experiment No: 9
Sales Database
Date : 3/04/2014
Aim:
Create table of sale order with following fields: Order Number(Unique key begins with 0),Client
number(FK),Order Date.
Create table clientmaster with following fields: clientno(PK), cname,city.
Create table salesmaster with following fields: salesmanno(PK),sname,city.
Add 5 rows of data in 3 tables
a)Retrieve all orders placed by a client named sajan.
b)Retrieve the names of all clients and salesman in the city of mumbai.
c)Retrieve the order number, cname, order date from client master and sales order table.
Experiment No:10
College Database
Date: 03/04/2014
Aim:
Branch(branch_id,branchName).
Create following tables
College(College_id,College Name).
Seats(seat_id,college_id,branch_id,total No of seats filled).
FK(college_id,branch_id).
Add 5 colleges.
Add 5 branches.
Add Details in seats table.
a)Find the name of colleges and baranch in which no seats are left.
b)Find the name of college and branch in which no seats are filled.
c)Find the all branch name of college name ‘AJCE’.
d)List all the college name in which CS branch is there?
Experiment No: 11
Reverse A Given Number
Date: 29/04/2014
Aim:Write a PL/SQL program to reverse a given number
Experiment No :12
Number Is Prime Or Not
Date: 29/04/2014
Aim:-
Write a PL/SQL program to check the given number is prime or not.
Experiment No: 13
Display The Pattern
Date: 27/05/14
Aim :
Create a PL/Sql program to display the pattern.
1
12
1 2 3…n
Experiment No: 14
Display The Prime Number Upto A Limit
Date: 27/05/14
Aim:
Create a PL/Sql program to display the prime number upto a limit.
Download