Use a trigger to stop an insert or update

后端 未结 2 934
逝去的感伤
逝去的感伤 2020-11-27 07:13

Since MySQL ignores check constraints, how does one go about using a trigger to stop an insert or update from happening?

For example:

Table foo has an attrib

2条回答
  •  失恋的感觉
    2020-11-27 07:30

    If your version of MySQL is older than 5.5, try setting a non-null field of the table to NULL. It is a hack, but it does prevent the update or insert from completing.

    The SIGNAL command which Naveen suggests looks great, and I'm looking forward to using it after we upgrade.

提交回复
热议问题