MCA-I ADBMS Practical File
MCA-I ADBMS Practical File
INDEX
S. No Title Page No. Remarks
Design and manage table using DML, DDL and DCL
1. commands. Perform select query to work on EMP and DEPT
3
table of scott/tiger log in.
Program 1: - Design and manage table using DML, DDL and DCL
commands. Perform select query to work on EMP and DEPT
table of scott/tiger log in.
DDL Commands
1. Create command
Output :-
Output :-
2. Alter Command
Output :-
Output :-
Output :-
3. Truncate Command
Output :-
4. Rename Command
Output :-
5. Drop Command
Output :-
DML Commands
1. Insert Command
values(
-> 1,
-> "Rishabh",
-> "Ass. Prog.",
-> 35000,
-> "Raipur",
-> 12345
-> );
Output :-
ii) Inserting more than one record using a single insert command:
Output :-
Output :-
2. Update Command
Output :-
3. Delete Command
Output :-
DCL Commands
1. Grant Command
Output :-
2. Revoke Command
Output :-
Output :-
-> 02,
-> "Neeraj",
-> "Durg",
-> 36978
-> );
mysql> insert into Emp values(
-> 03,
-> "Bikalp",
-> "Kanker",
-> 45796
-> );
mysql> insert into Emp values(
-> 04,
-> "Fanish",
-> "Bilaspur",
-> 58971
-> );
mysql> insert into Emp values(
-> 05,
-> "Bhavesh",
-> "Gariyaband",
-> 67489
-> );
mysql> insert into Emp values(
-> 06,
-> "Mohnish",
-> "Durg",
-> 32198
-> );
Output :-
Output :-
Output :-
SELECT
1. Where
mysql> select * from student
-> where Roll_No = 1;
Output :-
2. Distinct
mysql> select distinct Age from student;
Output :-
3. In
mysql> select * from student
-> where Address in ('Lalpur', 'Mahavir Nagar');
Output :-
4. Between-and
mysql> select * from student
-> where Roll_No between 2 and 4;
Output :-
5. Like
mysql> select * from student
-> where Address like 'p%';
Output :-
6. Is Null
mysql> select Name,Age,Contact
-> from student
-> where Contact is null;
Output :-
7. Group by – having
mysql> select Roll_No, Name, Age, Address, Contact
-> from student
-> group by Age
-> having count(Age) >= 2;
Output :-
8. Order by
mysql> select * from student
-> order by Name;
Output :-
COLUMN
1. Format
(Before Formatting)
(After Formatting)
mysql> alter table student
-> modify column Dob year;
Output :-
2. Heading
mysql> select Name as Stu_Name
-> from student;
Output :-
3. Justify
mysql> select lpad(Name,70,' ') from student;
Output :-
NESTED QUERIES
1. Any
mysql> select Name from Emp
-> where Emp_Id = any
-> (select Emp_Id from Dept
-> where Dep_Id > 2);
Output :-
2. All
mysql> select Name from Emp
-> where Emp_Id = all
-> (select Emp_Id from Dept
-> where Dep_Id = 3);
Output :-
3. In
mysql> select * from Emp
Raipur Institute of Technology [RITEE] P a g e | 30
Advance Database Management SESSION 2023-
Output :-
4. Not in
mysql> select * from Emp
-> where Emp_Id not in
-> (select Emp_Id from Emp
-> where Loc > 'C%');
Output :-
5. Exists
mysql> select Dep_Id from Dept
-> where exists
-> (select Name from Emp
-> where Emp.Loc = Dept.Loc and Emp_Id < 4);
Output :-
Consider a Table:-
1. Student
2. Student Course
1. Inner Join -
mysql> select StudentCourse.Course_Id, Student.Name,
-> Student.Age from Student
-> inner join StudentCourse on
-> Student.Roll_No = StudentCourse.Roll_No;
Output :-
1. Outer Join -
Output :-
Output :-
2. Full Join –
Output :-
VIEWS
1. Create View:-
Output :-
2. Update View :-
mysql> alter view Details_View as
-> select Name,Address,Contact
-> from student
-> where Roll_No = 1;
Output :-
3. Drop View :-
Output :-
SEQUENCES
1. Create Sequence :-
Output :-
Output :-
2. Alter Sequence :-
Output :-
3. Drop Sequence :-
Output :-
SYNONYMS
1. Create Synonyms :-
Output :-
2. Drop Synonym :-
Stud; Output :-
INDEX
1. Create Index :-
Output :-
2. Drop Index :-
Output :-
1. Commit
Consider a Table Student :-
Output :-
2. Rollback
Consider a Table Student :-
3. Save Point
Consider a Table Student :-
Output :-
1.) Grant the select authority on the Student table to all user.
Output :-
Output :-
Now try to check that user RishabhSahu can apply select privilege on
Student table or not:
3.) Drop all the privileges on Student table from user RishabhSahu.
Output :-
Output :-
Output :-
Output :-
Output :-
DELIMITER $$
DROP PROCEDURE IF EXISTS display_by_cursor$$
CREATE PROCEDURE display_by_cursor()
BEGIN
DECLARE Emp_id integer;
DECLARE Grd varchar(255);
DECLARE finished INTEGER DEFAULT 0;
DECLARE Cust_Record
CURSOR FOR
SELECT `Emp_No`,`Grade` FROM `salary`;
CREATE TEMPORARY TABLE tblResults (Emp_No
int,Grade varchar(255));
BEGIN
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET finished = 1;
OPEN Cust_Record;
getEmail: LOOP
FETCH Cust_Record into Emp_id, Grd;
IF finished = 1 THEN
LEAVE getEmail;
END IF;
INSERT INTO tblResults VALUES (Emp_id, Grd);
END LOOP getEmail;
CLOSE Cust_Record;
END;
SELECT * FROM tblResults;
DROP TEMPORARY TABLE IF EXISTS tblResults;
END$$
DELIMITER ;
CALL display_by_cursor();
Output :-
-------END------