开发者

How Do I create a trigger on a table that insert into another database

开发者 https://www.devze.com 2023-03-24 04:35 出处:网络
I have two mySQL db\'s on called home and the other called zenphoto_live. I want to create a trigger on zephoto_live.zp_images th开发者_如何学JAVAat inserts a record into home.tbl_new_image_inserts

I have two mySQL db's on called home and the other called zenphoto_live.

I want to create a trigger on zephoto_live.zp_images th开发者_如何学JAVAat inserts a record into home.tbl_new_image_inserts when ever a new/update occurs on the zenphoto_live.zp_images table. I tried

CREATE DEFINER = CURRENT_USER TRIGGER new_images AFTER INSERT ON zenphoto_live.zp_images FOR EACH ROW insert into home.tbl_new_image_inserts (id,albumid,datetime) values (zenphoto_live.zp_images.id,zenphoto_live.zp_images.albumid,now());

but I get "No Database selected" error.

Any help much appreciated.


Specify a full name for the trigger, e.g. -

CREATE DEFINER = CURRENT_USER TRIGGER zephoto_live.new_images AFTER INSERT ON
...

Or set default database for the session -

USE zephoto_live;
CREATE DEFINER = CURRENT_USER TRIGGER new_images AFTER INSERT ON
...
0

精彩评论

暂无评论...
验证码 换一张
取 消