触发错误1064

时间:2013-02-09 14:11:29

标签: mysql sql triggers phpmyadmin

  • 问题1:我在一台服务器上为每个网站获取了几个数据库。创建用户时,我想将数据复制到所有数据库。 使用phpadmin触发sql

  • 是否合适?
  • 问题2:我的请求中是否遗漏了一些内容?

我的要求:

CREATE TRIGGER `wordpress_database1`.`insert_user_from_database2` AFTER INSERT ON `wordpress_database2`.`wp_users`
FOR EACH
ROW
BEGIN
INSERT INTO `wordpress_database1`.`wp_users` (
ID,
user_login,
user_pass,
user_nicename,
user_email,
user_url,
user_registered,
user_activation_key,
user_status,
display_name
)
VALUES (
New.ID, New.user_login, New.user_pass, New.user_nicename, New.user_email, New.user_url, New.user_registered, New.user_activation_key, New.user_status, New.display_name
);
END;$$

我使用phpadmin sql收到此错误:

#1435 - Trigger in wrong schema

1 个答案:

答案 0 :(得分:2)

你还没有结束触发,

DELIMITER $$
CREATE TRIGGER `wordpress_database1`.`insert_user_from_database2` 
AFTER INSERT ON `wordpress_database2`.`wp_users`
FOR EACH
ROW
BEGIN
    INSERT INTO `wordpress_database1`.`wp_users` ( ID, user_login, user_pass, user_nicename,  user_email, user_url, user_registered, user_activation_key, user_status, display_name)
    VALUES ( New.ID, New.user_login, New.user_pass, New.user_nicename, New.user_email, New.user_url, New.user_registered, New.user_activation_key, New.user_status, New.display_name );
END $$
DELIMITER ;