Professional Documents
Culture Documents
Practical - 9 PDF
Practical - 9 PDF
Consider the following relational schema that manages the telephone bills of a mobile phone company.
1. Write a trigger that after each phone call updates the customer's bill.
MariaDB [cba18162101026]> CREATE TRIGGER `upbill` AFTER INSERT ON `phonecall` FOR EACH ROW
update bill set amount = amount + new.seconds * 2;
MariaDB [cba18162101026]> show triggers in ddcba4;
2. Create a trigger GRADES_TRG that calculates the value of the Avg_M column.
MariaDB [cba18162101026]>CREATE TRIGGER `Grades_trg` BEFORE INSERT ON `grades` FOR EACH ROW
set new.avg_m = (new.m1 + new.m2 + new.m3)/3;
MariaDB [cba18162101026]>insert into grades values (‘id1’,50,60,70,null);
MariaDB [cba18162101026]>select * from grades;
Create a trigger on table GRADES such that it restricts the entry of Duplicate SNo.