Triggers
Triggers
Triggers
Row-level trigger:
CREATE TABLE customers (
ID INT PRIMARY KEY,
NAME VARCHAR(50),
AGE INT,
ADDRESS VARCHAR(100),
SALARY DECIMAL(10, 2)
);
UPDATE customers
SET salary = salary + 500
WHERE id = 2;
EX02:
SQL> CREATE TABLE students (
2 student_id NUMBER PRIMARY KEY,
3 name VARCHAR2(50),
4 major VARCHAR2(50),
5 gpa NUMBER(3, 2)
6 );
Table created.
Table created.
Trigger created.
Trigger created.
Trigger created.
Trigger created.
Trigger created.
SQL> INSERT INTO students (student_id, name, major, gpa) VALUES (1,
'Alice', 'Computer Science', 8.8);
1 row created.
SQL> INSERT INTO students (student_id, name, major, gpa) VALUES (2,
'Bob', 'Mathematics',7.6);
1 row created.
SQL> INSERT INTO students (student_id, name, major, gpa) VALUES (3,
'Charlie', 'Physics', 8.9);
1 row created.
SQL> INSERT INTO students (student_id, name, major, gpa) VALUES (4,
'Diana', 'Chemistry', 6.7);
1 row created.
SQL> INSERT INTO students (student_id, name, major, gpa) VALUES (5,
'Evan', 'Biology', 7.5);
1 row created.
Trigger created.