You are on page 1of 52

YASHODA TECHNICAL CAMPUS, SATARA, NAAC- B +

NH-4, Wadhe Phata, Satara. Tele Fax- 02162-271238/39/40


Website- www.yes.edu.in,mcahod_ytc@yes.edu.in
Approved by AICTE, DTE, Mumbai, Affiliated to DBATU Lonere, SUK/ MSBTE,

Faculty of MCA

CERTIFICATE

This is to certify that Mr. /M ________________________


Gaikwad Tejas Arun

_______________________________________________________ of class MCA-I


Examination Seat No___________________________ has completed all the practical work
in the Relational Database Management System, as prescribed by Shivaji University,
Kolhapur in academic year 2023 - 24 (Semester I )

Course In-charge External Examiner Principal/HOD

Place:

Date:
Name: Tejas Arun Gaikwad Date: 24-8-2023

Class: MCA-I Roll No: 05

Subject: RDBMS

Experiment No.1

Aim: To create table, insert data and view data

Theory:

Program: Create a table with table name organization

Query:

create table organization(


Emp_id int NOT NULL PRIMARY KEY,
Emp_Name varchar(30),
Emp_Address varchar(30),
Emp_salary int NOT NULL,
Emp_Qualification varchar(30),
Emp_mobileno int,
Emp_City varchar(30),
Emp_department varchar(30),
Emp_designation varchar(30),
Emp_ProjectName varchar(30) NULL
);

Output:

Faculty Of MCA
Program: Insert data into the table

Query:

insert into organization values(1, 'Akshay Patil', 'Mayni', 55000, 'MCA', 8784545748, 'Satara', 'Production',
'Production Supervisor', 'oragnic farming');

insert into organization values(2, 'Sourabh Wankar', 'Raviwar Peth', 55000, 'MCA', 9877588955, 'Satara',
'Production', 'Production manager', 'Yuva Nete Yojna');

insert into organization values(3, 'Sejal Randive', 'Raviwar Peth', 55000, 'MCA', 6699885535, 'Satara',
'Finance', 'Fianace Manager', 'footware System');

insert into organization values(4, 'Chetan Sutar', 'Swaroop Colony', 55000, 'MCA', 938355745, 'Satara', 'Sales',
'Sales manger', 'Furniture Manufacturing System');

insert into organization values(5, 'Neeraj Bhagat', 'Khalcha Rashta', 55000, 'MCA', 5456756477, 'Satara',
'Marketing', 'marketing manager', 'Hospital System');

insert into organization values(6, 'Nikhil shinde', 'Umbraj', 45000, 'MCA', 9566545445, 'Satara', 'Technical',
'Technical manager', 'Food Management System');

insert into organization values(7, 'Rohan salunkhe', 'Nagthane', 35000, 'MBA', 5679674711, 'Satara',
'Transportation', 'Transportation Manager', 'data encryption system');

insert into organization values(8, 'Kaustubh Dhone', 'Sahupuri', 45000, 'MBA', 9966558833, 'Satara', 'finance',
'cashier', 'web browser');

insert into organization values(9, 'Siddhart Bhange', 'Saniwar peth', 25000, 'MCA', 9566889944, 'Satara',
'Inventry', 'Inventry manager', 'Nursury System');

insert into organization values(10, 'Umair', 'Karanje', 25000, 'BCA', 9566544545, 'Satara', 'Miantenance',
'Miantenance manager', 'Vehicle Renting System');

Output:

Faculty Of MCA
Program: View data from the table

Query:

select * from organization

Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:25-8-2023

Class: MCA-I Roll No:05

Subject: RDBMS

Experiment No.2

Aim: To filter data from table

Theory:

Program: filter data from table

Query:

select Emp_id, Emp_Name, Emp_Salary from organization

Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:30-8-2023

Class: MCA-I Roll No:05

Subject: RDBMS

Experiment No.3

Aim: To sort data of the table

Theory:

Program: Sort Emp_id column in ascending order.

Query:

select * from organization order by Emp_id Asc;

Output:

Faculty Of MCA
Program: Program: Sort Emp_name column in ascending order.

Query:

select * from organization order by Emp_name Asc;

Output:

Program: Sort Emp_salary column in ascending order.

Query:

select * from organization order by Emp_salary Asc;

Output:

Faculty Of MCA
Program: Sort Emp_id column in descending order.

Query:

select * from organization order by Emp_id Desc;

Output:

Program: Sort Emp_name column in descending order.

Query:

select * from organization order by Emp_name Desc;

Output:

Faculty Of MCA
Program: Sort Emp_name column in descending order.

Query:

select * from organization order by Emp_mobileno Desc;

Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:31-8-2023

Class: MCA-I Roll No:05

Subject: RDBMS

Experiment No.4

Aim: To update and delete table contents

Theory:

Program: Update Emp_salary column

Query:

update organization set Emp_salary=33000 where Emp_id=5

Output:

Faculty Of MCA
Program: Update Emp_qualification column

Query:

update organization set Emp_qualification=’B.Tech’ where Emp_id=3

Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:1-9-2023

Class: MCA-I ROLL NO: 05

Subject :RDBMS

Experimemt No-5

Q5. Working with the table.

Insert :
INSERT INTO Stud4

(5,'kunal ahire','beed',7807558675,'ba');VALUES

Output:
Update:

Before updating the table :


select * from Stud4;

Output:

After updating the table


UPDATE table set Stud_Dept='MCA' where Stud_Dept='BCA';

Output:
Delete:

Before deleting the table:


select * from Stud4;

Output:

After Deleting the table:


delete from Stud4 where

Std_id=5;

Output:
Name: Tejas Arun Gaikwad Date:4-9-2023

Class: MCA-I ROLL NO: 05

Subject :RDBMS

Experimemt No-6

Q6. To Modify a table.

Before Modify the table:


select * from Stud4;

Output:

Adding the Column:


Alter table Stud4 Add Std_Category varchar(20);

Output:
Modify Column:
Alter table Stud4 Modify Std_Category varchar(10);

Output:

Drop Column:
Alter table Stud4 Drop column Std_Category;

Output:
Name: Tejas Arun Gaikwad Date:6-9-2023

Class: MCA-I ROLL NO: 05

Subject :RDBMS

Experimemt No-7

Q7. Create table from another table.

Old table (Stud4):


select * from Stud4;

Output:

New table (Exam_Details):


create table Exam_Details as(select * from Stud4);

Output:
Name: Tejas Arun Gaikwad Date:7-9-2023

Class: MCA-I ROLL NO: 05


Subject :RDBMS

Experiment No-8

Q8. Create table using primary key and foreign key.

PRIMARY KEY:
create table Supplier12

supplier_id int primary key,

Product_name varchar(20),

Product_Price int,

Product_Quantity int

);

Output:
FOREIGN KEY:
create table Order12

Order_No int primary key,

Order_name varchar(20),

Order_Price int,

Order_Quantity int, Order_city varchar(30),


supplier_id int,
foreign key (supplier_id) references Supplier12(supplier_id)

);

Output:
Name: Tejas Arun Gaikwad Date: 8-9-2023

Class: MCA-I ROLL NO: 05


Subject :RDBMS

Experiment No-9
Q9. Study of view and indexes in database.

Creating Views:
create view Supplier12_view as select product_name,product_price from Supplier12;

Output:
Updating Views:
update Supplier12_view set product_price=1500 where product_name='Grapes';

Output:
Deleting views:

Example:
delete from Supplier12_view where product_price=1500;

Output:
INDEXES IN DATABASE:

Creating index-
create index Supplier12_index on Supplier12(Supplier_id,Product_name);

Output:

Single-Column index-
create index Supplier12_index on Supplier12(Product_name);

Output:

Unique Index-
create unique index Supplier_index1 on Supplier12(Product_name);

Output:
Composite Index-
create index Supplier_index on Supplier12(Supplier_id,Product_name);

Output:

Dropping index-
drop index Supplier_index ;

Output:
Name: Tejas Arun Gaikwad Date:11-9-2023

Class: MCA-I Roll No : 05

Subject: RDBMS

Experiment No: 10

Title: WAP to find whether a number is less than or greater than 5

Theory:

Program:

DECLARE

a Number:=10;

BEGIN

IF a>5 THEN DBMS_OUTPUT.PUT_LINE('Number is greater than 5');

ELSE DBMS_OUTPUT.PUT_LINE('Number is less than 5');

END IF;

END;

Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:13-9-2023

Class: MCA-I ROLL NO: 05

Subject: RDBMS

Experiment No: 11

Title: WAP to perform various arithmetic opration.

Program:

declare

a number:=20;

b number:=10;

c number;

d number;

e float;

f number;

begin

c:=a+b;

d:=a-b;

e:=a/b;

f:=a*b;

dbms_output.put_line('the value of Addition is:' || c );

dbms_output.put_line('The value of Substraction is:' || d);

dbms_output.put_line('The value of Division is:' || e);

dbms_output.put_line('The value of Multiplication is:' || f);

Faculty Of MCA
end;

Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date: 14-9-2023

Class: MCA-I ROLL NO: 05

Subject: RDBMS

Experiment No: 12

Title: WAP to calculate sum of even numbers upto 10.

Theory:

Program:

DECLARE

num NUMBER(3) := 2;
sum1 NUMBER(4) := 0;
BEGIN
WHILE num <= 11 LOOP

dbms_output.Put_line(num);
sum1 := sum1 + num;
num := num + 2;
END LOOP;
dbms_output.Put_line('Sum of even numbers is ' || sum1);
END;

Faculty Of MCA
Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:05-9-2023

Class: MCA-I ROLL NO: 05

Subject: RDBMS

Experiment No: 13

Title: Write a program that uses datatype of sal from table.(%type attribute).

Theory:

Program:

create table gaurav157(eno number(10),ename varchar(10),sal number(10));

Output:

declare

salary gaurav157.sal%type;

begin

insert into gaurav157(eno,ename,sal) values(30,'aman',25000);

update gaurav157 set sal=sal+500 where eno=30;

select sal into salary from gaurav157 where eno=30;

dbms_output.put_line('salary updated by'||salary);

end;

Faculty Of MCA
select*from gaurav157;

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:29-9-2023

Class: MCA-I ROLL NO: 05

Subject: RDBMS

Experiment No: 14

Title: Write a program to insert employee code into employee table.(%rowtype attribute)

Theory:

Program:

declare

emp gaurav157%Rowtype;

begin

emp.eno:=3;

emp.ename:='gaurav';

emp.sal:=3000;

insert into gaurav157(eno,ename,sal)values(emp.eno,emp.ename,emp.sal);

dbms_output.put_line('record inserted in the table');

end;

Output:

Faculty Of MCA
select*from gaurav157

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:4-10-2023

Class: MCA-I ROLL NO: 05

Subject: RDBMS

Experiment No: 15

Title: WAP of pl/sql to check whether number is even or odd.

Theory:

Program:

DECLARE

n NUMBER := 2935;

r NUMBER;

BEGIN

r := MOD(n, 2);

IF r = 0 THEN

dbms_output.Put_line('Even');

ELSE

dbms_output.Put_line('Odd');

END IF;

END;

Faculty Of MCA
Output:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date: 5-10-2023
class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No.16
Aim : WAP to find grades of a student.
Theory :

Program :
declare
grd CHAR(1);
begin
grd:= ‘A’;
case grd
when ‘A’ then dbms_output. Put_line (‘Your Grade is: Outstanding’);
when ‘B’ then dbms_output.Put_line(‘Your Grade is: Excellent’);
when ‘C’ then dbms_output. Put_line (‘Your Grade is: Very Good’);
when ‘D’ then dbms_output. Put_line (‘Your Grade is: Average’);
when ‘F’ then dbms_output. Put_line( ‘Your Grade is: Poor’);
else dbms_output. Put_line (‘No such grade in the list.’);
end case;
end;

Output :

Conclusion :

Faculty Of MCA
.

Name: Tejas Arun Gaikwad Date: 6-10-2023


class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No.17

Aim : WAP a PL/SQL code to find greater number among three numbers.

Theory :

Program :
declare
a number := 50;
b number := 78;
c number := 75;
begin
if a b and a > c
then
dbms_output.Put_line (‘Greatest number is ’||a);
elsif b> a and b > c
then
dbms_output.Put_line(‘Greatest number is ’||b);
else
dbms_output. Put_line(‘Greatest number is ’||c);
end if;
end;

Output:

Conclusion :

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:9-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No.18
Aim: Write a PL/SQL code to remove problem in program 10.

Theory:

Program:

Declare
a number;
b number;
e number;
begin
b:=:b;
c:=-a/b;
dbms_output.put_line (‘C is:’ || c);
exception when zero_divide
then
dbms_output.put_line (‘division of any number by zero will raise a problem, verify input values.’)
end;
Output:-

Conclusion :-
Faculty Of MCA
Name: Tejas Arun Gaikwad Date:11-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No.19

Aim: Write a PL/SQL code which handles more than one exception.

Theory:

Program:
Declare
Name Employee1. Emp_Name%type;
begin
select Emp_Name into Name From Employee1 where Dept _No=60;
dbms_output.put_line (‘Employee name is: ’||Name);
exception
when zero_divide
then
dbms_output.put_line (‘Not Possible!’);
when too_many_rows then
dbms_output.put_line (‘More than 1 row is returned.’);
when others then
dbms_output.put_line (‘No data found.’);
end;

Output:

Conclusion:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:12-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No.20
Aim: Write a PL/SQL code which explains the usage of NO_DATA_FOUND exception.

Theory:

Program:
Declare
EName Employee1. Emp_Name%TYPE;
Emp_id1 Employeel. Emp_No%TYPE:=:Emp_No;
begin
SELECT Emp_Name INTO EName FROM Employee1
WHERE Emp No Emp_id1;
--show the customer name
dbms_output.put_line (‘Employee name is ’ || EName);
EXCEPTION
WHEN NO _DATA_ FOUND THEN
dbms_output.put_line (‘Employee’ || Emp_id1 || ‘does not exist ’|| ‘NO Data Found’);
end;

Output:

Conclusion :-

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:13-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No.21
Aim: Write a PL/SQL code that uses implicit cursor attributes Inthis program update
salary of employees, if the salary is notupdated then display message for that.

Theory:

Program:
declare
rows number (5);
begin
update Employee set Emp_Salary= Emp_Salary+1000;
if SQL%NOTFOUND
then
dbms_output.put_line(‘none of the salaries were updated’);
elsif SQL%FOUND
then
rows:= SQLXROWCOUNT;
dbms_output.put_line(‘salaries of ’ ||rows||‘ employee are updated’);
end if;
end;

Output:

Conclusion:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:16-10-23
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 22

Aim: write a pl/sql code that returns the total no. of rows that are updated using
ROW COUNT attribute.
Theory:

Program:

Declare
begin
update Employee1 set Emp_Salary= Emp_Salary*2 where Emp_No=3; dbms_output.put_line (‘record updated=
’|| SQL %ROWCOUNT);
end;

Output:

Conclusion:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:18-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 23

Aim: Write a PL/SQL code to delete a record from table, if delete operation
succeeds the insert operation.
Theory:

Declare
begin
delete from Employeel where Emp No :Emp_No;
if SQL%FOUND
then
dbms_output.put_line('Record found & deleted'); |
insert into Employeel values('Saurabh', 80, 15000,8);
else dbms_output.put_line('record not found');
end if;
end;

Output:

Conclusion:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:20-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 24

Aim: Create a user defined exception which checks the name of the employee is
bank during the insertion.If you left the name blank it will raise error.
Theory:

Program:
declare eno employeel. Emp_No%type;
name employeel.Emp_Name%Stype;
name exception exception;
begin
eno:=:eno;
name:=:name;
if name is null then raise name exception;
end if;
insert into employeel (Emp No, Emp Name) values (eno, name); dbms_output.put_line('Data entered into the
row.");
exception when name_ exception then
dbms_output.put_line('ename should not be empty.");
end;

Output:

Conclusion :-

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:26-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 25

Aim: Write a PL/SQL code to display the information of the employee table with
%NOTFOUND attribute.
Theory:

Program:
declare
eid employeel. Emp_No%type;
name employeel. Emp_Name% type;
salary employeel.Emp_Salary %type;
cursor cursor1 is select Emp No, Emp Name, Emp Salary from employee1;
begin
open cursor1;
loop
fetch cursor1 into eid, name, salary;
exit when cursor1%NOTFOUND;
dbms_output.put_line (‘emp_id =’ ||eid||‘ ’||‘emp_name’ || name|| ‘ ’ ||‘emp_salary=’ || salary);
end loop;
close cursor1;
end;

Output:

Conclusion:

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:05-10-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 26

Aim: Write a PL/SQL code to display the information of a given department.


Theory:

Program:
declare
cursor cursor2 is select Emp_No, Emp_Name, Emp_Salary from employeel where Dept_No= : Dept_No;
name employeel Emp Name type; eid empl. Emp_No%type;
salary employeel. Emp_Salary%type;
begin
open cursor2;
fetch cursory into name,eid, salary; exit when cursor2%NOTFOUND;
dbms_output.put_line(‘emp_id= ’||eid||‘ ’||‘emp_name=’||‘ ’ ||name||‘ ’||‘emp_salary=’||salary);
end loop;
close cursor2;
end;

Output:

Conclusion :-

Faculty Of MCA
Name: Tejas Arun Gaikwad Class: MCA-1
ROLL NO: 05 Date: 6-11-2023
Subject: RDBMS

Experiment No. 05
Aim :- Write a PL/SQL code to increase the salary of the employees if the post is of‘clerk’, his or her
salary will be doubled and if the post is of ‘salesman’ he or she will get the increment of 5%.

Theory:-

Program:-

Output :-

Faculty Of MCA
Name: Tejas Arun Gaikwad Date:8-11-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 28
Aim :- Write a PL/SQL code to find out the salary of an employeeif salary is less than
18000 of employee no.7, then add RS 1000 to the original salary of that employee.

Theory :-

Program :-

DECLARE
Salary NUMBER;
BEGIN
SELECT EMP_ Salary INTO Salary FROM Employee1 WHERE Emp_No=1;
IF
Salary<18500
THEN
GOTO tanuja:
ELSE
DBMS_OUTPUT.PUT_LINE(‘SALARY IS’ ||Salary);
END IF;
<<tanuja>>
UPDATE Employee1 SET Emp_Salary=Emp Salary+1000 WHERE Emp_No=1;|
END;
/

Output :-

Conclusion :-

Faculty Of MCA
Name: Tejas Arun Gaikwad Date: 20-11-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 29

Aim :- Write a PL/SQL code to find out factorial of a number.


Theory :-

Program :-
Declare
N number;
I number:=1;
FACT NUMBER:=1;
BEGIN
N:=:N;
WHILE I<N LOOP
FACT:= FACT *I;
DBMS_OUTPUT.PUT_LINE(‘FACTORIAL IS=’ ||FACT);
END LOOP;
END;

Output :-

Faculty Of MCA
Name: Tejas Arun Gaikwad Date: 22-11-2023
Class: MCA-1 ROLL NO: 05
Subject: RDBMS

Experiment No. 30
Aim :- Write a PL/SQL code to perform arithmetic operations on some data.

Theory :-

Program :-

DECLARE
A NUMBER;
B NUMBER;
C NUMBER;
D NUMBER;
BEGIN
A:=:A
IF D=1
THEN
C:=A+B;
ELSIF
D=2
THEN
C:=A-B
ELSIF
D=3
THEN
C:=A*B
ELSIF
D=4
THEN
C:=A/B
DBMS_OUTPUT.PUT_LINE(‘ENTER VALID NUMBER’);
END IF;
DBMS_OUTPUT.PUT_LINE(‘C|| IS THE RESULT’);
END:

Faculty Of MCA
Output :-

Conclusion :-

Faculty Of MCA

You might also like