0

Suppose I have a script with the code for a trigger, how do I actually start up the script so that the trigger is active? How do I stop it?

3
  • 1
    More information please. Code example perhaps? Commented Nov 25, 2012 at 2:33
  • It is just a simple trigger saved in a .sql file. I do not know how to run(execute) this file. Commented Nov 25, 2012 at 2:48
  • @Trup Does the below answer help? Commented Nov 25, 2012 at 2:53

1 Answer 1

1

If you have a script that has code for creating a MySQL trigger, you would simply execute the script in order to create the trigger assuming the script contains MySQL statements along the lines of:

CREATE
    [DEFINER = { user | CURRENT_USER }]
    TRIGGER trigger_name trigger_time trigger_event
    ON tbl_name FOR EACH ROW trigger_body

http://dev.mysql.com/doc/refman/5.5/en/create-trigger.html

To get rid of a trigger that you have created, you use the DROP statement in MySQL accompanied by the name of the trigger, or create another script to execute the SQL statement:

DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name

http://dev.mysql.com/doc/refman/5.6/en/drop-trigger.html

To execute a SQL file you would simply type @[file_name].sql at the SQL prompt in the command line:

http://www.techonthenet.com/oracle/questions/script.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.