Consider the student relation containing the attributes ’ID’, ’Dept\_name’, ’Credits’.…
Jump to turn (9)
- 1Consider the student relation containing the attributes ’ID’, ’Dept\name’, ’Cred
- 2What kind of trigger will you use in the following scenarios and why ? Please me
- 3(c) Which type of trigger is used if we want the triggering statement to complet
- 4(d) How many times a before update row level trigger will execute if the update
- 5Suppose there is a database with the following relations : employees( id : integ
- 6ii) The authorization to access the relations has been granted to different user
- 7Suppose the database administrator decides to revoke the authorization of user "
- 8(b) Suppose we have a database that holds the information of all products in a m
- 9(a) Consider the following relation : Sales ( id : integer, region : string, pro
- User
Consider the student relation containing the attributes ’ID’, ’Dept_name’, ’Credits’. Write a trigger statement in sql that doesn’t allow inserting students data having ’Credits’ more than 10.0
- Assistant
Assuming the name of the table is "Student", the following trigger statement can be used in SQL to prevent inserting students data with credits more than 10.0:
sqlCREATE TRIGGER check_credits BEFORE INSERT ON Student FOR EACH ROW BEGIN IF NEW.Credits > 10.0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Credits cannot be more than 10.0'; END IF; END;This trigger will be executed before every insert operation on the Student table, and it will check if the value of Credits for the new row being inserted is more than 10.0. If it is, then the trigger will throw an error with the message "Credits cannot be more than 10.0", and the insert operation will be aborted.