首页 > 数据库 >Continue SQL query even on errors

Continue SQL query even on errors

时间:2023-11-06 15:33:44浏览次数:37  
标签:even INSERT use syntax Continue want sql query

try
mysql --force < sample_data.sql

Mysql help section says
 -f, --force         Continue even if we get an sql error.

----------------------
You could also use INSERT IGNORE

INSERT IGNORE INTO mytable
 (primaryKey, field1, field2)
VALUES
 ('1', 1, 2),
 ('1', 3, 4), //will not be inserted
 ('2', 5, 6); //will be inserted


----------------------
You can use INSERT... IGNORE syntax if you want to take no action when there's a duplicate record.

You can use REPLACE INTO syntax if you want to overwrite an old record with a new one with the same key.

Or, you can use INSERT... ON DUPLICATE KEY UPDATE syntax if you want to perform an update to the record instead when you encounter a duplicate.


----------------------

 

REF:

http://stackoverflow.com/questions/5366436/continue-sql-query-even-on-errors



标签:even,INSERT,use,syntax,Continue,want,sql,query
From: https://blog.51cto.com/emanlee/8212708

相关文章

  • 06前端开发jQuery
    DOM操作标签'''在起变量名的时候如果该变量指向的是一个标签那么建议使用xxxEleeg:aEle\pEle\divEle\spanEle'''#动态创建一个a标签并添加到页面指定位置varaEle=document.createElement('a')#创建a标签aEle.href='https://www.sogo.com/'#......
  • How to prevent salinization of land
    Howtopreventsalinizationofland一.Measures:1.Itcanbeanalyzedandoperatedbylevelingtheland,improvingcultivation,fertilization,sowing,planting,intersticulture,etc.,strengthenthemanagementofChineseagriculturalenterprises,andtry......
  • SATA基础+更改终端颜色+PCI.ids位置+Linux和Windows的scanf+C语言C++的局部变量与全局
    SATA基础https://zhuanlan.zhihu.com/p/554251608物理信号物理层功能时钟恢复:对于高频传输,一般是采用差分信号传输,并且没有单独的时钟,时钟存在于编码内部串并转换:对于高频传输,串联信号可以做到更高的频率。字节对其:8/10编码转换的10bit对其链路层、传输层链路层和传输......
  • while中使用break和continue
    while中使用break和continue:count=0##计数器whileTrue:s=input('请输入内容:')ifs=='退出':print(count)print('退出!')break##退出循环if'生气'ins:print(count)continue##本次循环没结束,要求重新输入......
  • sse_server sent event_eventSource_websocket替代_socketio替代_服务器端事件
    eventsourcebackend#-*-coding:utf-8-*-#这段代码是使用FastAPI框架创建一个简单的服务器端事件(Server-SentEvents,SSE)的示例。以下是对代码的详细解析:#1.`importjson,random,...`:这行代码导入了需要的Python模块。#2.`event_router=APIRouter()`:这行代码创建......
  • 如何使用Event事件对异步线程进行阻塞和放行?
    //定义信号事件staticAutoResetEventautoResetEvent=newAutoResetEvent(false);//定义要异步执行的方法staticvoidA()    {        for(inti=0;i<10;i++)        {            autoResetEvent.WaitOne();//阻塞等待信号......
  • do循环语句(打印1-10)(加入continue)
    #include<stdio.h>intmain(){  inti=1;  do  {    if(i==5)      continue;    printf("%d",i);    i++;  }  while(i<=10);  return0;}......
  • 如何获取URL参数使用jQuery或纯JavaScript?
    内容来自DOChttps://q.houxu6.top/?s=如何获取URL参数使用jQuery或纯JavaScript?我看过很多jQuery示例,其中参数的大小和名称是未知的。我的URL只会有一个字符串:http://example.com?sent=yes我只想检测:sent是否存在?它是否等于"yes"?最佳解决方案这里。vargetUrlPar......
  • 如何为Windows服务增加Log4net和EventLog的日志功能
    一、简介最近在做一个项目的时候,需要该项目自动启动、自动运行,不需要认为干预。不用说,大家都知道用什么技术,那就是Windows服务。在以前的NetFramework平台下,Windows服务是一个不错的选择。如果现在在NetCore版本,或者Net5.0以及以上版本,我们会有另外一个选择,这就是......
  • 【zabbix】configure: error: Unable to use libevent (libevent check failed)解决方
    安装zabbix,在zabbix目录下执行编译命令时报错configure:error:Unabletouselibevent(libeventcheckfailed),如图:说明:新服务器,一般依赖不足,需要视情况安装依赖,问题解决。解决方案:yuminstalllibevent-devel-y......