执行插入操作时,出现异常constraint failed[0x1555]: UNIQUE constraint failed

  意思是:sqlite 唯一约束失败

  定位于某个表字段上,该字段是表的主键。

  原因:插入的数据中该主键字段值在表中已有存在的记录。

  解决方案:重新调整插入语句中该主键字段的值,保证约束唯一性。

  在SQLite中,执行SQL语句的sqlite3_exec()和sqlite3_prepare()两个核心方法的返回值都是一个整型数据,因此,当程序执行出现错误时,我们可以根据执行返回的整型数据来判断错误发生的原因。以下就是SQLite的错误码:

 C++ Code 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
   /* 成功 | Successful result */
   /* SQL错误 或 丢失数据库 | SQL error or missing database */
   /* SQLite 内部逻辑错误 | Internal logic error in SQLite */
   /* 拒绝访问 | Access permission denied */
   /* 回调函数请求取消操作 | Callback routine requested an abort */
   /* 数据库文件被锁定 | The database file is locked */
   /* 数据库中的一个表被锁定 | A table in the database is locked */
   /* 某次 malloc() 函数调用失败 | A malloc() failed */
   /* 尝试写入一个只读数据库 | Attempt to write a readonly database */
   /* 操作被 sqlite3_interupt() 函数中断 | Operation terminated by ite3_interrupt() */
   /* 发生某些磁盘 I/O 错误 | Some kind of disk I/O error occurred */
   /* 数据库磁盘映像不正确 | The database disk image is malformed */
   /* sqlite3_file_control() 中出现未知操作数 | Unknown opcode in ite3_file_control() */
   /* 因为数据库满导致插入失败 | Insertion failed because database is full */
   /* 无法打开数据库文件 | Unable to open the database file */
   /* 数据库锁定协议错误 | Database lock protocol error */
   /* 数据库为空 | Database is empty */
   /* 数据结构发生改变 | The database schema changed */
   /* 字符串或二进制数据超过大小限制 | String or BLOB exceeds size limit */
   /* 由于约束违例而取消 | Abort due to constraint violation */
   /* 数据类型不匹配 | Data type mismatch */
   /* 不正确的库使用 | Library used incorrectly */
   /* 使用了操作系统不支持的功能 | Uses OS features not supported on host */
   /* 授权失败 | Authorization denied */
   /* 附加数据库格式错误 | Auxiliary database format error */
   /* 传递给sqlite3_bind()的第二个参数超出范围 | 2nd parameter to sqlite3_bind out of range */
   /* 被打开的文件不是一个数据库文件 | File opened that is not a database file */
  /* sqlite3_step() 已经产生一个行结果 | sqlite3_step() has another row ready */
  /* sqlite3_step() 完成执行操作 | sqlite3_step() has finished executing */

Sqlite - constraint failed[0x1555]: UNIQUE constraint failed的更多相关文章

  1. sqlite3, IntegrityError: UNIQUE constraint failed when inserting a value

    sqlite报错: sqlite3.IntegrityError: UNIQUE constraint failed: IMAGESTATUE.ID 解决方案: Change INSERT to IN ...

  2. Unique constraint on single String column with GreenDao2

    转:http://software.techassistbox.com/unique-constraint-on-single-string-column-with-greendao_384521.h ...

  3. ORA-00001: unique constraint (...) violated解决方案

    ORA-00001: unique constraint (...) violated 的解决方案 今天往Oracle数据库里插入数据一条记录的时候,报错了, 控制台抛出异常:违反唯一性约定, 我以为 ...

  4. Oracle 唯一 约束(unique constraint) 与 索引(index) 关系说明

    一. 官网对Unique Constraints说明 http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/datainte.h ...

  5. ORA-00001: unique constraint (...) violated并不一定是数据冲突

    原文链接:http://blog.163.com/jet_it_life/blog/static/205097083201301410303931/ 收到一位测试人员RAISE的JIRA,说在某张表上 ...

  6. Unique constraint on single String column with GreenDao

    转:http://stackoverflow.com/questions/22070281/greendao-support-for-unique-constraint-on-multiple-col ...

  7. Oracle之唯一性约束(UNIQUE Constraint)使用方法具体解释

    Oracle | PL/SQL唯一索引(Unique Constraint)使用方法 1 目标 用演示样例演示怎样创建.删除.禁用和使用唯一性约束. 2 什么是唯一性约束? 唯一性约束指表中一个字段或 ...

  8. SQL UNIQUE Constraint

    SQL UNIQUE Constraint The UNIQUE constraint uniquely identifies each record in a database table. The ...

  9. mybatis批量插入oracle时报错:unique constraint (table name) violated

    mybatis批量插入oracle时报错:unique constraint (table name) violated,是因为插入的集合中有两条相同唯一约束的数据.

随机推荐

  1. 逻辑回归的相关问题及java实现

    本讲主要说下逻辑回归的相关问题和详细的实现方法 1. 什么是逻辑回归 逻辑回归是线性回归的一种,那么什么是回归,什么是线性回归 回归指的是公式已知,对公式中的未知參数进行预计,注意公式必须是已知的,否 ...

  2. Mysql字符串中有数字的排序问题

    此方法是我见过最聪明的写法,不过不知道有没有隐含的bug: 参考地址 select id, col from tableName order by length(col) asc, col asc这种 ...

  3. ubuntu 将"/TMP"挂载到内存中

    一.修改"/etc/fstab"文件:        sudo gedit /etc/fstab  二.在文件中添加下列语句:   1,     # / was on /dev/s ...

  4. 腾讯QQ的发展与未来

    http://wenku.baidu.com/view/15166ddfc1c708a1284a447d.html 腾讯QQ的发展与未来

  5. Android访问php webservice

    如果是PHP做的服务端,而我们要用android去访问,怎么办?当然可以用REST,但也可以用点笨的方法,比如可以让PHP的服务端返回JSON或XML数据,而Android端则可以用APACHE的ht ...

  6. 摘:数据结构各种算法实现(C++模板)

    目  录 1.顺序表. 1 Seqlist.h 1 Test.cpp 6 2.单链表. 8 ListNode.h 8 SingleList.h 10 test.cpp 20 3.双向链表. 22 No ...

  7. javascript sort方法容易犯错的地方

    sort方法用来对数组排序非常方便.但是sort(func)这个func参数的构造却很容易混淆. sort判断func的返回值是判断正负,而不是ture和false.所以务必保证返回值要么负数要么正数 ...

  8. 温故而知新 通过chrome tool 查看是否产生闭包

    function foo() { var a = 20 var b = 30 function bar() { debugger; return a + b } return bar; } var b ...

  9. Ubuntu14.04单机版kubernetes安装指导

    转:http://dockone.io/article/950 概述本文主要讲述如何在Ubuntu系统上安装kubernetes,网络上也有许多相关的文章,感觉都不是很清晰,这里我将自己的安装实践给大 ...

  10. [Jobdu] 题目1139:最大子矩阵

    题目描述: 已知矩阵的大小定义为矩阵中所有元素的和.给定一个矩阵,你的任务是找到最大的非空(大小至少是1 * 1)子矩阵.比如,如下4 * 4的矩阵 0 -2 -7 09 2 -6 2-4 1 -4 ...