ERROR 1022: Can”t write; duplicate key in table “#sql-434_2”
SQL Statement:
ALTER TABLE `onlineorderdb`.`tb_message`
ADD CONSTRAINT `user_id`
FOREIGN KEY (`user_id`)
REFERENCES `onlineorderdb`.`tb_user` (`user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
ERROR: Error when running failback script. Details follow.
ERROR 1046: No database selected
SQL Statement:
CREATE TABLE `tb_message` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`subject` varchar(45) NOT NULL,
`content` varchar(200) DEFAULT NULL,
`mg_date` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
tb_user表
tb_message表
SQL Statement:
ALTER TABLE `onlineorderdb`.`tb_message`
ADD CONSTRAINT `user_id`
FOREIGN KEY (`user_id`)
REFERENCES `onlineorderdb`.`tb_user` (`user_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
ERROR: Error when running failback script. Details follow.
ERROR 1046: No database selected
SQL Statement:
CREATE TABLE `tb_message` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`subject` varchar(45) NOT NULL,
`content` varchar(200) DEFAULT NULL,
`mg_date` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
tb_user表
tb_message表
解决方案