0% found this document useful (0 votes)
110 views

List of Experiments/Excercises: Name of The Lab:DBMS Program:BCA Branch:BCA

The document describes experiments to be performed in a Database Management Systems lab. It includes 3 experiments: 1. Creating a Student Records table and inserting 10 records with primary key. 2. Creating an Item table and writing SQL queries to select item names, items between a price range, and total number of items. 3. Given a Department Information table, writing SQL queries to update a record, delete a record, add columns, and drop a column.

Uploaded by

Tanmay Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

List of Experiments/Excercises: Name of The Lab:DBMS Program:BCA Branch:BCA

The document describes experiments to be performed in a Database Management Systems lab. It includes 3 experiments: 1. Creating a Student Records table and inserting 10 records with primary key. 2. Creating an Item table and writing SQL queries to select item names, items between a price range, and total number of items. 3. Given a Department Information table, writing SQL queries to update a record, delete a record, add columns, and drop a column.

Uploaded by

Tanmay Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 28

Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

LIST OF EXPERIMENTS/EXCERCISES
1. Create a Table Student_records (Student_RollNo, Student_Name, Father’s Name, Branch, Section,

Year) and insert minimum 10 records in this Student_records Table with Primary Key (Student_RollNo).

Create Table Student_Records

Student_RollNo char(10),

Student_Name char(20),

FatherName char(20),

Branch char(10),

section char(10),

Year char(10),

primary key(Student_RollNo)

);

Insert into Student_Records values(12,'rahul','rohit','BCA','A','1st');

Insert into Student_Records values(13,'sourabh','raj','BCA','A','1st');

Insert into Student_Records values(14,'ankit','sajan','BCa','B','1st');

Insert into Student_Records values(15,'gaurab','kunal','BCA','A','1st');

Insert into Student_Records values(16,'sajan','sandeep','BCA','B','1st');

Insert into Student_Records values(17,'sachin','sanju','BCA','A','1st');

Insert into Student_Records values(18,'abhey','aman','BCA','B','1st');

Insert into Student_Records values(19,'pankaj','aman','BCA','A','1st');

Select * from Student_Records;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

2. Create a Table ITEM (Item_code, Item_name, Item_qty,Item_price,Item_ManufacturingDate).Find the following


query in SQL:

a. Find Item_name from this table

b. Find the Items which have Price between 1000 and 5000.

c. Find Total Number of Item of this table.


Programme:
Create Table ITEM
(
Item_code char(20),
Item_name char(20),
Item_qty char(20),
Item_price char(20),
Item_ManufacturingDate char(20)
);
Insert into ITEM values(01,'Item 1','1','1000','04-09-2020');
Insert into ITEM values(02,' Item 2','2','5000','12-12-2020');
Insert into ITEM values(03,' Item 3','7','100','01-01-2021');
Insert into ITEM values(04,' Item 4','5','3000','19-04-2021');
Insert into ITEM values(05,'Item 5','3','2000','12-01-2021');

Select * from ITEM ;

/* sql query */

/*a*/ SELECT Item_name from ITEM;


Select * from ITEM ;

/*b*/ SELECT Item_name FROM ITEM WHERE Item_price BETWEEN 1000 AND 5000;
Select * from ITEM ;

/*c*/ SELECT Count(Item_name) FROM ITEM;


Select * from ITEM ;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

3. Given a Table Department_Information

Department_ID Department_Name Department_Location

101 MCA AA

102 MBA CC

103 B.Tech BB

104 B.Pharma DD

105 B.Arch FF

106 BCA GG

Find the following query in SQL:

a. Change the Location of Department, B.Pharma from DD to MM.

b. Delete a Record form this table which hasDepartment_Location=GG.

c. Add a Column Department_PhoneNo in this table.

d. Add a Column Department_Address in this table

e. Delete a column Department_Location from this table.

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Create Table Department_Information


(
Department_ID char(20),
Department_Name char(20),
Department_Location char(20)
);

Insert into Department_Information values(101,'MCA','AA');


Insert into Department_Information values(102,'MBA','CC');
Insert into Department_Information values(103,'B.Tech','BB');
Insert into Department_Information values(104,'B.Pharma','DD');
Insert into Department_Information values(105,'B.Arch','FF');
Insert into Department_Information values(106,'BCA','GG');

Select * from Department_Information ;

/*a*/
Update Department_Information set Department_Location = 'MM' where Department_Name =
'B.Pharma' ;

Select * from Department_Information;

/*b*/
Delete from Department_Information where Department_location= 'GG' ;
Select * from Department_Information;

/*c*/
Alter table Department_Information Add Department_phoneNo Numeric(10);

Insert into Department_Information values(101,'MCA','AA','8854673219');


Insert into Department_Information values(102,'MBA','CC','6875329013');
Insert into Department_Information values(103,'B.Tech','BB','6754239801');
Insert into Department_Information values(104,'B.Pharma','DD','7895342178');
Insert into Department_Information values(105,'B.Arch','FF','7692134508');
Insert into Department_Information values(106,'BCA','GG','7654321977');
Select * from Department_Information;

/*d*/
Alter table Department_Information add Department_Address char(20);

Insert into Department_Information values(101,'MCA','AA','8854673219','Vedanta ');


Prepared by: aman.kaushik Reviewed by: Approved by:
Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Insert into Department_Information values(102,'MBA','CC','6875329232','Vishwakarma');


Insert into Department_Information values(103,'B.Tech','BB','672244201','Charankiya');
Insert into Department_Information values(104,'B.Pharma','DD','3495342178','Vedanta');
Insert into Department_Information values(105,'B.Arch','FF','76134508','Vastu');
Insert into Department_Information values(106,'BCA','GG','765477','Vishwakarma');
Select * from Department_Information;

/*e*/
Alter Table Department_Information drop Department_Location;
Select * from Department_Information;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

4. Create a Table Employee_Salary

(Emp_id,Emp_Name,Emp_Salary,Emp_Designation)

Find the following query in SQL:

a. Find the name of employee which is getting minimum salary

b. Find the name of employee which is getting Maximum salary

c. Find the name of employee which has salary more than 10000.

d. Find the name of employee which has salary >25000

e. Find the Total Salary of all Employees.


Programme:

create table employee_info


(
emp_id numeric(6),
emp_name char(20),
emp_city char(20),
emp_contact_info numeric(10),
emp_salary numeric(20),
emp_designation char(20),
primary key (emp_name)
);
--insert some values
insert into employee_info values(1,'ajay','dehradun',9796569,100,'worker');
insert into employee_info values(2,'rahul','dehradun',9796679,1000,'worker');
insert into employee_info values(3,'anuj','dehradun',9796678,120000,'worker');

--(a)

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

select emp_name from employee_info where emp_salary in


(select min(emp_salary) from employee_info);

--(b)
select emp_name from employee_info where emp_salary in
(select max(emp_salary) from employee_info);

--(c)
select emp_name from employee_info where emp_salary > 10000;

--(d)
select emp_name from employee_info where emp_salary > 25000;

--(e)
select emp_id,sum(emp_salary) as 'total salary' from employee_info

5. Write a Program to Create, update, drop, and alter view Operation.


Prepared by: aman.kaushik Reviewed by: Approved by:
Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

--CREATE:

Create Table Student_Records


(
Student_RollNo char(10),
Student_Name char(20),
FatherName char(20),
Branch char(10),
section char(10),
Year char(10),
primary key(Student_RollNo)
);

Insert into Student_Records values(01,'Ankit','suresh','Bsc','A','1');


Insert into Student_Records values(02,'Mhesh','Sagar ','Bsc','A','3');
Insert into Student_Records values(03,'Rakesh','Vinod ','Btech','A','1');
Insert into Student_Records values(04,'Nitesh ','Ashok ','BCA','A','2');
Insert into Student_Records values(05,'Abhishek','Anmol ','BBA','A','4');

Select * from Student_Records;

--UPDATE:
Update Student_Records set FatherName ='Mahendra ' where Student_RollNo = 05;
Select * from Student_Records;

--Drop:
Alter Student_Records drop section;
Select * from Student_Records;

Alter Student_Records drop section;


Select * from Student_Records;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

6. Write a Program to Implement Cursor Operation


Create Table Employee
(
ID char(10),
NAME char(20),
AGE char(20),
ADDRESS char(20),
SALARY char(20),

primary key(ID )
);

Insert into Employee values(101,'Rohan','23','Aligarh','5000');


Insert into Employee values(102,'Suresh','22','Rampur','2200');
Insert into Employee values(803,'Mahesh','24','Ghaziabad','4000');
Insert into Employee values(154,'Chandu','25','Noida','6000');
Insert into Employee values(985,'Anmol','21','Saharanpur','8000');
Insert into Employee values(116,'Sumit','20','Delhi','3000');

Select * from Employee;

DECLARE
total_rows number(2);
BEGIN
UPDATE Employee
SET salary = salary + 2000;
IF sql%notfound THEN
dbms_output.put_line('no Employee updated');
ELSIF sql%found THEN
total_rows := sql%rowcount;
dbms_output.put_line( total_rows || ' Employee updated ');
END IF;
END;
/

Select * from Employee;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

7. Write a Program in PL/SQL to print 1 to 10 using while loop.


Declare

I number;

Begin

    I:=1;

While (I<=10)

Loop

    Dbms_output.put_line(I);

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

    I:=I+1;

End loop;

End;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

8. Write a Program in PL/SQL to find Prime and Nonprime Number.

declare

-- declare variable n, i

-- and temp of datatype number

n number;

i number;

temp number;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

begin

-- Here we Assigning 10 into n

n := 13;

-- Assigning 2 to i

i := 2;

-- Assigning 1 to temp

temp := 1;

-- loop from i = 2 to n/2

for i in 2..n/2

loop

if mod(n, i) = 0

then

temp := 0;

exit;

end if;

end loop;

if temp = 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

then

dbms_output.put_line('true');

else

dbms_output.put_line('false');

end if;

end;

-- Program End

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

9. Write a Program in PL/SQL to find out the square of a number.


DECLARE

   a number;

PROCEDURE squareNum(x IN OUT number) IS


BEGIN

  x := x * x;

END;
BEGIN

   a:= 2;

   squareNum(a);

   dbms_output.put_line(' Square of (2): ' | |  a);

END;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

10. Write a Program to Implement Trigger Operation.


Create Table Employee
(
ID char(10),
NAME char(20),
AGE char(20),
ADDRESS char(20),
SALARY char(20),
Prepared by: aman.kaushik Reviewed by: Approved by:
Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

primary key(ID)
);

Insert into Employee values(101,'Rohan','23','Aligarh','5000');


Insert into Employee values(102,'Suresh','22','Rampur','2200');
Insert into Employee values(803,'Mahesh','24','Ghaziabad','4000');
Insert into Employee values(154,'Chandu','25','Noida','6000');
Insert into Employee values(985,'Anmol','21','Saharanpur','8000');
Insert into Employee values(116,'Sumit','20','Delhi','3000');

Select * from Employee;


CREATE or replace TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON Employee
FOR EACH ROW
WHEN (NEW.ID > 0)
Prepared by: aman.kaushik Reviewed by: Approved by:
Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

DECLARE
sal_diff number;
BEGIN
sal_diff := :NEW.salary - :OLD.salary;
dbms_output.put_line('Old salary:' || :OLD.salary);
dbms_output.put_line('New salary:' || :NEW.salary);
dbms_output.put_line('Salary difference: ' || sal_diff);
END;
/

INSERT INTO Employee (ID,NAME,AGE,ADDRESS,SALARY)


VALUES (7, 'Tushar', 22, 'Dehradun', 5500 );
Select * from Employee;

UPDATE Employee
SET salary = salary + 500
WHERE id = 2;
Select * from Employee;

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

By—Aman kaushik

Prepared by: aman.kaushik Reviewed by: Approved by:


Name of the Lab:DBMS Rev Date:15/1/2021 Date:

Program:BCA
Rev No.: 00
Branch:BCA
Course code: CAF106 Semester: Ist

L T P C : Academic Year: 2020-21


Lab In-Charge: Page: 1 of 1

LAB EVALUATION SCHEME:

Continuous Lab
Lab Assessment Lab Report Total Marks
Assessment Performance

5 5 5 5 20

Prepared by: aman.kaushik Reviewed by: Approved by:

You might also like