触发特定值到不同的数据库中

时间:2016-03-21 13:53:45

标签: sql triggers

我是新手触发,有没有办法在databaseA.conference中有新记录时触发对databaseB.track conferenceid的输入?这就是我所做的,而且不起作用。

DELIMITER//
CREATE or replace TRIGGER insert_confer
after insert ON conference
for each row
begin 
insertdatabaseb.Track(:new.conferenceid);
end;
/

                    DatabaseA                     Database B
                    Conference                    Track
                   -conferenceid                 -Trackid
                   -conferencename               -Trackname
                   -conferencevenue              -Conferenceid

1 个答案:

答案 0 :(得分:1)

问题不是触发器本身,而是insert上的语法。也许:

DELIMITER//
CREATE or replace TRIGGER insert_confer
after insert ON conference
for each row
begin 
    insert into databaseb.Track(conferenceid)
        values (:new.conferenceid);
end//
DELIMITER ;