Professional Documents
Culture Documents
Hu21csen0101379 DBMS Lab Record
Hu21csen0101379 DBMS Lab Record
Hu21csen0101379 DBMS Lab Record
Deemed to be University
(Estd. u/s of UGC Act, 1950)
Hyderabad Campus
i
GITAM
Deemed to be University
(Estd. u/s of UGC Act, 1950)
Hyderabad Campus
CERTIFICATE
Faculty I/c.
Date: Head of the Department
ii
INDEX
iii
DBMS LAB ASSIGNMENT -1
NAME: K. Santhana Gopala Krishnan ROLLNO: HU21CSEN0101379
write the SQL queries for the following
1.Create an employee table with (id, name, salary, dob, deptno) attributes. consider id as the primary
key
A.
iv
5. Delete the employees having null values for salary;
A.
v
8. Retrieve employee data from deptnos 10 and 20;
A.
vi
vii
viii
9
10
12
13
15
DBMS LAB ASSIGNMENT – 3
17
4. alter the table structure to add not null constraint on dob, default constraint on course fee with
defaultvalue of 5000.
A.
5. alter the table structure to add user defined constraint on course fee to allow the values between 3000
and15000
A.
6. create the table course with the attributes course id, name, instructor name with suitable domains
andprimary key.
A.
18
7. alter the student table structure to add foreign key referencing to course table
A.
19
9. alter the student table structure to modify the datatype of course fee to take real values.
A.
10. alter the table structure of course to rename the column instructor name to faculty name.
A.
20
DBMS LAB ASSIGNMENT – 4
NAME: K. Santhana Gopala Krishnan PIN NO: HU21CSEN0101379
Write SQL queries for the following
1. To retrieve all the information from the employee table in the descending order of employee names
A. Before
21
2. to retrieve all the employees information in the ascending order of salaries A.
4. to display the maximum salary, minimum salary, average salary of all employees A.
22
6. to display the departmentwide average salaries A.
7. to display the difference of average salary and his own earnings for each employee, give the alias name as
sal_diff
A.
23
24
DBMS LAB ASSIGNMENT – 5
NAME: K. Santhana Gopala Krishnan PIN NO: HU21CSEN0101379
Table Creation
1. create a view with name max_sal_view from employee table as department wise
maximum salaries
A.
25
3. insert a row into salrange_view and check that row inserted in employee table or
not.
A.
4. create a view salrange_view1 from employee table having salaries between 10000
and 50000 with check option
A.
5. insert a row into salrange_view1 with salaries 40000 and 60000. what did you
observe.
A.
26
the second row will not be inserted because it violates the view's filter condition.
6. delete max_sal_view
A.
8. insert four rows into employee table and commit the changes
A.
27
9. create a savepoint with name SPB
A.
10. delete two rows from employee table and dont commit
A.
28
After rollback deletion is undone.
29
DBMS LAB ASSIGNMENT – 6
NAME: K. Santhana Gopala Krishnan PIN NO: HU21CSEN0101379
1. create a user with your 'roll no' and use password as Gitam
A.
2. grant all privileges to 'roll no' and connect to 'roll no' with appropriate
password
A.
30
6. display login data
A.
7. connect back to admin user and revoke select privilege on login table
from roll no
A.
31
8. now retrieve the data from login table. what did you observe?
A.
After revoking the select privilege on the login table from the 'roll no' user, if we
try to retrieve the data from the login table using the 'roll no' user, we will get
an error message saying that the user does not have the required privilege to
access the table.
32
DBMS LAB ASSIGNMENT – 7
NAME: K. Santhana Gopala Krishnan PINNO: HU21CSEN0101379
Demonstrate the following joins using SQL queries
Table of Employees
1. Equi join:
2. Natural join
33
3. non-equal join
Table 2
1. Union
2. Union All
36
3. Intersect
4. Minus / Except
37
DBMS LAB ASSIGNMENT – 8
Name : K. Santhana Gopala Krishnan Pinno: HU21CSEN0101379
1. To print the employee details from employee table for a specific employee no given at
run time using local variables.
OUTPUT:
2. To print the employee details from employee table for a specific employee no given at
run time using record type variable.
OUTPUT:
38
3. To display the employee details from employee table for a specific employee no given
at run time using row type record variable.
OUTPUT:
39
4. To display the employee details from employee table for a specific employee no given
at run time using procedures.
40
5. To display the employee salary from employee table for a specific employee no given
at run time using functions.
41
DBMS LAB ASSIGNMENT – 9
NAME: K. Santhana Gopala Krishnan PIN NO: HU21CSEN0101379
1. To display all the employee details from employee table using implicit cursors
OUTPUT:
2. To display all the employee details from employee table using explicit cursors
OUTPUT:
42
3. To display all the student details from student table using loops (any loop)
OUTPUT:
4. Write an update trigger to display the salary change for an employee salary updating.
43
OUTPUT:
5. Create a log table and log every change of employee table, timing, operation, user
name using triggers.