Adbms Lab File
Adbms Lab File
of
Advanced DBMS
(CS441)
1 Use of DDL, DML and DCL commands for table creation in database. 12.08.2021
2 Use of where, rename, tuple variables and string operations on tables. 19.08.2021
3 Use of nested queries, set operations and join operations on tables. 26.08.2021
4 Use of PL/SQL variables, reserved words, identifiers and anchored data 02.09.2021
types.
9 Use a cursor for loop and process nested cursors in PL/SQL 07.10.2021
Objective:Use of DDL, DML and DCL commands for table creation in database.
Ouput:
Experiment – 2
Where command
Tuple variations
Rename command
String operations
Experiment – 3
Nested queries :
Employee1 Employee2
Query : select name, city from employee1 where name in (select name from employee4 where
designation = 'shareholder');
Set operations :
First second
Query2 (union all): select * from first union all select * from second;
Query3 (intersect): select * from first intersect select * from
second;
Join operations :
supplier_info
Order_info
Objective:Use of PL/SQL variables, reserved words, identifiers and anchored data types.
The %TYPE attribute lets you declare a constant, variable, field, or parameter to be of the
same data type a previously declared variable, field, record, nested table, or database column.
If the referenced item changes, your declaration is automatically updated.
An item declared with %TYPE (the referencing item) always inherits the data type of the
referenced item. The referencing item inherits the constraints only if the referenced item is
not a database column. The referencing item inherits the default value only if the referencing
item is not a database column and does not have the NOT NULL constraint.
Experiment – 5
Objective:Use of block, nested blocks and labels
in PL/SQL.
Use of Block:
IF THEN :-
DECLARE
a number(2) := 10;
BEGIN
END IF;
END:
ELSEIF :-
DECLARE
BEGIN
dbms_output.put_line(‘Value of a is 20’);
ELSEIF (a = 30) THEN
dbms_output.put_line (‘Value of a
is 30 ’);
ELSE
IF;
END;
NESTED IF:-
DECLARE
a number(3) := 100; b
number(3) := 200;
BEGIN
END IF;
END IF;
END;
CASE STATMENT :-
DECLARE
BEGIN
CASE grade
END CASE;
END;
Experiment – 9
INSERT INTO
Employee(EID,ENAME,AGE,ADDRESS,SALARY)VALUES(1,'SHUBHAM',21,'HARID
WAR',30000);
INSERT INTO
Employee(EID,ENAME,AGE,ADDRESS,SALARY)VALUES(2,'KUNAL',21,'JAIPUR',350
00);
INSERT INTO
Employee(EID,ENAME,AGE,ADDRESS,SALARY)VALUES(3,'SHRESTH',21,'MEERUT'
,20000);
INSERT INTO
Employee(EID,ENAME,AGE,ADDRESS,SALARY)VALUES(4,'RAKSHIT',22,'DEHRAD
UN',30000);
INSERT INTO
Employee(EID,ENAME,AGE,ADDRESS,SALARY)VALUES(5,'SHUBHANG',22,'RISHIK
ESH',25000);
total_rows number(2);
BEGIN
UPDATE Employee
IF sql%notfound THEN
END IF;
END;
/
-- EXPLICIT CURSOR
DECLARE
E_ID Employee.EID%type;
E_NAME Employee.ENAME%type;
E_ADDR Employee.ADDRESS%type;
CURSOR E_Employee is
BEGIN
OPEN E_Employee;
LOOP
END LOOP;
CLOSE E_Employee;
END;
/
Experiment –10
Insert All
'Gurugram', 78)
Begin
return total;
End;
create or replace procedure find_name(i_id in number, o_name out varchar2, o_city out varchar2) As Begin
Declare
numberOfStudents number(10) := 0;
o_namevarchar(50);
o_cityvarchar(50);
Begin
numberOfStudents := getNumberOfStudents();
End;
Experiment 11
We have this customer table on which we will be creating row and statement trigger.
DECLARE
Sal_diff number;
BEGIN
Query
Query
UPDATE customers
WHERE id = 2;