⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pragma.html

📁 SQLite is a software library that implements a self-contained, serverless, zero-configuration, trans
💻 HTML
📖 第 1 页 / 共 3 页
字号:
    <p>The empty-result-callbacks flag affects the <a href="c3ref/exec.html">sqlite3_exec()</a> API only.    Normally, when the empty-result-callbacks flag is cleared, the    callback function supplied to the <a href="c3ref/exec.html">sqlite3_exec()</a> call is not invoked    for commands that return zero rows of data. When empty-result-callbacks    is set in this situation, the callback function is invoked exactly once,    with the third parameter set to 0 (NULL). This is to enable programs      that use the <a href="c3ref/exec.html">sqlite3_exec()</a> API to retrieve column-names even when    a query returns no data.    </p><a name="pragma_encoding"></a><li><p><b>PRAGMA encoding;       <br>PRAGMA encoding = "UTF-8";       <br>PRAGMA encoding = "UTF-16";       <br>PRAGMA encoding = "UTF-16le";       <br>PRAGMA encoding = "UTF-16be";</b></p>    <p>In first form, if the main database has already been    created, then this pragma returns the text encoding used by the    main database, one of "UTF-8", "UTF-16le" (little-endian UTF-16    encoding) or "UTF-16be" (big-endian UTF-16 encoding).  If the main    database has not already been created, then the value returned is the    text encoding that will be used to create the main database, if     it is created by this session.</p>    <p>The second and subsequent forms of this pragma are only useful if    the main database has not already been created. In this case the     pragma sets the encoding that the main database will be created with if    it is created by this session. The string "UTF-16" is interpreted    as "UTF-16 encoding using native machine byte-ordering".  If the second    and subsequent forms are used after the database file has already    been created, they have no effect and are silently ignored.</p>    <p>Once an encoding has been set for a database, it cannot be changed.</p>    <p>Databases created by the <a href="lang_attach.html">ATTACH</a> command always use the same encoding    as the main database.</p></li><a name="pragma_full_column_names"></a><li><p><b>PRAGMA full_column_names;       <br>PRAGMA full_column_names = </b><i>0 | 1</i><b>;</b></p>    <p>Query or change the full-column-names flag. This flag affects    the way SQLite names columns of data returned by <a href="lang_select.html">SELECT</a> statements    when the expression for the column is a table-column name or the    wildcard "*".  Normally, such result columns are named    &lt;table-name/alias&gt;&lt;column-name&gt; if the <a href="lang_select.html">SELECT</a> statement joins     two or    more tables together, or simply &lt;column-name&gt; if the <a href="lang_select.html">SELECT</a>    statement queries a single table. When the full-column-names flag    is set, such columns are always named &lt;table-name/alias&gt;    &lt;column-name&gt; regardless of whether or not a join is performed.    </p>    <p>If both the short-column-names and full-column-names are set,    then the behaviour associated with the full-column-names flag is    exhibited.    </p></li><a name="pragma_fullfsync"></a><li><p><b>PRAGMA fullfsync       <br>PRAGMA fullfsync = </b><i>0 | 1</i><b>;</b></p>    <p>Query or change the fullfsync flag. This flag affects    determines whether or not the F_FULLFSYNC syncing method is used    on systems that support it.  The default value is off.  As of this    writing (2006-02-10) only Mac OS X supports F_FULLFSYNC.    </p></li><a name="pragma_incremental_vacuum"></a><li><p><b>PRAGMA incremental_vacuum</b><i>(N)</i><b>;</b></p>    <p>The incremental_vacuum pragma causes up to <i>N</i> pages to    be removed from the freelist.  The database file is truncated by    the same amount.  The incremental_vacuum pragma has no effect if    the database is not in    <a href="#pragma_auto_vacuum">auto_vacuum==incremental</a> mode    or if there are no pages on the freelist.  If there are fewer than    <i>N</i> pages on the freelist, then the entire freelist is cleared.</p>    <p>As of <a href="releaselog/3_4_0.html">version 3.4.0</a> (the first version that supports    incremental_vacuum) this feature is still experimental.  Possible    future changes include enhancing incremental vacuum to do    defragmentation and node repacking just as the full-blown    <a href="lang_vacuum.html">VACUUM</a> command does.  And    incremental vacuum may be promoted from a pragma to a separate    SQL command, or perhaps some variation on the <a href="lang_vacuum.html">VACUUM</a> command.    Programmers are cautioned to not become enamored with the    current syntax or functionality as it is likely to change.</p></li><a name="pragma_legacy_file_format"></a><li><p><b>PRAGMA legacy_file_format;       <br>PRAGMA legacy_file_format = <i>ON | OFF</i></b></p>    <p>This pragma sets or queries the value of the legacy_file_format    flag.  When this flag is on, new SQLite databases are created in    a file format that is readable and writable by all versions of    SQLite going back to 3.0.0.  When the flag is off, new databases    are created using the latest file format which might not be    readable or writable by older versions of SQLite.</p>    <p>When the pragma is issued with no argument, it returns the    setting of the flag.  This pragma does <u>not</u> tell which    file format the current database is using.  It tells what format    will be used by any newly created databases.</p>    <p>This flag only affects newly created databases.  It has no    effect on databases that already exist.</p></li><a name="pragma_locking_mode"></a><li><p><b>PRAGMA locking_mode;       <br>PRAGMA locking_mode = <i>NORMAL | EXCLUSIVE</i></b></p>    <p>This pragma sets or queries the database connection locking-mode.     The locking-mode is either NORMAL or EXCLUSIVE.    <p>In NORMAL locking-mode (the default), a database connection    unlocks the database file at the conclusion of each read or    write transaction. When the locking-mode is set to EXCLUSIVE, the    database connection never releases file-locks. The first time the    database is read in EXCLUSIVE mode, a shared lock is obtained and     held. The first time the database is written, an exclusive lock is    obtained and held.</p>    <p>Database locks obtained by a connection in EXCLUSIVE mode may be    released either by closing the database connection, or by setting the    locking-mode back to NORMAL using this pragma and then accessing the    database file (for read or write). Simply setting the locking-mode to    NORMAL is not enough - locks are not be released until the next time    the database file is accessed.</p>    <p>There are two reasons to set the locking-mode to EXCLUSIVE. One    is if the application actually wants to prevent other processes from    accessing the database file. The other is that a small number of    filesystem operations are saved by optimizations enabled in this    mode. This may be significant in embedded environments.</p>    <p>When the locking_mode pragma specifies a particular database,    for example:</p>    <blockquote>PRAGMA <b>main.</b>locking_mode=EXCLUSIVE;    </blockquote>    <p>Then the locking mode applies only to the named database.  If no    database name qualifier preceeds the "locking_mode" keyword then    the locking mode is applied to all databases, including any new    databases added by subsequent <a href="lang_attach.html">ATTACH</a> commands.</p>   <p>The "temp" database (in which TEMP tables and indices are stored)   always uses exclusive locking mode.  The locking mode of temp cannot   be changed.  All other databases use the normal locking mode by default   and are affected by this pragma.</p></li><a name="pragma_page_size"></a><li><p><b>PRAGMA page_size;       <br>PRAGMA page_size = </b><i>bytes</i><b>;</b></p>    <p>Query or set the page-size of the database. The page-size    may only be set if the database has not yet been created. The page    size must be a power of two greater than or equal to 512 and less    than or equal to 8192. The upper limit may be modified by setting    the value of macro SQLITE_MAX_PAGE_SIZE during compilation.  The    maximum upper bound is 32768.    </p></li><a name="pragma_max_page_count"></a><li><p><b>PRAGMA max_page_count;       <br>PRAGMA max_page_count = </b><i>N</i><b>;</b></p>    <p>Query or set the maximum number of pages in the database file.    Both forms of the pragma return the maximum page count.  The second    form attempts to modify the maximum page count.  The maximum page    count cannot be reduced below the current database size.    </p></li><a name="pragma_read_uncommitted"></a><li><p><b>PRAGMA read_uncommitted;       <br>PRAGMA read_uncommitted = </b><i>0 | 1</i><b>;</b></p>    <p>Query, set, or clear READ UNCOMMITTED isolation.  The default isolation    level for SQLite is SERIALIZABLE.  Any process or thread can select    READ UNCOMMITTED isolation, but SERIALIZABLE will still be used except    between connections that share a common page and schema cache.    Cache sharing is enabled using the    <a href="c3ref/enable_shared_cache.html">sqlite3_enable_shared_cache()</a> API and is only available between    connections running the same thread.  Cache sharing is off by default.    </p></li><a name="pragma_short_column_names"></a><li><p><b>PRAGMA short_column_names;       <br>PRAGMA short_column_names = </b><i>0 | 1</i><b>;</b></p>    <p>Query or change the short-column-names flag. This flag affects    the way SQLite names columns of data returned by <a href="lang_select.html">SELECT</a> statements    when the expression for the column is a table-column name or the    wildcard "*".  Normally, such result columns are named    &lt;table-name/alias&gt;lt;column-name&gt; if the <a href="lang_select.html">SELECT</a> statement     joins two or more tables together, or simply &lt;column-name&gt; if     the <a href="lang_select.html">SELECT</a> statement queries a single table. When the short-column-names     flag is set, such columns are always named &lt;column-name&gt;     regardless of whether or not a join is performed.    </p>    <p>If both the short-column-names and full-column-names are set,    then the behaviour associated with the full-column-names flag is    exhibited.    </p></li><a name="pragma_synchronous"></a><li><p><b>PRAGMA synchronous;       <br>PRAGMA synchronous = FULL; </b>(2)<b>       <br>PRAGMA synchronous = NORMAL; </b>(1)<b>       <br>PRAGMA synchronous = OFF; </b>(0)</p>    <p>Query or change the setting of the "synchronous" flag.      The first (query) form will return the setting as an     integer.  When synchronous is FULL (2), the SQLite database engine will    pause at critical moments to make sure that data has actually been     written to the disk surface before continuing.  This ensures that if    the operating system crashes or if there is a power failure, the database    will be uncorrupted after rebooting.  FULL synchronous is very     safe, but it is also slow.      When synchronous is NORMAL, the SQLite database    engine will still pause at the most critical moments, but less often    than in FULL mode.  There is a very small (though non-zero) chance that    a power failure at just the wrong time could corrupt the database in    NORMAL mode.  But in practice, you are more likely to suffer    a catastrophic disk failure or some other unrecoverable hardware    fault.    With synchronous OFF (0), SQLite continues without pausing    as soon as it has handed data off to the operating system.    If the application running SQLite crashes, the data will be safe, but    the database might become corrupted if the operating system    crashes or the computer loses power before that data has been written    to the disk surface.  On the other hand, some    operations are as much as 50 or more times faster with synchronous OFF.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -