【www.gdgbn.com--mysql教程】

MySQL里面的Replace 的用法和insert .. update 的用法  
drop table if exists t;  
create table t(id int not null auto_increment primary key, name varchar(100));  
create unique index idx_t on t(name);  
replace into t (name) values("first"); -- 数据的id=1  
select * from t;  
replace into t (name) values("first"); -- 数据的id变成了2  
select * from t;  
insert into t(name) values("second"); -- 数据的id为3  
select * from t;  
insert into t(name) values("second") on duplicate key update name="second2"; -- 依然为3,但内容变了  
select * from t; 
MySQL里面的Replace 的用法和insert .. update 的用法

本文来源:http://www.gdgbn.com/shujuku/23508/