How to do the data validation directly from MySQL? Trigger mysql example.
Many times I wanted to do data validation directly when inserting into a MySQL table and leave the source code of my application nice, clean and very readable, but support for that was only in Oracle and other SQL servers but not in MySQL.
Beginning with version 5 of MySQL the development team has added “triggering” to their SQL server engine, to meet the growing demand of users.
But what are triggers ?
A trigger is a database object that is associated with a table and is activated when an event occurs for that table. Can be successfully used for database data validation and any other calculations done directly on the database.