0% found this document useful (0 votes)
13 views13 pages

Databaselab - Cse37

The document outlines a series of database lab assignments for KIIT University, including tasks such as creating tables, inserting data, retrieving records, and performing updates. It covers various SQL operations like creating views, sequences, and indexes, as well as executing queries for data manipulation. The assignments are structured in a step-by-step format, guiding students through practical applications of database management concepts.

Uploaded by

Avipsa Basu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views13 pages

Databaselab - Cse37

The document outlines a series of database lab assignments for KIIT University, including tasks such as creating tables, inserting data, retrieving records, and performing updates. It covers various SQL operations like creating views, sequences, and indexes, as well as executing queries for data manipulation. The assignments are structured in a step-by-step format, guiding students through practical applications of database management concepts.

Uploaded by

Avipsa Basu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

KIIT UNVERSITY

DATABASE LAB ASSIGNMENT

ASSIGNMENT-1

1. Create the following table according to the following information

i) Table name- DEPOSIT(roll number)

FIELD NAME DATA TYPE SIZE


ACTNO VARCHAR2 5
CNAME VARCHAR2 20
BNAME VARCHAR2 20
AMOUNT NUMBER 8,2
ADATE DATE

ii) Table name-BRANCH(roll number)

FIELD NAME DATA TYPE SIZE


BNAME VARCHAR2 20
CITY VARCHAR2 20

iii) Table name-CUSTOMER(roll number)


FIELD NAME DATA TYPE SIZE
CNAME VARCHAR2 20
CITY VARCHAR2 20

iv) Table name-BORROW(roll number)


FIELD NAME DATA TYPE SIZE
LOANNO VARCHAR2 5
CNAME VARCHAR2 20
BNAME VARCHAR2 20
AMOUNT NUMBER (8,2)

2. Describe the tables which are already created.

3. Insert the data as for the following

i) DEPOSIT(roll number)

ACTNO CNAME BNAME AMOUNT ADATE


100 ANIL VRCE 1000.00 01-MAR-95
101 SUNIL AJNI 5000.00 04-JAN-96
102 RAHUL KAROLBAGH 3500.00 17-NOV-95
103 MADHURI CHANDNI 1200.00 17-DEC-95
104 PRAMOD MGROAD 3000.00 27-MAR-96
105 SANDIP KAROLBAGH 2000.00 31-MAR-96
ii) BRANCH(roll number) iii) CUSTOMER(roll number)

BRANCH CITY CNAME CITY


VRCE NAGPUR ANIL CALCUTA
AJNI NAGPUR SUNIL DELHI
KAROLBAGH DELHI RAHUL BARODA
CHANDNI DELHI MADHURI NAGPUR
MGROAD BANGALORE PRAMOD NAGPUR

iv)BORROW(roll number)
LOANNO CNAME BNAME AMOUNT
201 ANIL VRCE 1000.00
206 RAHUL AJNI 5000.00
311 SUNIL DHARAMPETH 3000.00
321 MADHURI ANDHERI 2000.00
375 PRAMOD VIHAR 8000.00

2
ASSIGNMENT-2

1. Retrieve the details from the table DEPOSIT(roll number)


2. Calculate TA(10% of amount),DA(20% of amount) and TOTAL of each customer from
BORROW(roll number) table also project CNAME & AMOUNT.
3. Retrieve the customer name, account no of DEPOSIT(roll number).
4. Retrieve the name of the customer living in NAGPUR.
5. Retrieve the name of the customers who opened account after 17-NOV-95.
6. Retrieve the account number and amount of the customer having account opened between 01-12-95
and 01-06.96.
7. Retrieve all the records from the table DEPOSIT(roll number) where CNAME begins with C..
8. Retrieve all the records from the table BORROW(roll number) where 2nd character of CNAME is U.
9. Retrieve all the records from the table DEPOSIT(roll number) where branch name is CHANDNI or
MGROAD.
10. Retrieve all the records from the table DEPOSIT(roll number) where branch name is not in
CHANDNI or MGROAD.
11. Retrieve all the records from the table BORROW(roll number) where amount in between 2000 and
3000.
12. Retrieve all the records from DEPOSIT(roll number). where amount > 1000 and arrange the customer
name in ascending order.
13. Retrieve all the records from BOOROW(roll number) where amount>1000 and arrange customer
name in ascending and branch name in descending order.
14. Find out the tables which are created by the user.
15. Retrieve customer details from BORROW(roll number) table where the third character of the customer
name is either ‘A’ or ‘D’.
16. Retrieve all the records from the table BORROW(roll number) where amount is not between 2000
and 8000.
17. Find out the unique records from the table DEPOSIT(roll number).

3
ASSIGNMENT-3

1. Update the amount of all depositors in deposit table by giving them 10% interest (i.e. amount=amount
* 0.1) where branch is VRCE.
2. Update the amount of all depositors in deposit table by giving them 10% interest where branch is
VRCE and customer name ANIL.
3. Create table STUDENT and insert the following data :-

. FIELD DATA TYPE NAME ROLLNO BRANCH CITY


. NAME VARCHAR(20) VIJAYA 150 CSE CHENNAI
. ROLLNO NUMBER(10) SITA 202 ETC KOLKATA
. BRANCH VARCHAR2(20) RAVI 300 EEE DELHI
. CITY VARCHAR2(20) BASU 165 ETC CHENNAI
RASMI 107 ETC RKL
KARAN 111 CSE CTC
REKHA 117 BME BBSR
4. Count the number of students of each department.
5. Count the number of students of each department where the department name starts with ‘E’.
6. Delete all rows from the table STUDENT where branch is ETC.
7. Rename the table STUDENT to STUDINFORMATION.
8. Add a field called MARKS to the table STUDENT which can hold a number upto 8 digit length.
9. Modify the field :”NAME” of the table STUDENT to hold a maximum of 25 character.
10. Delete a field called marks from STUDENT table.
11. Delete all the data part from the table STUDENT.
12. Destroy the table STUDENT.
13. List total deposit from DEPOSIT table
14. List total deposit of customer having account date after 04-jan-96.
15. Count number of customer cities.
16. Retrieve maximum loan from branch VRCE.

4
ASSIGNMENT-4

1. Calculate 10*10.
2. Display system date.
3. Calculate the absolute value of -20.
4. Calculate 10^10.
5. Calculate square root of 25.
6. Round the value 23.565 to one places of decimal.
7. Display ‘TRIDENT’ in lowercase.
8. Display ‘trident’ in uppercase.
9. Display the first letter of your name in uppercase.
10. Calculate the length of your name.
11. Write a query that would return a string like “ORA” , if the string inputted is ‘ORACLE’.
12. Find the character position of ‘C’ in the string ‘ORACLE’.
‘ORACLE
13. Delete the extra spaces from the strings ‘ ORACLE’ and ‘ORACLE
14. Write a query that would display **ORACLE, if the string inputted is ORACLE.
15. Same as question 14 but the output is ORACLE**.
16. Retrieve the last month specified in system date.
17. Retrieve number of months between 01-01-07 to 01-05-07.
18. Round 56.23 using negative numbers(e.g.-1,-2, and-3)
19. Find out the remainder of the division 1600/300.
20. Find the maximum and minimum number from a list of numbers.

5
ASSIGNMENT-5

1. Create a table called PRODUCT


FIELD DATA TYPE
PRODUCTNO VARCHAR2(10)
QTY_ORDER VARCHAR2(10)
RATE NUMBER(10,2)
Use the attribute PRODUCTNO as column level Primary key.

2. Create a table called CLIENT


FIELD DATA TYPE
CLIENTNO VARCHAR2(10)
NAME VARCHAR2(10)
CITY VARCHAR2(10)
SALARY NUMBER(10,2)
Such that the contents of the column CLIENTNO are unique across the entire column.

3. Create a table called EMPLOYEE


FIELD DATA TYPE
EMPNO VARCHAR2(10)
FNAME VARCHAR2(10)
MNAME VARCHAR2(10)
LNAME VARCHAR2(10)
EMPNO must start with capital letter ‘E’. Data value inserted into the column FNAME, LNAME
should only be in upper case.

4. Create a table called CLIENT1


FIELD DATA TYPE
CLIENTNO VARCHAR2(10)
NAME VARCHAR2(10)
SALARY NUMBER(10,2)
ADDRESS VARCHAR2(10)
Such that CLIENTNO,NAME columns are NOT NULL.

5. . Create a table called SALESORDERDETALS with its primary key as DORDERNO. The foreign
key is ORDERNO of the table SALESORDER referencing to the column DORDERNO in the table
SALESORDERDETAILS in table level concept.

SALESORDERDETAILS table. SALESORDER table.


FIELD DATA TYPE FIELD DATA TYPE
DORDERNO VARCHAR(10) ORDERNO VARCHAR(10)
PRODUCTNO VARCHAR(10) ORDERDATE DATE
QTYORDER NUMBER (8,2) CLIENTNO VARCHAR(10)
RATE NUMBER(10,2) ORDERSTATUS VARCHAR(10)

6
6. Apply on delete cascade..

7. Apply on delete set null.

8. Add a primary key constraint on the column FNAME of the table EMPLOYEE.

9. Add a foreign key on the column ORDERNO belonging to the table SALESORDER10 which refers
to the table SALESORDERDETAILS. Modify column PRODUCTNO to include UNIQUE constraint.

10. Drop primary key constraint from the table EMPLOYEE.

11. Drop the foreign key constraint on the column CLIENTNO in the table SALESORDER10.
SALESORDER10 table

FIELD DATA TYPE


ORDERNO VARCHAR2(10)
PRODUCTNO VARCHAR2(10)
QTYORDER NUMBER(8,2)
RATENUMBER(10,2)

7
Assignment-6

Sub-query

1. List all the depositors having deposit in all the branches where SUNIL is having branch.
2. Retrive the account and amount of all the depositors living in city NAGPUR.
3. List the cities of depositors having branch as ‘KAROLBAGH’.
4. List all the cities where branches of Anil & Sunil are located.
5. List all the customer Name,Amount of depositors living in city where Anil or Sunil is living.

View
Emp_Company
ENAME CNAME SALARY JDATE
ANIL ACC 1500 01-MAY-89
SANKAR TATA 2000 10-JUL-90
JAYA CMC 1800 07-JUN-91
SUNIL CMC 1700 01-JAN-88
VIJAY TATA 5000 03-JAN-88

6. Create a view foe retrieving company name its average salary, maximum salary & minimum salary.

7. Create a view called Emp_Company_Details from Emp_Company that includes all the attributes of
Emp_Company.

8. Retrive the contents of the view called Emp_Company_Details..

9. Insert into the view Emp_Company_Details.

ENAME CNAME SALARY JDATE


PRAKASH TATA 3000 27-MAY-89
AJAY ACC 8000 30-APR-95

10. Update the content of SALARY to 10000 in the view called Emp_ompany_Details where ENAME
is Prakash.

11. Delete the record from the view Emp_Company_Details where ENAME is Prakash.

Self-Join
Insert the following date into the table Employee
ENAME CITY
ANIL NAGPUR
SANKAR BOMBAY
JAYA MADRAS
SUNIL BOMBAY
VIJAY DELHI
PRAKASH CALCUTTA
AJAY MADRAS
8
12. List the employee living in the same city where SUNIL is living.

13. From the following table retrive the name of employee & the name of respective manger

EMPOYEE Table
EMPNO NAME MGRNO
10 ASHOK 11
11 RAVI 12
12 SUMIT 13

Equi-Join

14. Retrive the name of customers from deposit table having the living city same as their branch city.

15. Retrive the name of borrowers havin deposit amount greater than 1000 and loan amount greater than
2000.

16. Retrive the name of customer having living city BOMBAY and branch city NAGPUR.

17. Retrive the branch city and living city of PROMOD .

18. Retrive the loanNo, Loan amount, account no, deposit amount of customers living in city Nagpur.

9
Assignment-7
1. Create an English sentence by joining string values with column data retrieved
from the deposit table i.e
Print customer {cname} having accountno {actno} in branch {bname} has deposited
{amount}on {adate} from deposit table.

2. Print Borrow {cname} having accountno [loanno} has taken{amount}loan from {bname}
from borrow table.

3. 3.Print Customer {cname} resides in {city} from Customer table.

4. 4.Print Branch {bname} is in {city} from branch table.

5. 5.Retrived the deposit information table actno, cname, bname, amount for all the deposits
placed by the customer in ascending order of adate . The adate should be displayed in
‘DD/MM/YY’ format.

6. Display the date in ‘ DD/MM/YY’ format.

7. Display the date in ‘DDSP’ format.

8. Display the date in ‘DDSPTH’ format.

9. 9.Retrive the employee of company ‘ACC ‘and ‘TATA’(Union Operation).

10. 10.Retrive the name of employee which is common to both the company ‘ACC’ and ‘TATA’.

11. Retrive the name of employee where ‘ACC’ is located but not ‘TATA’.

12. 12.list all the customers who are deposited but not borrowers.

13. List all the customers who are deposited and borrowers.

10
ASSIGNMENT-8

1. Create a Sequence having name SQ which ranges from 0 to 100 incremented by 2.

2.Create a decrementing sequence based on the data of Q1.

3.Create a view DEPO_VIEW of table DEPOSIT having columns ACTNO , CNAME.

4.Use the above sequence SQ to insert values into actno column of above created view.

5.Alter the Sequence SQ from maximum value 100 to 150.

6. List the name of created sequences.

7. Drop the created Sequence SQ.

8.Create a simple index on BNAME column accepting duplicate values for DEPOSIT table.

9. Create an simple index on ACTNO column not accepting duplicate values for DEPOSIT
table.

10.Create an composite index on CNAME, BNAME allowing duplicate values for BORROW
table.

11. Create an composite index on LOANNO, BNAME not allowing duplicate values for
BORROW table.

12.Select the list of indexes.

13. Drop the above created index.

14.Create a Synonym DEPO_SYN for the table DEPOSIT.

15. Insert the following data into the synonym.

ACTNO CNAME BNAME AMOUNT ADATE


100 ANIL VRCE 1000.00 01-MAR-95
101 SUNIL AJNI 5000.00 04-JAN-96
102 RAHUL KAROLBAGH 3500.00 17-NOV-95

11
16. Update the amount of all depositors in the synonym DEPO_SYN by giving them 10%
interest where branch is AJNI

17.Delete all rows from the synonym DEPO_SYN where branch is VRCE.

18. List the created synonym names.

19. Drop the created Synonym DEPO_SYN.

20. Delete the first three records from DEPOSIT table using ROWNUM.

Assignment – 9
1. Write a PL/SQL block that accept an integer value and prints that value.

2. Write a PL/SQL block to calculate the area of a triangle by accepting the base and
height.

2. 3. Write a PL/SQL block to calculate the area of a rectangle, store the length, breadth
and the corresponding value of the calculated area in the table called rectarea.

1. Write a PL/SQL block to print 1,2,3,………….10 by using basic loop.

2. write the program as in question 4. by using for loop.

3. Write a PL/SQL block to calculate the area of a circle for a value of radius varying from
r=2 to r=5.

4. Write a PL/SQL block to print 10,9,8,7,…………..1

5. Write a PL/SQL block to calculate s:=1+2+3+………….+100.

6. Write a PL/SQL statement to add odd numbers and multiply even number between 1-
50.

7. Write a PL/SQL code to print the reverse of a number.

8. Write a PL/SQL code to print the reverse of a word.

12
ASSIGNMENT- 10

1. Write a PL/SQL code which will display ACTNO,CNAME of any CUSTOMER


entered by the user and calculate the interest depending upon the following condition.
If amount >2000 then INTEREST=amount * 30% of amount
If amount >1500 then INTEREST = amount * 20% of amount
If amount >1000 then INTEREST = amount * 10% of amount
If amount >500 then INTEREST =0.
2. Write a PL/SQL code that will accept an account number from the user and debit an
amount of Rs 1000 if the account has a balance greater than Rs 2000. The process is to
be fired on the DEPOSIT table.
3. Write a PL/SQL code to calculate the area of the circle &n insert it into the table
called calcarea if area>30.
4. Write a PL/SQL block to display the ACTNO,BNAME,AMOUNT of the customer
whose name is RAHUL . The process is to be fired on the DEPOSIT table.
5. Do the same as Q.5 but accept the name of customer in run time.
6. Write a PL/SQL code to print the factorial of a number.

13

You might also like