本帖最后由 liulanger160 于 2010-06-09 22:19:01 编辑

解决方案 »

  1.   

    出错信息:
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
      

  2.   

    用你的代码测试没有问题,你是不是没加  delimiter //
    mysql> DROP TABLE IF EXISTS tab1;
    Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> CREATE TABLE tab1(
        ->    tab1_id varchar(11)
        -> );
    Query OK, 0 rows affected (0.09 sec)mysql> DROP TABLE IF EXISTS tab2;
    Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> CREATE TABLE tab2(
        ->    tab2_id varchar(11)
        -> );
    Query OK, 0 rows affected (0.08 sec)mysql>
    mysql> DROP TRIGGER IF EXISTS t_afterinsert_on_tab1;
    Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>
    mysql> delimiter //
    mysql> CREATE TRIGGER t_afterinsert_on_tab1
        -> AFTER INSERT ON tab1
        -> FOR EACH ROW
        -> BEGIN
        ->     insert into tab2(tab2_id) values(new.tab1_id);
        -> END;
        -> //
    Query OK, 0 rows affected (0.08 sec)mysql> delimiter ;
    mysql>