mysql triggers and stored procedures diff
are stored precedures, triggers?
i was asked to write a mysql script file and develop database, on a server that does not suppor开发者_C百科t triggers. so my question is, since i can't use triggers, then i can't use stored procedures right?
Triggers involve stored procedures (essentially), but not all stored procedures are triggers. So if the database is an old version of MySQL (per Ike's answer), both are out.
However it may be a general dictum for your design ("develop database") not to use triggers. Projects can get into trouble by pushing business logic into triggers on the database. Yes, sometimes that can solve otherwise intractable problems enforcing complex inter-table dependencies. But your task may have been to do a more-or-less vanilla design, avoiding triggers in the first iteration.
A stored procedure is not as much a design risk. It doesn't attempt to "enforce" anything in the business logic, just (hopefully) to comply with it. And the stored procedure runs when it is called, so it basically acts as a mechanism to store a script in the database and make it simpler to execute than running a script from a client connection. Stored procedures might be useful to designing dataloads and reports, if those are within the scope of your task.
Which version of MySQL are you using?
Triggers and stored procedures were both added in 5.0, so if you are using 3.X or 4.X then you can't use triggers or stored procedures.
精彩评论