Simple to use Oracle triggers

Source: Internet
Author: User

--Build table statements
CREATE TABLE Student (ID number (9), name VARCHAR2 (+), age number (5));CREATE TABLE Class (ID number (9), name VARCHAR2, Teacherid number (9), StudentID number (9));CREATE TABLE Teacher (ID number (9), name VARCHAR2 (+), age number (5));--Student InformationInsert intoStudentValues(1,'YANGML', at);Insert intoStudentValues(2,'Zhangj', at);Insert intoStudentValues(3,'Zhulj', -);Insert intoStudentValues(4,'CHENGLP', -);--Teacher InformationInsert intoTeacherValues(1,'Yangls', -);Insert intoTeacherValues(2,'Zhangls', -);Insert intoTeacherValues(3,'Zhuls', -);Insert intoTeacherValues(4,'Chenls', -);--class InformationInsert intoClassValues(1,'First Grade',1,1);Insert intoClassValues(2,'Second Grade',2,2);Insert intoClassValues(3,'Third grade',3,3);Insert intoClassValues(4,'Grade Four',4,4);--Delete TriggerCreate or Replace TriggerTrigdel beforeDelete onclass forEach rowDeclare --Local Variables herebegin Delete fromTeacherwhereTeacher.id=: old.id; Delete fromStudentwhereStudent.id=: old.id;EndTrigdel;--Test DeleteDelete fromclass;Select * fromclass;Select * fromstudent;Select * fromTeacher

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.