[英]MySQL REPLACE doesn't works how expected
My table (name is primary key, id is unique key): 我的表(名称是主键,id是唯一键):
|| name || id || col_1 ||
===================================
|| test1 ||1234|| test999 ||
Query: 查询:
REPLACE INTO `table` (`name`, `col_1`) VALUES ('NOTTEST1', 'test999').
In this case, it mustn't replace row, but it does. 在这种情况下,它不能替换行,但是可以。 What am I doing wrong?
我究竟做错了什么?
It works well! 效果很好!
can you check if table structure is set correctly. 您可以检查表结构是否设置正确。 Here's what I did:
这是我所做的:
Table: 表:
CREATE TABLE `test` (
`name` varchar(25) NOT NULL,
`id` int(11) DEFAULT NULL,
`col_1` varchar(25) DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into `test`(`name`,`id`,`col_1`) values ('test1',1234,'test999');
And when I tried this: 当我尝试这个:
REPLACE INTO test (`name`,`col_1`) VALUES('test11','admin');
It created a new record. 它创造了一个新记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.