码迷,mamicode.com
首页 > 数据库 > 详细

mysql 查看删除触发器等操作

时间:2019-11-15 12:03:34      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:删除   color   sed   day   delete   let   HERE   存在   value   

mysql 查看删除触发器等操作

  平时很少操作触发器,源于昨晚的一次故障,使用pt-online-change-schema修改大表过程中出现异常,再次执行时,提示已经存在触发器,导致失败。

这里推荐第三种方式:

 

1.、查看所有触发器

select * from information_schema.triggers\G;

2、根据触发器名称看下相关触发器信息

mysql> select * from information_schema.triggers where trigger_name=‘pt_osc_fudao_course_fudao_course_ins‘\G;

3、show triggers\G;

技术图片
mysql>  show triggers\G;
*************************** 1. row ***************************
             Trigger: pt_osc_fudao_course_fudao_course_ins
               Event: INSERT
               Table: fudao_course
           Statement: REPLACE INTO `fudao_course`.`_fudao_course_new` (`id`, `course_id`, `subject`, `grade`, `tid`, `uid`, `aid`, `join_person_id`, `period_type`, `start_time`, `end_time`, `day`, `week`, `day_start_time`, `day_end_time`, `grade_type`, `course_type`, `course_status`, `teacher_remark`, `student_remark`, `cw_id`, `hw_id`, `add_time`, `update_time`, `complaint`) VALUES (NEW.`id`, NEW.`course_id`, NEW.`subject`, NEW.`grade`, NEW.`tid`, NEW.`uid`, NEW.`aid`, NEW.`join_person_id`, NEW.`period_type`, NEW.`start_time`, NEW.`end_time`, NEW.`day`, NEW.`week`, NEW.`day_start_time`, NEW.`day_end_time`, NEW.`grade_type`, NEW.`course_type`, NEW.`course_status`, NEW.`teacher_remark`, NEW.`student_remark`, NEW.`cw_id`, NEW.`hw_id`, NEW.`add_time`, NEW.`update_time`, NEW.`complaint`)
              Timing: AFTER
             Created: NULL
            sql_mode: NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION
             Definer: admin_m@%
character_set_client: utf8mb4
collation_connection: utf8mb4_general_ci
  Database Collation: utf8_general_ci
*************************** 2. row ***************************
             Trigger: pt_osc_fudao_course_fudao_course_upd
               Event: UPDATE
               Table: fudao_course
           Statement: BEGIN DELETE IGNORE FROM `fudao_course`.`_fudao_course_new` WHERE !(OLD.`id` <=> NEW.`id`) AND `fudao_course`.`_fudao_course_new`.`id` <=> OLD.`id`;REPLACE INTO `fudao_course`.`_fudao_course_new` (`id`, `course_id`, `subject`, `grade`, `tid`, `uid`, `aid`, `join_person_id`, `period_type`, `start_time`, `end_time`, `day`, `week`, `day_start_time`, `day_end_time`, `grade_type`, `course_type`, `course_status`, `teacher_remark`, `student_remark`, `cw_id`, `hw_id`, `add_time`, `update_time`, `complaint`) VALUES (NEW.`id`, NEW.`course_id`, NEW.`subject`, NEW.`grade`, NEW.`tid`, NEW.`uid`, NEW.`aid`, NEW.`join_person_id`, NEW.`period_type`, NEW.`start_time`, NEW.`end_time`, NEW.`day`, NEW.`week`, NEW.`day_start_time`, NEW.`day_end_time`, NEW.`grade_type`, NEW.`course_type`, NEW.`course_status`, NEW.`teacher_remark`, NEW.`student_remark`, NEW.`cw_id`, NEW.`hw_id`, NEW.`add_time`, NEW.`update_time`, NEW.`complaint`);END
              Timing: AFTER
             Created: NULL
            sql_mode: NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION
             Definer: admin_m@%
character_set_client: utf8mb4
collation_connection: utf8mb4_general_ci
  Database Collation: utf8_general_ci
*************************** 3. row ***************************
             Trigger: pt_osc_fudao_course_fudao_course_del
               Event: DELETE
               Table: fudao_course
           Statement: DELETE IGNORE FROM `fudao_course`.`_fudao_course_new` WHERE `fudao_course`.`_fudao_course_new`.`id` <=> OLD.`id`
              Timing: AFTER
             Created: NULL
            sql_mode: NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION
             Definer: admin_m@%
character_set_client: utf8mb4
collation_connection: utf8mb4_general_ci
  Database Collation: utf8_general_ci
3 rows in set (0.00 sec)

ERROR: 
No query specified
show triggers\G

4、删除触发器

技术图片
drop trigger pt_osc_fudao_course_fudao_course_ins;
drop trigger pt_osc_fudao_course_fudao_course_upd;
drop trigger pt_osc_fudao_course_fudao_course_del;
drop trigger

 

 

mysql 查看删除触发器等操作

标签:删除   color   sed   day   delete   let   HERE   存在   value   

原文地址:https://www.cnblogs.com/bjx2020/p/11865200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!