DBMS Lab Manual
DBMS Lab Manual
DBMS Lab Manual
1
SRI VENKATESHWARA COLLEGE OF ENGINEERING
AIM:
Using basic database management operations using SQL, specifically focusing on user creation, table
creation, data manipulation, and constraint application. The tasks include creating a new user with full
permissions, performing data insertion and rollback operations, adding constraints to the table, and
verifying the enforcement of these constraints.
2. Insert the any three records in the employee table contains attributes
EMPNO,ENAME JOB, MANAGER_NO, SAL, COMMISSION and use
rollback. Check the result.
3. Add primary key constraint and not null constraint to the employee table.
ALTER TABLE Employee.
2
SRI VENKATESHWARA COLLEGE OF ENGINEERING
4. Insert null values to the employee table and verify the result.
3
SRI VENKATESHWARA COLLEGE OF ENGINEERING
AIM: To demonstrate the use of aggregate functions and SQL clauses like GROUP BY and
ORDER BY. The tasks include creating a table, inserting records, and performing various
queries to count records, find maximum and minimum values, sort data, and group data based
on specific attributes.
1. Create Employee table containing all Records E_id, E_name, Age, Salary.
4
SRI VENKATESHWARA COLLEGE OF ENGINEERING
INSERT INTO Employee (E_id, E_name, Age, Salary) VALUES (1, 'John Doe', 30, 50000.00);
INSERT INTO Employee (E_id, E_name, Age, Salary) VALUES (2, 'Jane Smith', 25, 45000.00);
INSERT INTO Employee (E_id, E_name, Age, Salary) VALUES (3, 'Alice Brown', 28, 47000.00);
INSERT INTO Employee (E_id, E_name, Age, Salary) VALUES (4, 'Bob White', 35, 43000.00);
INSERT INTO Employee (E_id, E_name, Age, Salary) VALUES (5, 'Charlie Black', 32, 42000.00);
4. Create a row level trigger for the customers table that would fire for INSERT
or UPDATE or DELETE operations performed on the CUSTOMERS table.
This trigger will display the salary difference between the old & new Salary.
CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
5
SRI VENKATESHWARA COLLEGE OF ENGINEERING
AIM:
To create a row-level trigger for the CUSTOMERS table that fires for INSERT, UPDATE, or
DELETE operations and displays the salary difference between the old and new salary.
The trigger will use the BEFORE clause to ensure it executes before the INSERT, UPDATE, or
DELETE operations.
It will check for INSERT, UPDATE, and DELETE operations using the WHEN clause and
conditional logic.
TESTING
INSERT A NEW CUSTOMER.
INSERT INTO CUSTOMERS (ID, NAME, AGE, ADDRESS, SALARY) VALUES (1,
'John Doe', 30, '123 Elm St', 50000);
UPDATE A CUSTOMER'S SALARY.
6
SRI VENKATESHWARA COLLEGE OF ENGINEERING
DELETE A CUSTOMER.
5. Create cursor for Employee table & extract the values from the table.
Declare the variables ,Open the cursor & extrct the values from the cursor.
Close the cursor.
Employee(E_id, E_name, Age, Salary)
To create a cursor for the Employee table, extract values, and demonstrate the complete
lifecycle of a cursor in Oracle PL/SQL (declare, open, fetch, and close).
DECLARE
-- Declare variables to hold the values from the Employee table
v_E_id Employee.E_id%TYPE;
v_E_name Employee.E_name%TYPE;
v_Age Employee.Age%TYPE;
v_Salary Employee.Salary%TYPE;
BEGIN
-- Open the cursor
OPEN emp_cursor;
7
SRI VENKATESHWARA COLLEGE OF ENGINEERING
6. Write a PL/SQL block of code using parameterized Cursor, that will merge
the data available in the newly created table N_RollCall with the data
available in the table O_RollCall. If the data in the first table already exist in
the second table then that data should be skipped.
#
SET SERVEROUTPUT ON;
DECLARE
-- Variables to hold the values fetched from the cursor
v_Roll_ID N_RollCall.Roll_ID%TYPE;
v_Roll_Name N_RollCall.Roll_Name%TYPE;
8
SRI VENKATESHWARA COLLEGE OF ENGINEERING
FROM O_RollCall
WHERE Roll_ID = p_Roll_ID;
9
SRI VENKATESHWARA COLLEGE OF ENGINEERING
AIM:
To install an open-source NoSQL database, MongoDB, and perform basic CRUD (Create,
Read, Update, Delete) operations.
10