The document is a lab manual for a Database Management System course, detailing various experiments related to SQL and RDBMS installation and usage. It includes instructions for installing Oracle, MySQL, and PostgreSQL, creating users and databases, and executing SQL commands for data manipulation. Additionally, it covers topics such as SQL functions, joins, subqueries, views, cursors, and triggers.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0 ratings0% found this document useful (0 votes)
8 views38 pages
DBMS Final
The document is a lab manual for a Database Management System course, detailing various experiments related to SQL and RDBMS installation and usage. It includes instructions for installing Oracle, MySQL, and PostgreSQL, creating users and databases, and executing SQL commands for data manipulation. Additionally, it covers topics such as SQL functions, joins, subqueries, views, cursors, and triggers.
[ REFERENCING |
::=
INSERT |
DELETE |
UPDATE [ OF ]
::= [ {.} ... ]
...
OLD [ ROW ] [ AS ] old values |
NEW [ROW ] [AS ] new values |
OLD TABLE [ AS ] |
NEWTABLE [AS ] ::= ::= ::=
[FOR EACH {ROW | STATEMENT} ] [ WHEN (search condition) ]
::=
SQL statement |BEGIN ATOMIC {SQL statement; }... END
creates a log table and a trigger that inserts a row in the log table after any UPDATE
statement affects the SALARY column of the EMPLOYEES table, and then updates
EMPLOYEES.SALARY and shows the log table.
CREATE TABLE employees (
employee_id INTEGER PRIMARY KEY,
first_name VARCHAR(25),
last_name VARCHAR(25)
ys
CREATE TABLE salaries (
salary_id INTEGER PRIMARY KEY,
employee_id INTEGER,
salary_amount INTEGER,
CONSTRAINT fk_employee FOREIGN KEY (employee_id) REFERENCES
employees(employee_id)
ds
CREATE OR REPLACE TRIGGER check_employee_exists
BEFORE INSERT ON salaries
FOR EACH ROW
DECLARE
v_count INTEGER:
BEGIN
SELECT COUNT(*) INTO v_count
FROM employees
WHERE employee_id = :NEW.employee_id:
IF v_count = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Employee does not exist’);
END IF;
END:
/
BEGIN,
INSERT INTO salaries (salary_id, employee_id, salary_amount) VALUES (1, 1001,
50000);
EXCEPTION
WHEN OTHERS THEN,
DBMS_OUTPUT.PUT_LINE( Error: ' || SQLERRM);Output :-
Coal aeekig