pragma.html

来自「sqlite 3.3.8 支持加密的版本」· HTML 代码 · 共 657 行 · 第 1/3 页

HTML
657
字号
<html dir="LTR" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:ndoc="urn:ndoc-preprocess">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" />
    <title>PRAGMA</title>
    <link rel="stylesheet" type="text/css" href="ndoc.css"> </link>
    <link rel="stylesheet" type="text/css" href="user.css"> </link>
    <script type="text/javascript" src="ndoc.js"> </script>
  </head>
  <body style="display: none;">
    <input type="hidden" id="userDataCache" class="userDataStyle" />
    <input type="hidden" id="hiddenScrollOffset" />
    <img id="dropDownImage" style="display:none; height:0; width:0;" src="drpdown.gif" />
    <img id="dropDownHoverImage" style="display:none; height:0; width:0;" src="drpdown_orange.gif" />
    <img id="collapseImage" style="display:none; height:0; width:0;" src="collapse.gif" />
    <img id="expandImage" style="display:none; height:0; width:0;" src="exp.gif" />
    <img id="collapseAllImage" style="display:none; height:0; width:0;" src="collall.gif" />
    <img id="expandAllImage" style="display:none; height:0; width:0;" src="expall.gif" />
    <img id="copyImage" style="display:none; height:0; width:0;" src="copycode.gif" />
    <img id="copyHoverImage" style="display:none; height:0; width:0;" src="copycodeHighlight.gif" />
    <div id="header">
      <table width="100%" id="topTable">
        <tr id="headerTableRow1">
          <td align="left">
            <span id="runningHeaderText">PRAGMA</span>&nbsp;</td>
        </tr>
        <tr id="headerTableRow2">
          <td align="left">
            <span id="nsrTitle">SQLite Language Reference Documentation</span>
          </td>
        </tr>
        <tr id="headerTableRow3" style="display:none">
          <td>
            <a id="seeAlsoSectionLink" href="#seeAlsoToggle" onclick="OpenSection(seeAlsoToggle)">See Also</a>
            <a id="exampleSectionLink" href="#codeExampleToggle" onclick="OpenSection(codeExampleToggle)">Example</a>
          </td>
        </tr>
     </table>
      <table width="100%" id="bottomTable" cellspacing="0" cellpadding="0" style="display:none">
        <tr>
          <td>
            <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage)" tabindex="0">
              <img ID="toggleAllImage" class="toggleAll" src="collall.gif" />
              <label id="collapseAllLabel" for="toggleAllImage" style="display: none;">
							Collapse All
						</label>
              <label id="expandAllLabel" for="toggleAllImage" style="display: none;">
							Expand All
						</label>
            </span>
          </td>
        </tr>
      </table>
    </div>
    <div id="mainSection">
    <div id="mainBody">
      <h1 class="heading">
        SQL As Understood By SQLite</h1>
      <h4>
        PRAGMA</h4>
      <p>
        The <a href="#syntax">PRAGMA command</a> is a special command used to modify the
        operation of the SQLite library or to query the library for internal (non-table)
        data. The PRAGMA command is issued using the same interface as other SQLite commands
        (e.g. SELECT, INSERT) but is different in the following important respects:
      </p>
      <ul>
        <li>Specific pragma statements may be removed and others added in future releases
          of SQLite. Use with caution! </li>
        <li>No error messages are generated if an unknown pragma is issued. Unknown pragmas
          are simply ignored. This means if there is a typo in a pragma statement the library
          does not inform the user of the fact. </li>
        <li>Some pragmas take effect during the SQL compilation stage, not the execution stage.
          This means if using the C-language sqlite3_compile(), sqlite3_step(), sqlite3_finalize()
          API (or similar in a wrapper interface), the pragma may be applied to the library
          during the sqlite3_compile() call. </li>
        <li>The pragma command is unlikely to be compatible with any other SQL engine. </li>
      </ul>
      <p>
        The available pragmas fall into four basic categories:</p>
      <ul>
        <li>Pragmas used to <a href="#schema">query the schema</a> of the current database.
        </li>
        <li>Pragmas used to <a href="#modify">modify the operation</a> of the SQLite library
          in some manner, or to query for the current mode of operation. </li>
        <li>Pragmas used to <a href="#version">query or modify the databases two version values</a>,
          the schema-version and the user-version. </li>
        <li>Pragmas used to <a href="#debug">debug the library</a> and verify that database
          files are not corrupted. </li>
      </ul>
      <hr />
      <a name="syntax"></a>
      <h1>
        PRAGMA command syntax</h1>
      <p>
        <table cellpadding="10">
          <tr>
            <td align="right" width="1%" nowrap>
              <i><font color="#ff3434">sql-statement</font></i> ::=</td>
            <td>
              <b><font color="#2c2cf0">PRAGMA </font></b><i><font color="#ff3434">name</font></i><b><font
                color="#2c2cf0"> </font></b>[<b><font color="#2c2cf0">= </font></b><i><font color="#ff3434">
                  value</font></i><b><font color="#2c2cf0"></font></b>]<b><font color="#2c2cf0"> </font>
                  </b><big>|</big><b><font color="#2c2cf0"><br />
                    PRAGMA </font></b><i><font color="#ff3434">function</font></i><b><font color="#2c2cf0"><big>(</big></font></b><i><font
                      color="#ff3434">arg</font></i><b><font color="#2c2cf0"><big>)</big></font></b></td>
          </tr>
        </table>
      </p>
      <p>
        The pragmas that take an integer <b><i>value</i></b> also accept symbolic names.
        The strings "<b>on</b>", "<b>true</b>", and "<b>yes</b>" are equivalent to <b>1</b>.
        The strings "<b>off</b>", "<b>false</b>", and "<b>no</b>" are equivalent to <b>0</b>.
        These strings are case- insensitive, and do not require quotes. An unrecognized
        string will be treated as <b>1</b>, and will not generate an error. When the <i>value</i>
        is returned it is as an integer.</p>
      <hr />
      <a name="modify"></a>
      <h1>
        Pragmas to modify library operation</h1>
      <ul>
        <a name="pragma_auto_vacuum"></a>
        <li>
          <p>
            <b>PRAGMA auto_vacuum;
              <br />
              PRAGMA auto_vacuum = </b><i>0 | 1</i><b>;</b></p>
          <p>
            Query or set the auto-vacuum flag in the database.</p>
          <p>
            Normally, when a transaction that deletes data from a database is committed, the
            database file remains the same size. Unused database file pages are marked as such
            and reused later on, when data is inserted into the database. In this mode the <a
              href="lang_vacuum.html">VACUUM</a> command is used to reclaim unused space.</p>
          <p>
            When the auto-vacuum flag is set, the database file shrinks when a transaction that
            deletes data is committed (The VACUUM command is not useful in a database with the
            auto-vacuum flag set). To support this functionality the database stores extra information
            internally, resulting in slightly larger database files than would otherwise be
            possible.</p>
          <p>
            It is only possible to modify the value of the auto-vacuum flag before any tables
            have been created in the database. No error message is returned if an attempt to
            modify the auto-vacuum flag is made after one or more tables have been created.
          </p>
          <a name="pragma_cache_size"></a></li>
        <li>
          <p>
            <b>PRAGMA cache_size;
              <br />
              PRAGMA cache_size = </b><i>Number-of-pages</i><b>;</b></p>
          <p>
            Query or change the maximum number of database disk pages that SQLite will hold
            in memory at once. Each page uses about 1.5K of memory. The default cache size is
            2000. If you are doing UPDATEs or DELETEs that change many rows of a database and
            you do not mind if SQLite uses more memory, you can increase the cache size for
            a possible speed improvement.</p>
          <p>
            When you change the cache size using the cache_size pragma, the change only endures
            for the current session. The cache size reverts to the default value when the database
            is closed and reopened. Use the <a href="#pragma_default_cache_size"><b>default_cache_size</b></a>
            pragma to check the cache size permanently.</p>
          <a name="pragma_case_sensitive_like"></a></li>
        <li>
          <p>
            <b>PRAGMA case_sensitive_like;
              <br />
              PRAGMA case_sensitive_like = </b><i>0 | 1</i><b>;</b></p>
          <p>
            The default behavior of the LIKE operator is to ignore case for latin1 characters.
            Hence, by default <b>'a' LIKE 'A'</b> is true. The case_sensitive_like pragma can
            be turned on to change this behavior. When case_sensitive_like is enabled, <b>'a'
              LIKE 'A'</b> is false but <b>'a' LIKE 'a'</b> is still true.</p>
          <a name="pragma_count_changes"></a></li>
        <li>
          <p>
            <b>PRAGMA count_changes;
              <br />
              PRAGMA count_changes = </b><i>0 | 1</i><b>;</b></p>
          <p>
            Query or change the count-changes flag. Normally, when the count-changes flag is
            not set, INSERT, UPDATE and DELETE statements return no data. When count-changes
            is set, each of these commands returns a single row of data consisting of one integer
            value - the number of rows inserted, modified or deleted by the command. The returned
            change count does not include any insertions, modifications or deletions performed
            by triggers.</p>
          <a name="pragma_default_cache_size"></a></li>
        <li>
          <p>
            <b>PRAGMA default_cache_size;
              <br />
              PRAGMA default_cache_size = </b><i>Number-of-pages</i><b>;</b></p>
          <p>
            Query or change the maximum number of database disk pages that SQLite will hold
            in memory at once. Each page uses 1K on disk and about 1.5K in memory. This pragma
            works like the <a href="#pragma_cache_size"><b>cache_size</b></a> pragma with the
            additional feature that it changes the cache size persistently. With this pragma,
            you can set the cache size once and that setting is retained and reused every time
            you reopen the database.</p>
          <a name="pragma_default_synchronous"></a></li>
        <li>
          <p>
            <b>PRAGMA default_synchronous;</b></p>
          <p>
            This pragma was available in version 2.8 but was removed in version 3.0. It is a
            dangerous pragma whose use is discouraged. To help dissuide users of version 2.8
            from employing this pragma, the documentation will not tell you what it does.</p>
          <a name="pragma_empty_result_callbacks"></a></li>
        <li>
          <p>
            <b>PRAGMA empty_result_callbacks;
              <br />
              PRAGMA empty_result_callbacks = </b><i>0 | 1</i><b>;</b></p>
          <p>
            Query or change the empty-result-callbacks flag.</p>
          <p>
            The empty-result-callbacks flag affects the sqlite3_exec API only. Normally, when
            the empty-result-callbacks flag is cleared, the callback function supplied to the
            sqlite3_exec() 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

⌨️ 快捷键说明

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