天天看點

SQLite錯誤碼

在SQLite中,執行SQL語句的sqlite3_exec()和sqlite3_prepare()兩個核心方法的傳回值都是一個整型資料,是以,當程式執行出現錯誤時,我們可以根據執行傳回的整型資料來判斷錯誤發生的原因。以下就是SQLite的錯誤碼:

1 #define SQLITE_OK           0   /* 成功 | Successful result */
 2 /* 錯誤碼開始 */
 3 #define SQLITE_ERROR        1   /* SQL錯誤 或 丢失資料庫 | SQL error or missing database */
 4 #define SQLITE_INTERNAL     2   /* SQLite 内部邏輯錯誤 | Internal logic error in SQLite */
 5 #define SQLITE_PERM         3   /* 拒絕通路 | Access permission denied */
 6 #define SQLITE_ABORT        4   /* 回調函數請求取消操作 | Callback routine requested an abort */
 7 #define SQLITE_BUSY         5   /* 資料庫檔案被鎖定 | The database file is locked */
 8 #define SQLITE_LOCKED       6   /* 資料庫中的一個表被鎖定 | A table in the database is locked */
 9 #define SQLITE_NOMEM        7   /* 某次 malloc() 函數調用失敗 | A malloc() failed */
10 #define SQLITE_READONLY     8   /* 嘗試寫入一個隻讀資料庫 | Attempt to write a readonly database */
11 #define SQLITE_INTERRUPT    9   /* 操作被 sqlite3_interupt() 函數中斷 | Operation terminated by sqlite3_interrupt() */
12 #define SQLITE_IOERR       10   /* 發生某些磁盤 I/O 錯誤 | Some kind of disk I/O error occurred */
13 #define SQLITE_CORRUPT     11   /* 資料庫磁盤映像不正确 | The database disk image is malformed */
14 #define SQLITE_NOTFOUND    12   /* sqlite3_file_control() 中出現未知操作數 | Unknown opcode in sqlite3_file_control() */
15 #define SQLITE_FULL        13   /* 因為資料庫滿導緻插入失敗 | Insertion failed because database is full */
16 #define SQLITE_CANTOPEN    14   /* 無法打開資料庫檔案 | Unable to open the database file */
17 #define SQLITE_PROTOCOL    15   /* 資料庫鎖定協定錯誤 | Database lock protocol error */
18 #define SQLITE_EMPTY       16   /* 資料庫為空 | Database is empty */
19 #define SQLITE_SCHEMA      17   /* 資料結構發生改變 | The database schema changed */
20 #define SQLITE_TOOBIG      18   /* 字元串或二進制資料超過大小限制 | String or BLOB exceeds size limit */
21 #define SQLITE_CONSTRAINT  19   /* 由于限制違例而取消 | Abort due to constraint violation */
22 #define SQLITE_MISMATCH    20   /* 資料類型不比對 | Data type mismatch */
23 #define SQLITE_MISUSE      21   /* 不正确的庫使用 | Library used incorrectly */
24 #define SQLITE_NOLFS       22   /* 使用了作業系統不支援的功能 | Uses OS features not supported on host */
25 #define SQLITE_AUTH        23   /* 授權失敗 | Authorization denied */
26 #define SQLITE_FORMAT      24   /* 附加資料庫格式錯誤 | Auxiliary database format error */
27 #define SQLITE_RANGE       25   /* 傳遞給sqlite3_bind()的第二個參數超出範圍 | 2nd parameter to sqlite3_bind out of range */
28 #define SQLITE_NOTADB      26   /* 被打開的檔案不是一個資料庫檔案 | File opened that is not a database file */
29 #define SQLITE_ROW         100  /* sqlite3_step() 已經産生一個行結果 | sqlite3_step() has another row ready */
30 #define SQLITE_DONE        101  /* sqlite3_step() 完成執行操作 | sqlite3_step() has finished executing */