mysql1054错误insert_MySQL错误1054:INSERT中的“字段列表”中的未知列

bd96500e110b49cbb3cd949968f18be7.png

I am using MySQL Workbench to create a database. I have a table called USERS defined as follows:

delimiter $$

CREATE TABLE `users` (

`UID` int(10) unsigned NOT NULL AUTO_INCREMENT

`USERNAME` varchar(20) NOT NULL,

`PASSWORD` varchar(64) NOT NULL

PRIMARY KEY (`UID`),

UNIQUE KEY `USER_NAME_UNIQUE` (`USERNAME`),

KEY `USERS_ROLES_REF_IDX` (`USER_ROLE`),

CONSTRAINT `USERS_ROLES_REF` FOREIGN KEY (`USER_ROLE`) REFERENCES `roles_ref` (`ROLE_NAME`)

) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8$$

CREATE

DEFINER=`root`@`localhost`

TRIGGER `MyDB`.`users_after_ins_trig`

AFTER INSERT ON `MyDB`.`users`

FOR EACH ROW

begin

insert into profiles (username) VALUES (new.username);

end

$$

When I go to forward engineer the database and create it, the script gives me the following error. As you can see from above, the username is part of the table. What gives?

Executing SQL script in server

ERROR: Error 1054: Unknown column 'username' in 'field list'

INSERT INTO `MyDB`.`USERS` (`UID`, `USERNAME`, `PASSWORD`)

VALUES (NULL, 'user1', 'blahpassword')

解决方案

Could it be that you are inserting into profiles from your trigger? I'm guessing profiles does not have a username column.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值