mysql insert into replace into insert ignore into 用法
来源:互联网 发布:数据库注释注入防护 编辑:程序博客网 时间:2024/06/04 19:19
mysql中insert into和replace into以及insert ignore用法区别:
mysql中常用的三种插入数据的语句:
insert into表示插入数据,数据库会检查主键,如果出现重复会报错;
replace into表示插入替换数据,需求表中有PrimaryKey,或者unique索引,如果数据库已经存在数据,则用新数据替换,如果没有数据效果则和insert into一样;
insert ignore into表示,如果中已经存在相同的记录,则忽略当前新数据;
下面通过代码说明之间的区别,如下:
转自:http://mxdxm.iteye.com/blog/1153513
mysql中常用的三种插入数据的语句:
insert into表示插入数据,数据库会检查主键,如果出现重复会报错;
replace into表示插入替换数据,需求表中有PrimaryKey,或者unique索引,如果数据库已经存在数据,则用新数据替换,如果没有数据效果则和insert into一样;
insert ignore into表示,如果中已经存在相同的记录,则忽略当前新数据;
下面通过代码说明之间的区别,如下:
create table testtb( id int not null primary key, name varchar(50), age int );
insert into testtb(id,name,age) values(1,"bb",13); select * from testtb; insert ignore into testtb(id,name,age) values(1,"aa",13); select * from testtb;//仍是1,“bb”,13,因为id是主键,出现主键重复但使用了ignore则错误被忽略 replace into testtb(id,name,age) values(1,"aa",12); select * from testtb; //数据变为1,"aa",12
转自:http://mxdxm.iteye.com/blog/1153513
0 0
- mysql insert into replace into insert ignore into 用法
- mysql insert into & replace into & insert ignore into
- mysql中insert into和replace into以及insert ignore用法区别
- mysql中insert into和replace into以及insert ignore用法区别
- mysql中insert into和replace into以及insert ignore用法区别
- mysql中insert into和replace into以及insert ignore用法区别
- MySQL中INSERT IGNORE INTO和REPLACE INTO的使用
- MySQL中的insert ignore into, replace into等的一些用法总结
- MySQL中的insert ignore into, replace into等的一些用法总结
- MySQL中的insert ignore into, replace into等的一些用法总结
- MySQL中的insert ignore into, replace into等的一些用法总结
- MySQL中的insert ignore into, replace into等的一些用法
- INSERT IGNORE 与INSERT INTO ,replace into 的区别
- MySQL replace into 用法(insert into 的增强版)
- MySQL replace into 用法(insert into 的增强版)
- MySQL replace into 用法(insert into 的增强版)
- MySQL replace into 用法(insert into 的增强版)
- MySQL replace into 用法(insert into 的增强版)
- 2017sdut省赛选拔(1)--poj1631-(nlogn的最长上升子序列)
- Online Caisno Malaysia iBET Live Casino Rebate 0.75% Unlimited(iBET Live Casino, Live Casino Rebate,
- 第十一章 Shell 的变量功能
- 【day-11】寻找前K大个数-堆排序
- 设计模式之命令模式
- mysql insert into replace into insert ignore into 用法
- MySQL开启慢查询日志slow_query_log
- Linux中常用软件安装(基于Ubuntu)
- mysql infile/outfile 导入导出
- TOMCAT 目录结构
- 第十一章 命令别名与历史命令
- 计算机中缺失MSVCR110.dll,MSVCP120D.dll等问题解决
- 第十一章 Bash Shell 的操作环境
- spring cloud网关zuul源码Request生命周期管理