[Database] commonly used data, methods and error codes in SQLite ..

Source: Internet
Author: User
Tags sql error
Sqlite3 *             // A session Of   Database  Connectionsqlite3_stmt  *    //  SQL statement object  > Supported Data Types Of   Column  It seems that sqlite2 only supports the text type, which is greatly enriched in sqlite3.  Text  Numeric  Integer  Real  None  >  Methods: sqlite3 has 82 functions, but there are several commonly used functions:  // Libraryinitialization /  Shutdown  Int  Sqlite3_initialize (void );  Int  Sqlite3_shutdown (void );  //   Database Modify /  Query Int Sqlite3_open (const Char  * , Sqlite3 **  );  Int Sqlite3_close (sqlite3 *  );  Int Sqlite3_exec (sqlite3 * , Const Char   * SQL, sqlite_callback, void * , Char **  );  Int Sqlite3_prepare (sqlite3 * DB, const Char   * Zsql, Int Nbyte, sqlite3_stmt ** Ppstmt, const Char   **  Pztail );  Int Sqlite3_step (sqlite3_stmt *  Pstmt ); Int Sqlite3_finalize (sqlite3_stmt *  Pstmt)  Int Sqlite3_reset (sqlite3_stmt *  Pstmt );  //  Bindingsqlite3_bind_blob (sqlite3_stmt  * Pstmt, Int I, const void * Zdata, Int Ndata, void ( * Xdel) (void*  ));  Int Sqlite3_bind_xxx (sqlite3_stmt * Pstmt, Int  I, xxx Rvalue)  Int Sqlite3_bind_parameter_index (sqlite3_stmt * Pstmt, const Char   *  Zname );  Int Sqlite3_clear_bindings (sqlite3_stmt *  Pstmt ); //  Get Data  Int Sqlite3_get_table (sqlite3 * , Const Char   * SQL, Char  *** Result, Int   * Nrow, Int   * Ncolumn, Char   **  Errmsg); const unsigned Char  * Sqlite3_column_text (sqlite3_stmt * Pstmt, Int  I); const void  * Sqlite3_column_blob (sqlite3_stmt * Pstmt, Int  I); sqlite3_column_int (sqlite3_stmt  * Pstmt, Int  I );  //  Error Handling Int Sqlite3_busy_handler (sqlite3 * DB, Int ( * Xbusy) (void * , Int ), Void *  Parg) sqlite3_errcode () sqlite3_errmsg () sqlite3 some functions carry 16 or V2 behind the ass. The former indicates UTF16 encoding, and the latter indicates the enhanced version of the function, some Windows API exists.  >  Error codes:  --  -------------------------------------------------------- # Define sqlite_ OK  0     /*  Successful result  */  # Define sqlite_error  1     /*  SQL error or missing Database  */  # Define sqlite_internal  2     /*  Internal Logic error in SQLite */  # Define sqlite_perm  3     /*  Access permission denied  */  # Define sqlite_abort  4     /*  Callback routine requested an abort  */  # Define sqlite_busy  5     /* The database file is locked  */  # Define sqlite_locked  6     /*  A table in the database is locked  */  # Define sqlite_nomem  7     /*  A malloc () failed  */  # Define sqlite_readonly  8    /*  Attempt to write a readonly Database  */  # Define sqlite_interrupt  9     /*  Operation terminated by sqlite3_interrupt ()  */  # Define sqlite_ioerr  10     /*  Some kind of disk I/O error occurred  */  # Define sqlite_corrupt 11     /*  The database disk image is malformed  */  # Define sqlite_notfound  12     /*  Unknown opcode in sqlite3_file_control ()  */  # Define sqlite_full  13     /*  Insertion failed because database is full  */ # Define sqlite_cantopen  14     /*  Unable to open the database file  */  # Define sqlite_protocol  15     /*  Database lock protocol error  */  # Define sqlite_empty  16     /*  Database is empty */  # Define sqlite_schema  17     /*  The database schema changed  */  # Define sqlite_toobig  18     /*  String or blob exceeds size limit  */  # Define sqlite_constraint  19     /* Abort due to Constraint Violation  */  # Define sqlite_mismatch  20     /*  Data Type Mismatch  */  # Define sqlite_misuse  21     /*  Library used incorrectly  */  # Define sqlite_nolfs  22    /*  Uses OS features not supported on host  */  # Define sqlite_auth  23     /*  Authorization denied  */  # Define sqlite_format  24     /*  Auxiliary database format Error  */  # Define sqlite_range 25     /*  2nd parameter to sqlite3_bind out of range  */  # Define sqlite_notadb  26     /*  File opened that is not a database file  */  # Define sqlite_row  100    /*  Sqlite3_step () has another row ready  */ # Define sqlite_done  101    /*  Sqlite3_step () has finished executing  */  --  ---------------------------------------------------------------  >   Transaction  (Transaction Processing) SQLite supports transaction. In order to improve performance, it is necessary to make similar operations into a transaction as much as possible. The performance of deleting 1 million data records at a time is definitely not the same as that of deleting data at a time of 1 million. In this case, make a unified transaction, and it is also easy to roll back.  >  Thread safesqlite is thread-safe, but the sqlite_threadsafe preprocessing macro must be set to 1 during compilation. In 3.3 . 1  Before the version, a sqlite3 structure can only be used to call the same thread created by sqlite3_open. You cannot open a database in a thread and pass the database handle to another process. In 3.  3  In Versions later than. 1, as long as the connection does not hold the fcntl () lock, it is safe to move the handle between threads.  >  SQLite pragmathe Pragma statement  Is An SQL extension specific To SQLite And Used To Modify the operation Of The SQLite Library Or   To Query the SQLite Library For Internal (non -  Table ) Data. Pragma command is a special command. It is used to modify SQLite database operations or query databases to obtain internal (non-table) data • automated • automatic_index • cache_size • automated • elastic • collation_list • compile_options • database_list • encoding • converged • fullfsync • converged • indexing • index_info • index_list • integrity_check • journal_mode • • Strong • locking_mode • max_page_count • page_count • page_size • parser_trace • quick_check • Strong • synchronous • table_info • temp_store • user_version • Strong • wal_autocheckpoint • wal_checkpoint • writable_schema 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.