DBMS Lab File
DBMS Lab File
2.Create Entity-Relationship
Diagram using case tools.
Step 1: Go to Website
Visit: https://dbdiagram.io
You can sign in with Google or GitHub to save your work, or use it without signing in.
Table College {
college_id int [pk]
name varchar
location varchar
}
• pk = Primary Key
• ref: > College.college_id = Foreign Key
It auto-generates the diagram as you type.
-- UPDATE
UPDATE employees
SET salary = salary + 1000
WHERE employee_id = 207;
-- DELETE
DELETE FROM employees
WHERE employee_id = 207;
-- DROP TABLE
DROP TABLE departments;
4.Normalization.[Skipped]
5. Create cursor.
-- Sample table
emp_id NUMBER,
name VARCHAR2(50),
salary NUMBER
);
DECLARE
v_name employees.name%TYPE;
v_salary employees.salary%TYPE;
CURSOR emp_cursor IS
BEGIN
OPEN emp_cursor;
LOOP
END LOOP;
-- Close the cursor
CLOSE emp_cursor;
END;
--Output (example):
...
A procedure is a named PL/SQL block that performs an action. It does not return a value
directly, but can use OUT parameters.
param1 IN datatype,
IS
BEGIN
END;
p_salary IN NUMBER,
IS
BEGIN
DECLARE
v_bonus NUMBER;
BEGIN
calc_bonus(5000, v_bonus);
END;
What is a Function?
A function is a named PL/SQL block that returns a single value using the RETURN keyword
param1 IN datatype
) RETURN datatype
IS
BEGIN
RETURN value;
END;
END emp_bonus_pkg;
PART 2: Triggers in Oracle
What is a Trigger?
A trigger is a stored PL/SQL block that automatically runs when a specific event occurs (like
INSERT, UPDATE, DELETE).