设为首页 加入收藏

TOP

MySQL里面的Replace 的用法和insert .. update 的用法
2011-06-12 21:28:14 来源: 作者: 【 】 浏览:48次 评论:0

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 的用法

您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇数据库在指定位置增加字段 下一篇MYSQl left join 查询性能和效率..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位