当前位置:网站首页>The difference between insert ignore and insert into
The difference between insert ignore and insert into
2022-06-26 07:07:00 【Talk to me】
INSERT IGNORE And INSERT INTO The difference is that INSERT IGNORE Will ignore the database already exists The data of , If there is no data in the database , Just insert new data , If you have data, skip this data . In this way, you can keep the existing data in the database , To insert data in the gap .
eg: insert ignore into table(name) select name from table2
mysql There are three kinds of statements to insert data :
insert into Means insert data , The database checks the primary key (PrimaryKey), If there is a repetition, an error will be reported ;
replace into Indicates insert replacement data , What is in the demand table PrimaryKey, perhaps unique Index words , If the database already has data , Replace with new data , If there's no data effect, it's the same as insert into equally ;
REPLACE Statement will return a number , To indicate the number of rows affected . This number is the sum of the number of rows deleted and inserted . If for a single line REPLACE The number is 1, Then a line is inserted , At the same time, no lines have been deleted . If the number is greater than 1, Before the new line is inserted , One or more old lines have been deleted . If the table contains multiple unique indexes , And the new row copies the values of different old rows in different unique indexes , It is possible that a single line replaces multiple old lines .
insert ignore Express , If the same record already exists in , Ignore the current new data ;
The difference is explained by the code below , as follows :
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;// Is still 1,“bb”,13, because id It's the primary key , Duplicate primary key but used ignore The error is ignored
replace into testtb(id,name,age)values(1,"aa",12);
select * from testtb; // The data becomes 1,"aa",12
边栏推荐
- 一文深入底层分析Redis对象结构
- 5,10,15,20-tetra (4-methoxycarbonylphenyl) porphyrin tcmpp purple crystal; Meso-5,10,15,20-tetra (4-methoxyphenyl) porphyrin tmopp|zn[t (4-mop) p] and co[t (4-mop) p] complexes
- . Net 20th anniversary! Microsoft sends a document to celebrate
- Redis系列——redis启动,客户端day1-2
- 5,10,15,20-tetra (4-bromophenyl) porphyrin (h2tppbr4) /5.2.15,10,15,20-tetra [4-[(3-aminophenyl) ethynyl] phenyl] porphyrin (tapepp) Qiyue porphyrin reagent
- Oracle中计算除法——解决除数为零报错
- Parameter index out of range (0 < 1) (1> number of parameters, which is 0
- Zraqnhydae
- Meso tetra (4-bromophenyl) porphyrin (tbpp); 5,10,15,20-tetra (4-methoxy-3-sulfonylphenyl) porphyrin [t (4-mop) ps4] supplied by Qiyue
- 【yolov4】基于yolov4深度学习网络目标检测MATLAB仿真
猜你喜欢

MySQL

Ppbpi-h-cr, ppbpimn Cr, ppbpi Fe Cr alkynyl crosslinked porphyrin based polyimide material Qiyue porphyrin reagent

i3wm 获取window class

面试被问Redis主从复制不会答?这13张图让你彻底弄明白

【图像增强】基于人工多重曝光融合AMEF实现图像去雾附matlab代码

Redis系列——5种常见数据类型day1-3

Bugku exercise ---misc--- prosperity, strength and democracy

Turris omnia: an open source router technology favored by hackers
![[yolov4] matlab simulation of network target detection based on yolov4 deep learning](/img/f9/31aba8f8bc04ccb16486dc87712ef6.png)
[yolov4] matlab simulation of network target detection based on yolov4 deep learning

MATLAB线性规划模型学习笔记
随机推荐
SQL中空值的判断
Crosslinked porphyrin based polyimide ppbpi-2, ppbpi-1-cr and ppbpi-2-cr; Porous porphyrin based hyperbranched polyimide (ppbpi-1, ppbpi-2) supplied by Qiyue
一项听起来大胆,并且非常牛逼的操作——复刻一个 Netflix
INSERT IGNORE 与INSERT INTO的区别
Here comes the apple ar/vr device exclusive system! Or named realityos
China's Ni MH battery industry development overview analysis and investment trend forecast report 2022 Edition
Network IO, disk IO
How to open an account in flush? Is it safe to open an account online?
Massive log collection tool flume
Global and Chinese silicon carbide monocrystal furnace market survey and future production and marketing demand analysis report 2022-2027
Numpy learning challenge level 1 - Download and installation of numpy
Tetradecanoxy tetraphenylporphyrin methacrylate mm-tpp-14c; Cetanoxy tetraphenyl porphyrin methacrylate mm-tpp-16c; Purple solid; Qiyue supply
C#实现给DevExpress中GridView表格指定列添加进度条显示效果——代码实现方式
Market development status analysis and investment risk outlook report of China's battery industry 2022-2027
Mysql操作数据库
[image fusion] MRI-CT image fusion based on gradient energy, local energy and PCA fusion rules with matlab code
淺析一道經典題
二叉树中和为某一值的路径(一)(二)(三)(剑指offer)
基于sanic的服务使用celery完成动态修改定时任务
My SQL (II)