Question: MySQL: Trigger Insert (1) I have a table with field1 field2 ... fieldN (2) How do I write a MySQL query such that an insert

MySQL: Trigger Insert

(1) I have a table with

field1

field2

...

fieldN

(2) How do I write a MySQL query such that an insert trigger enforces the following constraints:

field1 = '1', '2', ... '10'

field2 is between '1000' and '2000'

(3) The trigger should ```SIGNAL SQL STATE 45001``` and return a message explaining why the insert is invalid for a constraint violation. For example: "field1" is not in desired range"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!