Introduction

SQLite ADO.NET Provider
SQLite.NET Class Library Documentation
See Also Example

About SQLite.NET

This class library is an ADO.NET wrapper around the popular (and free!) SQLite database engine. For information on SQL syntax, features of SQLite and a good understanding of how it works and what it does, I highly recommend heading over to sqlite.org and reading the documentation there.

The C# provider, the very minor C code modifications to SQLite, documentation and etc were written by Robert Simpson, and the SourceForge project page can be found here.

The System.Data.SQLite project is currently maintained by the SQLite Development Team and the latest source code and project information can be found here.

What's New?

Click here to see the version history of this SQLite.NET provider

Using this library

The following are links to information on various aspects of the library and how to use it in your application(s)

How to install Visual Studio Design-Time Support

How to configure and enumerate SQLite.NET through the DbProviderFactories object

Getting the best performance out of SQLite

Limitations of the SQLite.NET provider and the SQLite engine (compared to other providers and engines)

SQLite.NET Provider Features

This SQLite provider implements every feature of the underlying SQLite database engine without omission. Here's a brief summary:

  • Written from scratch on Visual Studio 2008 specifically for ADO.NET, implenting all the base classes and features recently introduced in the framework, including automatic transaction enlistment.
  • Supports the Full and Compact .NET Framework, as well as native C/C++ development. 100% binary compatible with the original sqlite3.dll.
  • Full support for Mono via a "managed only" provider that runs against the official SQLite 3.6.1 or higher library.
  • Full Entity Framework support (ADO.NET 3.5 SP1)
  • On the Compact Framework, it is faster than Sql Server Mobile. SQLite's installed size is a fraction of Sql Mobile's. It uses less memory at runtime, runs queries faster, and has a smaller database file size as well.
  • Encrypted database support. Encrypted databases are fully encrypted and support both binary and cleartext password types.
  • Visual Studio 2005/2008/2010/2012/2013/2015 Design-Time Support. You can add a SQLite database to the Servers list, design queries with the Query Designer, drag-and-drop tables onto a Typed DataSet, etc.
  • Full SQLite schema editing inside Visual Studio. You can create/edit tables, views, triggers, indexes, check constraints and foreign keys.
  • Available as a single file redistributable (except Compact Framework). The core sqlite3 codebase and the ADO.NET wrapper are combined into one multi-module assembly.
  • Also available as separate native and managed assemblies and optionally with the Visual C++ Runtime statically linked.
  • Binaries included for Itanium, x64, x86 and ARM processors.
    Itanium processor support not currently included.
  • DbProviderFactory support.
  • Full support for ATTACH'ed databases. Exposed as Catalogs in the schema. When cloning a connection, all attached databases are automatically re-attached to the new connection.
  • DbConnection.GetSchema(...) support includes the MetaDataCollections, DataSourceInformation, Columns, Tables, Views, ViewColumns, Catalogs, Indexes, IndexColumns, ForeignKeys and Triggers.
  • Enhanced DbDataReader.GetSchemaTable() functionality returns catalog, namespace and detailed schema information even for complex queries.
  • Named and unnamed parameters.
  • Full UTF-8 and UTF-16 support, each with optimized pipelines into the native database core.
  • Multiple simultaneous DataReaders (one DataReader per Command however).
  • Full support for user-defined scalar and aggregate functions, encapsulated into an easy-to-use base class in which only a couple of overrides are necessary to implement new SQL functions.
  • Full support for user-defined collating sequences, every bit as simple to implement as user-defined functions and uses the same base class.
  • Full source for the entire engine and wrapper. No copyrights. Public Domain. 100% free for commercial and non-commercial use.

Distributing the Binaries (Desktop)

When using the mixed-mode assembly, the System.Data.SQLite.DLL file includes all the native and managed code. In that case, this is the only DLL required to be redistributed with your SQLite.NET application(s). When using separate native and managed assemblies, the System.Data.SQLite.DLL file contains all the managed code and the SQLite.Interop.DLL file contains all the native code. The native code comes in 3 flavors: Win32, Itanium and x64 (AMD64).
Itanium processor support not currently included.

Distributing the Binaries (Compact Framework)

Both the System.Data.SQLite.DLL and SQLite.Interop.XXX.DLL files must be deployed on the Compact Framework. The XXX is the build number of the System.Data.SQLite library (e.g. "118"). The SQLite.Interop.XXX.DLL file is a fully native assembly compiled for the ARM processor, and System.Data.SQLite is the fully-managed Compact Framework assembly.

Send comments on this topic.


Design-Time Support
SQLite.NET Class Library Documentation
See Also Example

Installing SQLite Visual Studio Design-Time Support

Supporting the Visual Studio query designer and allowing you to manipulate SQLite databases from within Visual Studio is a great time-saver. Though the support is not yet fully-implemented, there's certainly enough there to keep you busy. You can create databases, design and execute queries, create typed datasets and lots more all from Visual Studio.

Installation Instructions

Download and run one of the setup packages and then select the "Install the designer components for Visual Studio 20XX." option when prompted.

Express Edition Limitations

Visual Studio design-time Support, works with all versions of Visual Studio 2005/2008/2010/2012/2013/2015. You can add a SQLite database to the Servers list, design queries with the Query Designer, drag-and-drop tables onto a Typed DataSet, etc.
Due to Visual Studio licensing restrictions, the Express Editions can no longer be supported.


DbProviderFactory Support
SQLite.NET Class Library Documentation
See Also Example

DbProviderFactories and You

One of the great new features of ADO.NET 2.0 is the use of reflection as a means of instantiating database providers programmatically. The information .NET uses to enumerate the available data providers in the system is relatively simple. It merely looks in the machine.config and in your own app.config file for some XML data to tell it what providers are installed and what assemblies those providers are in.

Scenario 1: Version Independent (does not use the Global Assembly Cache)

This method allows you to drop any new version of the System.Data.SQLite.DLL into your application's folder and use it without any code modifications or recompiling. Add the following code to your app.config file:

<configuration>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite"
           description=".NET Framework Data Provider for SQLite"
           type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data>
</configuration>

Scenario 2: Version Dependent, using either the DLL located in the same folder as the application or the Global Assembly Cache

This method expands on the above XML to provide the version number and key token of the SQLite DLL so it can be found either in the same folder as the application or looked up in the GAC. The downside to this method is that DbProviderFactories will use this version information to only load the version specified. This means if you update the DLL, you must also update this XML.

<configuration>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite"
           description=".NET Framework Data Provider for SQLite"
           type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite,
                 Version=1.0.118.0, Culture=neutral,
                 PublicKeyToken=db937bc2d44ff139"/>
    </DbProviderFactories>
  </system.data>
</configuration>

The following C# code demonstrates instantiating SQLite through DbProviderFactories:

      DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite");
      using (DbConnection cnn = fact.CreateConnection())
      {
        cnn.ConnectionString = "Data Source=test.db3";
        cnn.Open();
      }


Environment Variables
SQLite.NET Class Library Documentation
See Also Example

The following special replacement tokens may be recognized and replaced with their associated runtime value, depending on context, when setting values are being read by the native library pre-loading subsystem. Unless otherwise stated explicitly, all of these tokens are case-sensitive and the percent characters must be included in order for them to be recognized.

All references to special replacement tokens will be expanded to their corresponding values within the returned settings values unless either the "No_Tokens" or "No_Tokens_<name>" environment variable is set [to anything].

Name | Description
%PreLoadSQLite_AssemblyDirectory% | If this token (which is case-sensitive and must include the percent characters) is present within a setting value being returned, it will be replaced with the qualified name of the directory containing the System.Data.SQLite assembly. If the name of the directory is not available, the token will not be replaced.
%PreLoadSQLite_TargetFramework% | If this token (which is case-sensitive and must include the percent characters) is present within a setting value being returned, it will be replaced with an abbreviation of the target framework attribute value for the System.Data.SQLite assembly. If the target framework attribute value is not available, the token will not be replaced.
%PreLoadSQLite_XmlConfigDirectory% | If this token (which is case-sensitive and must include the percent characters) is present within a setting value being returned, it will be replaced with the qualified name of the directory containing the XML configuration file. If the name of the directory is not available, the token will not be replaced. Generally, this token may only be used within the XML configuration file itself.

These environment variables are used to control several features of the System.Data.SQLite library. All of these environment variables are optional. If a particular environment variable is not present, the XML configuration file "System.Data.SQLite.dll.config" in the directory containing the currently executing assembly (i.e. the one containing all the managed components for System.Data.SQLite) will also be consulted. If present, the XML configuration file should be structured as follows:

        <?xml version="1.0"?>
        <configuration>
          <appSettings>
            <add key="A_Setting" value="String Value" />
            <add key="Another_Setting" value="%ENV_VALUE%" />
          </appSettings>
        </configuration>

All references to existing environment variables will be expanded to their corresponding values within the returned settings values unless either the "No_Expand" or "No_Expand_<name>" environment variable is set [to anything].

None of these environment variables are supported by the Compact Framework builds of System.Data.SQLite, due to limitations imposed by the platform itself; however, the XML configuration file mentioned above may be used instead.

Name | Description
AppendManifestToken_SQLiteProviderManifest | If this environment variable is set [to anything], it will be used by the System.Data.SQLite.Linq.SQLiteProviderManifest class (and the System.Data.SQLite.EF6.SQLiteProviderManifest class) to modify future provider manifest tokens by appending the value of the environment variable to the existing provider manifest token, if any. Typically, in order for the constructed provider manifest token to be syntactically correct, the environment variable value [to be appended] must begin with a semicolon.
DefaultFlags_SQLiteConnection | If this environment variable is set [to anything], it will be used by the System.Data.SQLite.SQLiteConnection class as the default flags for all opened connections (i.e. when they are not present in the connection string).
Disable_SQLiteLog | If this configuration variable is set [to anything], the SQLite logging subsystem will be initially disabled when initialized.
Force_SQLiteLog | If this environment variable is set [to anything], the SQLite logging subsystem may be initialized in a non-default application domain. By default, this is not allowed due to the potential for application domain unloading issues.
Initialize_SQLiteLog | If this environment variable is set [to anything], the SQLite logging subsystem will attempt to perform initialization even when an attempt was previously made.
No_PreLoadSQLite | If this environment variable is set [to anything], the native library pre-loading code will be disabled. By default, the native library pre-loading code will attempt to load the native SQLite library from architecture-specific (e.g. "x86", "amd64", "x64") or platform-specific (e.g. "Win32") directories that reside underneath the application base directory.
No_SQLiteConnectionNewParser | If this environment variable is set [to anything], the new connection string parsing algorithm will not be used. This environment variable is intended for use with legacy code only.
No_SQLiteFunctions | If this environment variable is set [to anything], the initial search for types in all loaded assemblies that are tagged with the SQLiteFunction attribute will be skipped. Normally, this search is conducted only once per application domain by the static constructor of the SQLiteFunction class; however, these implementation details are subject to change.
No_SQLiteGetSettingValue | If this environment variable is set [to anything], all calls to the GetSettingValue method will return the default value. This will effectively prevent all other setting values from having any effect, including those specified via other supported environment variables or in the associated XML configuration file.
No_SQLiteLog | If this environment variable is set [to anything], the SQLite logging subsystem will not be initialized by the SQLiteLog class; however, it may still be initialized by external components (i.e. something other than System.Data.SQLite).
No_SQLiteXmlConfigFile | If this environment variable is set [to anything], calls to the GetSettingValue method will never result in the XML configuration file being read; instead, the default value will be returned. This will effectively prevent any setting values specified via the XML configuration file from having any effect.
PreLoadSQLite_AllowBaseDirectoryOnly | If this environment variable is set [to anything], the base directory itself is considered valid for pre-loading the native SQLite library.
PreLoadSQLite_BaseDirectory | If this environment variable is set [to anything], it will be used instead of the application base directory by the native library pre-loader. This environment variable can be especially useful in ASP.NET and other hosted environments where direct control of the location of the managed assemblies is not under the control of the application.
PreLoadSQLite_BreakIntoDebugger | If this environment variable is set [to anything], the native library pre-loader subsystem will attempt to give the interactive user an opportunity to attach a debugger to the current process.
PreLoadSQLite_LibraryFileNameOnly | If this environment variable is set [to anything], it will be used as the base file name (without directory information) for the native SQLite library to be pre-loaded (e.g. "sqlite3.dll" or "libsqlite3.so.0").
PreLoadSQLite_NoSearchForDirectory | If this environment variable is set [to anything], the native library pre-loading code will skip conducting a search for the native library to pre-load. By default, the search starts in the location of the currently executing assembly (i.e. the assembly containing all the managed components for System.Data.SQLite) and then falls back to the application domain base directory.
PreLoadSQLite_ProcessorArchitecture | If this environment variable is set [to anything], it will be used instead of the processor architecture value contained in the PROCESSOR_ARCHITECTURE environment variable to help build the path of the native library to pre-load.
PreLoadSQLite_UseAssemblyDirectory | If this environment variable is set [to anything], the location of the currently executing assembly (i.e. the one containing all the managed components for System.Data.SQLite) will be used as the basis for locating the the native library to pre-load (i.e. instead of using the application domain base directory).
PROCESSOR_ARCHITECTURE | This environment variable is normally set by the operating system itself and should reflect the native processor architecture of the current process (e.g. a 32-bit x86 application running on a 64-bit x64 operating system should have the value "x86").
SQLite_ForceLogLifecycle | If this environment variable is set [to anything], calls into key members pertaining to the lifecycle of connections and their associated classes (e.g. LINQ, EF6, etc) will be logged.
SQLite_ForceLogPrepare | If this environment variable is set [to anything], all calls to prepare a SQL query will be logged, regardless of the flags for the associated connection.
SQLite_ForceLogRetry | If this environment variable is set [to anything], all internal retries during statment preparation and stepping will be logged, regardless of the flags for the associated connection.
SQLite_GlobalCommandBehaviors | If this environment variable is set [to anything], it will be processed as a list of CommandBehavior flags, if possible. It will be ignored if it cannot be processed correctly. For more details please refer to the CombineBehaviors method.
SQLite_LegacyEncryptPage1 | If this environment variable is set [to anything], page #1 of database files encrypted using the (unsupported) legacy CryptoAPI codec will be encrypted. This was the default behavior prior to release 1.0.112.3; however, it is now disabled (by default) as it can cause corruption and/or other malfunctions in some circumstances. Please do not use this environment variable unless it is absolutely necessary for your specific use case.
SQLite_StrongConnectionPool | If this environment variable is set [to anything], the default connection pool will use normal objects instead of weak references. This should prevent any pooled connection objects from ever being automatically cleaned up by the garbage collector.
TypeName_SQLiteProviderServices | If this environment variable is set [to anything], it will be used by the System.Data.SQLite.SQLiteFactory class as the type name containing the System.Data.Common.DbProviderServices implementation that should be used.
Use_SQLiteConvert_DefaultDbType | If this environment variable is set [to anything], it will be used by the System.Data.SQLite.SQLiteConvert class as the default DbType value that should be used when a per-connection value is not available.
Use_SQLiteConvert_DefaultTypeName | If this environment variable is set [to anything], it will be used by the System.Data.SQLite.SQLiteConvert class as the default type name that should be used when a per-connection value is not available.


Optimizing Your Queries

Optimizing for SQLite
SQLite.NET Class Library Documentation
See Also Example

Tips on Optimizing Your Queries

The next few paragraphs will attempt to give you a few rudimentary rules for speeding up your queries in general, and especially how SQLite is adversely affected by the kinds of SQL behaviors you may have taken for granted in other providers. It is by no means a complete optimization guide. For even more details on optimizing your queries, visit sqlite.org.

The Importance of Transactions

If you are inserting data in SQLite without first starting a transaction: DO NOT PASS GO! Call BeginTransaction() right now, and finish with Commit()! If you think I'm kidding, think again. SQLite's A.C.I.D. design means that every single time you insert any data outside a transaction, an implicit transaction is constructed, the insert made, and the transaction destructed. EVERY TIME. If you're wondering why in the world your inserts are taking 100x longer than you think they should, look no further.

Prepared Statements

Lets have a quick look at the following code and evaluate its performance:

      using (SQLiteCommand mycommand = new SQLiteCommand(myconnection))
      {
        int n;

        for (n = 0; n < 100000; n ++)
        {
          mycommand.CommandText = String.Format("INSERT INTO [MyTable] ([MyId]) VALUES({0})", n + 1);
          mycommand.ExecuteNonQuery();
        }
      }

This code seems pretty tight, but if you think it performs well, you're dead wrong. Here's what's wrong with it:

  • I didn't start a transaction first! This insert is dog slow!
  • The CLR is calling "new" implicitly 100,000 times because I am formatting a string in the loop for every insert
  • Since SQLite precompiles SQL statements, the engine is constructing and deconstructing 100,000 SQL statements and allocating/deallocating their memory
  • All this construction and destruction is involving about 300,000 more native to managed interop calls than an optimized insert

So lets rewrite that code slightly:

      using (SQLiteTransaction mytransaction = myconnection.BeginTransaction())
      {
        using (SQLiteCommand mycommand = new SQLiteCommand(myconnection))
        {
          SQLiteParameter myparam = new SQLiteParameter();
          int n;

          mycommand.CommandText = "INSERT INTO [MyTable] ([MyId]) VALUES(?)";
          mycommand.Parameters.Add(myparam);

          for (n = 0; n < 100000; n ++)
          {
            myparam.Value = n + 1;
            mycommand.ExecuteNonQuery();
          }
        }
        mytransaction.Commit();
      }

Now this is a blazing fast insert for any database engine, not just SQLite. The SQL statement is prepared one time -- on the first call to ExecuteNonQuery(). Once prepared, it never needs re-evaluating. Furthermore, we're allocating no memory in the loop and doing a very minimal number of interop transitions. Surround the entire thing with a transaction, and the performance of this insert is so far and away faster than the original that it merits a hands-on-the-hips pirate-like laugh.

Every database engine worth its salt utilizes prepared statements. If you're not coding for this, you're not writing optimized SQL, and that's the bottom line.


Provider Limitations
SQLite.NET Class Library Documentation
See Also Example

Limitations of this ADO.NET SQLite Data Provider

As providers go, this one doesn't have many restrictions. SQLite has no support for row-level or table-level locks. When a connection locks the database for writing, no other connection or process may read or write to the database until the write operation is complete. The SQLite.NET provider attempts to retry internally if a database is locked, up to the CommandTimeout property of the command in question.

SQLite is inherently type-less, and only understands a few basic datatypes natively. They are (in .NET-speak) Int64, Double, String and Blob. The SQLite.NET provider will use the database schema information it can glean to enforce type-ness, but it is an inexact science.

Hierarchical DataReaders are not supported. In the case of transactions, any SQLiteCommand created on a connection will (when executed) automatically join a transaction in progress, regardless of whether that transaction was created before or after the command.

A SQLiteCommand object can be re-assigned a new SQLiteConnection object as long as no DataReaders are active on the command.

Opening a transaction is considered a write operation, so only use them when you want to write to the database! If you hold open an "immediate" transaction, all readers on other connections will be blocked until the transaction is closed!

Thread Safety

Multi-threading in SQLite must be done carefully. Here are the restrictions:

  • You May Clone() a SQLiteConnection object in one thread and pass the cloned object to another thread. Once passed, the other thread becomes the new owner of the cloned connection, and the original thread must not keep a reference to the clone or call any methods on the clone.
  • You May create multiple threads, and those threads can create their own SQLiteConnection and subsequent objects for accessing a database. Multiple connections on multiple threads to the same database file are perfectly acceptable and will behave predictably.
  • You May NOT call methods or properties or otherwise reference any SQLite provider classes that belong to another thread.
  • You May NOT pass a SQLiteCommand, SQLiteDataReader, SQLiteDataAdapter or any other SQLite provider class except a cloned SQLiteConnection to another thread.

Understand again that SQLite has no fine-grained locking mechanisms. It is therefore your own responsibility in a multi-threaded environment to handle potential timeouts that may occur if a long-running query in one thread prevents a query in another thread from executing. These timeouts will only occur if one thread is attempting to read while another thread is attempting to write. Whichever thread got its lock first will be the one to execute, and the other thread will block until the CommandTimeout value elapses or the other thread finishes.


SQLite Query Syntax
SQLite Language Reference Documentation
See Also Example

SQL As Understood By System.Data.SQLite

The SQLite library understands most of the standard SQL language. But it does omit some features while at the same time adding a few features of its own. This document attempts to describe precisely what parts of the SQL language SQLite does and does not support. A list of keywords is also provided. In all of the syntax diagrams that follow, literal text is shown in bold blue. Non-terminal symbols are shown in italic red. Operators that are part of the syntactic markup itself are shown in black roman. This document is just an overview of the SQL syntax implemented by SQLite.

The SQLite core library implements the follow syntax:

SQL As Understood By SQLite

The System.Data.SQLite provider implements the follow additional syntax:

TYPES


TYPES
SQLite Language Reference Documentation
See Also Example

SQL As Understood By SQLite (sortof)

TYPES

sql-statement ::= | TYPES [datatype name][,datatype name][,datatype name][,...] ; select-stmt
select-stmt ::= | see SELECT

Use the TYPES keyword before a SELECT statement to provide the SQLite ADO.NET provider a list of return datatypes to expect from the subsequent SELECT statement.

This is a language extension (aka hack) to SQLite specifically for the ADO.NET data provider. It is a pseudo-statement, meaning only the ADO.NET provider understands it.

Background

Due to SQLite's typeless nature, there are certain kinds of queries for which the ADO.NET provider cannot determine the proper return data type. Scalar and aggregate functions pose a particular problem because there is no requirement for a given scalar or aggregate function to return any particular datatype. As a matter of fact, scalar functions could theoretically return a different datatype for every row or column in a query and this is perfectly legal from SQLite's point of view.

Since ADO.NET is designed around a typed system and we're shoe-horning SQLite into it, this keyword helps the provider out in cases where the return type cannot be easily determined.

This command must be used in conjunction with a SELECT statement. It only works when both the TYPES keyword and its value(s) are passed along with a SELECT statement as a single semi-colon separated unit.

Examples

TYPES [bigint], [int], [mediumint], [smallint], [tinyint];
SELECT 1, 2, 3, 4;

The above query would return the columns as types System.Int64, System.Int32, System.Int32, System.Int16 and System.Byte respectively.

TYPES [bigint], [int], , [tinyint];
SELECT 1, 2, 3, 4;

In this sample, only columns 1, 2 and 4 would have explicit typing. Column 3's datatype would pass though the system and be discovered normally.

TYPES real;
SELECT SUM(Cost) FROM [Products];

The above query explicitly tells the provider that the SUM aggregate function returns a System.Double.

Usage Notes

  • You cannot use parameters in the TYPES statement.
  • The TYPES statement must be immediately followed by a SELECT statement.
  • It is legal to pass multiple TYPES and SELECT statements in a multi-statement command.
  • You may enclose datatypes in quotes "" or brackets [] or those `` thingies if you want.


Version History
SQLite.NET Class Library Documentation
See Also Example

Version History

1.0.118.0 - June 10, 2023

  • Updated to SQLite 3.42.0.
  • Add the ConnectionStringPreview, SqlStringPreview, and Canceled connection events.
  • Add support for the sqlite3_is_interrupted core library API. Pursuant to forum post [b6a707bffb].
  • Add support for the sqlite_trace_v2 core library API. Pursuant to forum post [1c418d7edc].
  • Add TextHexPassword connection string property for use with SEE.
  • Add SQLite_ForceLogRetry environment variable to force logging of all internal retries during statment preparation and stepping.
  • Add StepRetries connection string property to allow the maximum number of retries when stepping a query to be overridden.
  • Fix ExecuteScalar and ExecuteNonQuery handling of write transactions that require more than one call to step. Pursuant to forum post [f4e718891d]. ** Potentially Incompatible Change **
  • Parameter names should be case-sensitive. Fix for [e22d357a21]. ** Potentially Incompatible Change **

1.0.117.0 - November 28, 2022

  • Updated to SQLite 3.40.0.
  • Add support for creating custom window functions. Pursuant to forum post [21de219031].
  • Suppress finalizer calls for SQLite3 objects that are closed. Fix for [ce4d70ea6f].
  • Improvements to object disposal diagnostics. Pursuant to [ce4d70ea6f].
  • Add MaximumSleepTime property to the SQLiteCommand class and DefaultMaximumSleepTime connection string property.
  • Add experimental support for running the test suite using .NET 5 and .NET 6.
  • Add experimental support for native sha3 extension.

1.0.116.0 - June 1, 2022

  • Updated to SQLite 3.38.5.
  • More flexible connection pooling via the new ISQLiteConnectionPool2 interface.
  • Add SQLite_StrongConnectionPool environment variable to prevent pooled connections from being garbage collected.
  • Improvements to object disposal handling for database connections.

1.0.115.5 - November 2, 2021

  • Updated to SQLite trunk.
  • Add Busy event to the SQLiteConnection class. Pursuant to forum post [08a52f61fc].
  • Fix metadata UTF-16 string length calculations on Linux. Fix for forum post [eeaefb84ec].

1.0.115.0 - August 25, 2021

  • Updated to SQLite 3.36.0.

1.0.114.0 - May 22, 2021

  • Updated to SQLite 3.35.5.
  • Updated to Entity Framework 6.4.4.
  • Add preliminary support for the .NET Framework 4.8.
  • Add support for math functions now provided by the SQLite core library.
  • Add support for ORDER BY and LIMIT for UPDATE and DELETE.
  • Add TextPassword connection string property for use with SEE.

1.0.113.0 - June 1, 2020

  • Updated to SQLite 3.32.1.
  • Add SQLite_ForceLogLifecycle environment variable to force logging of calls into key members pertaining to the lifecycle of connections and their associated classes (e.g. LINQ, EF6, etc).
  • Support automatic value conversions for columns with a declared type of MEDIUMINT or MEDIUMUINT. Pursuant to [515cb60b10].

1.0.112.3 - Xxxx XX, 2020

  • When using the (unsupported) legacy CryptoAPI based codec, skip encrypting page #1 because that can lead to database corruption and other malfunctions.
  • Add SQLite_ForceLogLifecycle environment variable to force logging of calls into key members pertaining to the lifecycle of connections and their associated classes (e.g. LINQ, EF6, etc).
  • Support automatic value conversions for columns with a declared type of MEDIUMINT or MEDIUMUINT. Pursuant to [515cb60b10].

1.0.112.2 - April 27, 2020

  • Fix NuGet packaging for .NET Standard 2.1. Fix for [7c73262e6f].

1.0.112.1 - April 6, 2020

  • Updated to SQLite 3.31.1.
  • Include the "LINQ" partial classes in the primary managed assembly for .NET Standard 2.1. Fix for [ad28d8e026].

1.0.112.0 - October 28, 2019

  • Updated to SQLite 3.30.1.
  • Add preliminary support for .NET Core 3.0 and the .NET Standard 2.1. Pursuant to [ce75d320d0].
  • Updated to Entity Framework 6.3.0.
  • Add support for new DBCONFIG options from the SQLite core library. Pursuant to [03b6b0edd7].
  • Add SetLimitOption method to the SQLiteConnection class.

1.0.111.0 - June 10, 2019

  • Updated to SQLite 3.28.0.
  • Add No_SQLiteLog environment variable.

1.0.110.0 - March 4, 2019

  • Updated to SQLite 3.27.2.
  • Add HidePassword connection flag to remove the password from the connection string once the database is opened. Pursuant to [23d8d6171e].
  • Add experimental StrictConformance connection flag to force strict compliance to the ADO.NET standard. Pursuant to [e36e05e299].
  • Add support for the sqlite3changeset_start_v2() and sqlite3changeset_start_v2_strm() interfaces.

1.0.109.0 - August 15, 2018

  • Updated to SQLite 3.24.0.
  • Updated to Entity Framework 6.2.0.
  • Do not attempt to initialize the logging subsystem more than once. ** Potentially Incompatible Change **
  • Prevent GetSchemaTable from throwing InvalidCastException. Fix for [baf42ee135].
  • Add preliminary support for the .NET Framework 4.7.2.
  • Add preliminary support for .NET Core 2.0 and the .NET Standard 2.0. Pursuant to [5c89cecd1b].
  • Add simpler overload for the SQLiteBlob.Create method. Pursuant to [dfc8133ba2].
  • Add GetFieldAffinity method to the SQLiteDataReader class.

1.0.108.0 - March 2, 2018

  • Support extended result codes when messages are looked up without the SQLite core library.
  • Override System.Object members for the SQLiteException class to improve its ToString return value. Pursuant to [53962f9eff].
  • More database connection configuration options for the sqlite3_db_config() interface. ** Potentially Incompatible Change **
  • Set HResult property of SQLiteException based on the SQLite core library error code. ** Potentially Incompatible Change **
  • Modify experimental WaitForEnlistmentReset method to require a nullable boolean parameter for the value to return when the connection is disposed. ** Potentially Incompatible Change **

1.0.107.0 - January 30, 2018

  • Updated to SQLite 3.22.0.
  • Improve performance of type name lookups by removing superfluous locking and string creation.
  • Support asynchronous completion of distributed transactions. Fix for [5cee5409f8].
  • Add experimental WaitForEnlistmentReset method to the SQLiteConnection class. Pursuant to [7e1dd697dc].
  • Fix some internal memory accounting present only in the debug build.
  • Make sure inbound native delegates are unhooked before adding a connection to the pool. Fix for [0e48e80333].
  • Add preliminary support for the .NET Framework 4.7.1.
  • Updates to internal DbType mapping related lookup tables. Pursuant to [a799e3978f].

1.0.106.0 - November 2, 2017

  • Updated to SQLite 3.21.0.
  • Add full support for the native session extension.
  • Add BindDecimalAsText and GetDecimalAsText connection flags to force binding and returning of decimal values as text. Pursuant to [b167206ad3].
  • Add BindInvariantDecimal and GetInvariantDecimal connection flags, enabled by default, to force binding and returning of decimal values using the invariant culture. Pursuant to [b167206ad3]. ** Potentially Incompatible Change **
  • Add preliminary support for Visual Studio 2017 and the .NET Framework 4.7. This does not include support for the design-time components for Visual Studio, see [8292431f51].

1.0.105.2 - June 12, 2017

  • Updated to SQLite 3.19.3.
  • Fix issues that prevented SQLiteBlob creation from succeeding for tables that did not have an integer primary key.

1.0.105.1 - May 15, 2017

  • Prevent culture settings from negatively impacting integer connection string defaults.
  • Make sure the "No_SQLiteConnectionNewParser" and "DefaultFlags_SQLiteConnection" setting values end up being cached.
  • Cache the XML file name and assembly directory used by the configuration subsystem.

1.0.105.0 - April 9, 2017

  • Updated to SQLite 3.18.0.
  • Add experimental support for native sha1 extension.

1.0.104.0 - December 16, 2016

  • Updated to SQLite 3.15.2.
  • Add the "%PreLoadSQLite_AssemblyDirectory%", "%PreLoadSQLite_TargetFramework%", and "%PreLoadSQLite_XmlConfigDirectory%" replacement tokens for use in configuration setting values. Pursuant to [d4728aecb7].
  • Prevent the GetByte, GetChar, and GetInt16 methods of the SQLiteDataReader class from throwing exceptions for large integer values. Pursuant to [5535448538]. ** Potentially Incompatible Change **
  • Use SAVEPOINTs to properly implement nested transactions when the new AllowNestedTransactions connection flag is used. Pursuant to [1f7bfff467].
  • When converting a Julian Day value to an integer, round to the nearest millisecond first. Pursuant to [69cf6e5dc8]. ** Potentially Incompatible Change **

1.0.103.0 - September 15, 2016

  • Updated to SQLite 3.14.2.
  • Add preliminary support for the .NET Framework 4.6.2.
  • Change the SQLiteReadValueCallback delegate "eventArgs" parameter to be of type SQLiteReadEventArgs. ** Potentially Incompatible Change **
  • Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs. ** Potentially Incompatible Change **
  • Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs. ** Potentially Incompatible Change **
  • Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.
  • Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to [25d53b48f6]. ** Potentially Incompatible Change **
  • Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.
  • Add support for incremental blob I/O.
  • Improve support for the sqlite3_db_config() interface. Pursuant to [f64f4aee95].

1.0.102.0 - June 23, 2016

  • Updated to SQLite 3.13.0.
  • Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available. ** Potentially Incompatible Change **
  • Prevent the SQLiteCommand.ExecuteScalar method from throwing an exception when there are no result columns. ** Potentially Incompatible Change **
  • Support per-connection customization for binding parameters and reading values, based on the database type name.
  • Add TypeName property to the SQLiteParameter class.
  • Add VerifyOnly method to the SQLiteCommand class.
  • Add IsReadOnly method to the SQLiteConnection class.

1.0.101.0 - April 19, 2016

  • Updated to SQLite 3.12.2.
  • Add binary package release for Mono on POSIX.

1.0.100.0 - April 15, 2016

  • Updated to SQLite 3.12.1.
  • Support compiling and using the interop assembly on Linux and Mac OS X.
  • Support running the test suite under Mono on Linux and Mac OS X.
  • Properly handle NULL values in the "name" column of the results returned by PRAGMA index_info(). Fix for [5251bd0878].
  • For column types that resolve to boolean, recognize case-insensitive prefixes of "True" and "False". Fix for [dbd65441a5].
  • Add NoVerifyTextAffinity connection flag to skip type affinity checking when fetching a column value as a string. Pursuant to [dbd65441a5].
  • The UnixEpoch DateTime format should use Int64 internally, not Int32. ** Potentially Incompatible Change **
  • Avoid using Path.Combine with null values in the native library pre-loader. Fix for [da685c0bac].
  • Fix the (unsupported) legacy CryptoAPI based codec so that it no longer prevents page size changes.

1.0.99.1 - March 31, 2016

  • Updated to SQLite 3.9.3.

1.0.99.0 - December 9, 2015

  • Updated to SQLite 3.9.2.
  • Add preliminary support for the .NET Framework 4.6.1.
  • Fix handling of sqlite3_index_info members not available with older versions of the SQLite core library. ** Potentially Incompatible Change **
  • Update and improve documentation comments for the native virtual table methods.
  • Permit an existing registered function to be replaced. Fix for [2556655d1b].
  • Make GetValue work for boolean columns with textual "True" and "False" values. Fix for [7714b60d61]. ** Potentially Incompatible Change **
  • Add Reset method to the SQLiteCommand class.
  • Add FileName property to the SQLiteConnection class.
  • Add experimental support for the native json1 and fts5 extensions.
  • Add GetDatabaseName, GetTableName, and GetOriginalName methods to the SQLiteDataReader class.

1.0.98.0 - August 19, 2015

  • Updated to SQLite 3.8.11.1.
  • Add full support for Visual Studio 2015 and the .NET Framework 4.6.
  • Add support for creating custom SQL functions using delegates.
  • Implement the Substring method for LINQ using the "substr" core SQL function. ** Potentially Incompatible Change **
  • Prevent encrypted connections from being used with the connection pool. Pursuant to [89d3a159f1]. ** Potentially Incompatible Change **
  • Honor the second argument to Math.Round when using LINQ. ** Potentially Incompatible Change **
  • Honor the pre-existing flags for connections during the Open method. Fix for [964063da16]. ** Potentially Incompatible Change **
  • Remove errant semi-colons from the SQL used by LINQ to INSERT and then SELECT rows with composite primary keys. Fix for [9d353b0bd8].
  • Refactor INSERT/UPDATE handling (in the LINQ assembly) so it can handle composite and non-integer primary keys. Fix for [41aea496e0].
  • Change the base type for the SQLiteConnectionFlags enumeration to long integer. ** Potentially Incompatible Change **
  • Add extended return codes to the SQLiteErrorCode enumeration. Pursuant to [71bedaca19]. ** Potentially Incompatible Change **
  • Improve exception handling in all native callbacks implemented in the SQLiteConnection class.
  • Add Progress event and ProgressOps connection string property to enable raising progress events during long-running queries.
  • Add "Recursive Triggers" connection string property to enable or disable the recursive trigger capability. Pursuant to [3a82ee635b].
  • Add NoDefaultFlags connection string property to prevent the default connection flags from being used. Pursuant to [964063da16].
  • Add VfsName connection string property to allow a non-default VFS to be used by the SQLite core library.
  • Add BusyTimeout connection string property to set the busy timeout to be used by the SQLite core library.
  • Add UnbindFunction and UnbindAllFunctions methods to the SQLiteConnection class.
  • Enable integration with the ZipVFS extension.

1.0.97.0 - May 26, 2015

  • Updated to SQLite 3.8.10.2.
  • Updated to Entity Framework 6.1.3.
  • Improve ADO.NET conformance of the SQLiteDataReader.RecordsAffected property. Fix for [74542e702e]. ** Potentially Incompatible Change **
  • Prevent the IDataReader.GetDataTypeName method from throwing "No current row" exceptions. Fix for [94252b9059].
  • When BinaryGUID handling is off, transform the LINQ parameter types as well. Fix for [a4d9c7ee94]. ** Potentially Incompatible Change **
  • The IDataReader.GetDataTypeName method should always return the declared type name. ** Potentially Incompatible Change **
  • Add DefaultFlags_SQLiteConnection environment variable to enable customization of the default connection flags.
  • Prevent calls to sqlite3_step() and sqlite3_interrupt() from being interrupted via ThreadAbortException.
  • Make sure enabling UseUTF16Encoding sets the schema encoding to UTF-16. Fix for [7c151a2f0e].

1.0.96.0 - March 5, 2015

  • Prevent the IDataReader.GetOrdinal method from throwing "No current row" exceptions. Fix for [2be4298631], [abad7c577d], and [c28d7fe915].
  • When counting the number of tables in the GetSchemaTable method, do not include those that have a null or empty name. Fix for [92dbf1229a].

1.0.95.0 - March 2, 2015

  • Updated to SQLite 3.8.8.3.
  • Updated to Entity Framework 6.1.2.
  • Modify configuration file transforms performed by the NuGet packages to allow Entity Framework 6 design-time integration to work automatically. Fix for [2be4298631], [abad7c577d], and [417d669435].
  • The "System.Data.SQLite.EF6*" and "System.Data.SQLite.Linq*" NuGet packages no longer depend on the "System.Data.SQLite.Core*" packages. ** Potentially Incompatible Change **
  • The "System.Data.SQLite.MSIL*" NuGet packages no longer directly include any files; they are now meta-packages. ** Potentially Incompatible Change **
  • The "System.Data.SQLite.x86*" and "System.Data.SQLite.x64*" NuGet packages now depend on the "System.Data.SQLite.Linq" and "System.Data.SQLite.EF6" NuGet packages. ** Potentially Incompatible Change **
  • Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.
  • Make sure SQLiteIndexOutputs.ConstraintUsages instances are created prior to calling ISQLiteManagedModule.BestIndex. Fix for [56f511d268].
  • Correct marshalling of strings and blobs in the SQLiteValue class. Fix for [85b824b736].
  • Various minor performance enhancements to the SQLiteDataReader class. Pursuant to [e122d26e70].
  • Defer disposing of connections created by the static SQLiteCommand.Execute method when a data reader is returned. Fix for [daeaf3150a].
  • Wrap SELECT statements in parenthesis if they have an ORDER BY, LIMIT, or OFFSET clause and a compound operator is involved. Fix for [0a32885109].
  • In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for [c5cc2fb334]. ** Potentially Incompatible Change **
  • Handle Julian Day values that fall outside of the supported range for OLE Automation dates. Fix for [3e783eecbe]. ** Potentially Incompatible Change **
  • Make sure the interop files are copied when publishing a project that refers to a NuGet package containing them. Fix for [e796ac82c1]. ** Potentially Incompatible Change **
  • Make sure the interop files are copied before the PostBuildEvent. Fix for [f16c93a932]. ** Potentially Incompatible Change **
  • Modify GetSchemaTable method to avoid setting SchemaTableColumn.IsKey column to true when more than one table is referenced. Fix for [47c6fa04d3]. ** Potentially Incompatible Change **
  • Add AppendManifestToken_SQLiteProviderManifest environment variable to enable better integration between LINQ and the underlying store connection.
  • Add SQLite_ForceLogPrepare environment variable to force logging of all prepared SQL regardless of the flags for the associated connection.
  • Honor the DateTimeFormat, DateTimeKind, DateTimeFormatString, BinaryGUID connection string and/or provider manifest token properties from within the LINQ assembly. Fix for [8d928c3e88]. ** Potentially Incompatible Change **
  • Add PrepareRetries connection string property to allow the maximum number of retries when preparing a query to be overridden. Fix for [647d282d11].
  • Add BindDateTimeWithKind connection flag to force DateTime parameter values to match the DateTimeKind associated with the connection, if applicable. Fix for [a7d04fb111].

1.0.94.0 - September 9, 2014

  • Updated to SQLite 3.8.6.
  • Updated to Entity Framework 6.1.1.
  • Refactor and simplify NuGet packages in order to support per-solution SQLite interop assembly files. ** Potentially Incompatible Change **
  • Add RefreshFlags method to the SQLiteDataReader class to forcibly refresh its connection flags.
  • Improve automatic detection and handling of the Entity Framework 6 assembly by the design-time components installer. Pursuant to [e634e330a6]. ** Potentially Incompatible Change **
  • Improve SQLiteDataReader performance slightly by caching the connection flags. ** Potentially Incompatible Change **
  • Add ClearCachedSettings method to the SQLiteConnection class.
  • Add NoConvertSettings connection flag to disable querying of runtime configuration settings from within the SQLiteConvert class. Pursuant to [58ed318f2f].
  • Minimize usage of the "Use_SQLiteConvert_DefaultDbType" and "Use_SQLiteConvert_DefaultTypeName" settings. Fix for [58ed318f2f]. ** Potentially Incompatible Change **

1.0.93.0 - June 23, 2014

  • Updated to SQLite 3.8.5.
  • Updated to Entity Framework 6.1.
  • Add support for mapping transaction isolation levels to their legacy default values. Pursuant to [56b42d99c1].
  • Add support for setting the default DbType and type name used for mappings on a per-connection basis. Pursuant to [3c00ec5b52].
  • Add DetectTextAffinity and DetectStringType connection flags to enable automatic detection of column types, when necessary. Pursuant to [3c00ec5b52].
  • Add SetChunkSize method to the SQLiteConnection class. Pursuant to [d1c008fa0a].
  • Add SharedFlags static property to the SQLiteConnection class.
  • Make the ISQLiteSchemaExtensions interface public. ** Potentially Incompatible Change **
  • Have the SQLiteProviderFactory class (in the System.Data.SQLite.Linq assembly) implement the IServiceProvider interface.
  • Fix bug in documentation generator automation that prevented some internal documentation links from working.
  • Fix DateTime constant handling in the LINQ assembly. Fix for [da9f18d039]. ** Potentially Incompatible Change **

1.0.92.0 - March 19, 2014

  • Updated to SQLite 3.8.4.1.
  • Update the list of keywords returned by SQLiteConnection.GetSchema("ReservedWords"). ** Potentially Incompatible Change **
  • Raise the static SQLiteConnection.Changed event when any SQLiteCommand or SQLiteDataReader object is closed or disposed.
  • Add the SQLiteDataReader.StepCount property to return the number of rows seen so far.
  • Add StickyHasRows connection flag to cause the SQLiteDataReader.HasRows property to return non-zero if there were ever any rows in the associated result sets.
  • When the TraceWarning connection flag is set, issue warnings about possibly malformed UNC paths. Pursuant to [283344397b].
  • Convert the primary NuGet package, "System.Data.SQLite", into a meta-package.
  • Enhancements to the NuGet packages, including the new "modular" packages.

1.0.91.0 - February 12, 2014

  • Updated to SQLite 3.8.3.1.
  • Refresh all included SQLite core library documentation (e.g. SQL syntax).
  • Add support for Entity Framework 6.
  • Add support for per-connection mappings between type names and DbType values. Pursuant to [e87af1d06a].
  • Modify the namespace used for all internal classes in the System.Data.SQLite.Linq assembly. ** Potentially Incompatible Change **
  • Add SQLiteCompileOptions and InteropCompileOptions properties to the SQLiteConnection class to return the compile-time options for the SQLite core library and interop assembly, respectively.
  • Add BindInvariantText and ConvertInvariantText connection flags to force the invariant culture to be used when converting parameter values to/from strings.
  • Add NoConnectionPool and UseConnectionPool connection flags to disable or enable connection pooling by default.
  • Modify handling of the design-time components installer to run Visual Studio devenv.exe /setup after installing the package. This appears to be necessary in some circumstances for Visual Studio 2013. Pursuant to [a47eff2c71].
  • Modify the native library pre-loader to support reading settings from an XML configuration file and to be capable of checking more than one directory. Persuant to [f0246d1817].
  • Support detecting when the native library pre-loader should use the CodeBase property instead of the Location property as the basis for locating the interop assembly.
  • Change the default behavior for the native library pre-loader so it first searches the executing (i.e. System.Data.SQLite) assembly directory and then the application domain directory. Pursuant to [f0246d1817]. ** Potentially Incompatible Change **
  • Include DbType.AnsiString in the list of types that need special ColumnSize handling. Fix for [0550f0326e].

1.0.90.0 - December 23, 2013

  • Updated to SQLite 3.8.2.
  • Add Visual Studio 2013 support to all the applicable solution/project files, their associated supporting files, and the test suite.
  • Add Visual Studio 2013 support to the redesigned designer support installer.
  • Add support for Windows Embedded Compact 2013.
  • Add experimental support for the native regexp extension.
  • Never create a new connection wrapper in the SQLiteConnection.Shutdown method. ** Potentially Incompatible Change **
  • Add experimental GetMemoryStatistics, ReleaseMemory, and Shutdown methods to the SQLiteConnection class.
  • Add memory leak detection to the test project for the .NET Compact Framework.
  • Add SQLITE_ENABLE_MEMORY_MANAGEMENT compile-time option to the interop assembly.
  • Use current isolation level when enlisting into an existing transaction. Fix for [56b42d99c1].
  • Better handling of non-error log messages from the SQLite core library. Pursuant to [44df10ea90].
  • Add TraceWarning connection flag to enable tracing of type mapping failures and disable tracing of them by default. Pursuant to [6d45c782e4].
  • Use 32-bit values to keep track of numeric precision and scale when building the schema table for a query. Fix for [ef2216192d].

1.0.89.0 - October 28, 2013

  • Updated to SQLite 3.8.1.
  • Add AutoCommit property to the SQLiteConnection class. Fix for [9ba9346f75].
  • Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605].
  • Check the result of sqlite3_column_name function against NULL.
  • Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.
  • Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for [aba4549801].
  • Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.
  • Revise how the extra object data is passed to the static SQLiteConnection.Changed event. ** Potentially Incompatible Change **
  • Make sure the database cannot be changed by a query when the CommandBehavior.SchemaOnly flag is used. Fix for [f8dbab8baf]. ** Potentially Incompatible Change **
  • Fix bug in NDoc3 that was preventing some of the MSDN documentation links from working.
  • Include the XML documentation files in the NuGet packages. Fix for [5970d5b0a6].
  • Add InteropVersion, InteropSourceId, ProviderVersion, and ProviderSourceId properties to the SQLiteConnection class.
  • Add experimental support for interfacing with the authorizer callback in the SQLite core library.
  • Add experimental support for the native totype extension.

1.0.88.0 - August 7, 2013

  • Various fixes to managed virtual table integration infrastructure.
  • Implement workaround for an incorrect PROCESSOR_ARCHITECTURE being reported. Fix for [9ac9862611].
  • Modify classes that implement the IDisposable pattern to set the disposed flag after their base classes have been disposed.
  • When automatically registering custom functions, use the executing assembly (i.e. System.Data.SQLite) for reference detection. Fix for [4e49a58c4c].

1.0.87.0 - July 8, 2013

  • Add all the necessary infrastructure to allow virtual tables to be implemented in managed code. Fix for [9a544991be].
  • The DbType to type name translation needs to prioritize the Entity Framework type names. Fix for [47f4bac575].
  • Add DateTimeFormatString connection string property to allow the DateTime format string used for all parsing and formatting to be overridden.
  • Add NoFunctions connection flag to skip binding functions registered in the application domain.
  • Add several data-types for compatibility purposes. Fix for [fe50b8c2e8].
  • Add SQLiteConnection.BindFunction method to facilitate adding custom functions on a per-connection basis.
  • When reading a DateTime value, avoid unnecessary string conversions. Fix for [4d87fbc742].
  • Modify the index introspection code so that it does not treat PRAGMA table_info "pk" column values as boolean. Fix for [f2c47a01eb].
  • Disable use of the new connection string parsing algorithm when the No_SQLiteConnectionNewParser environment variable is set. Pursuant to [bbdda6eae2].
  • Rename the ReturnCode property of the SQLiteException class to ResultCode. ** Potentially Incompatible Change **

1.0.86.0 - May 23, 2013

  • Updated to SQLite 3.7.17.
  • Disable use of the AllowPartiallyTrustedCallers attribute when compiled for the .NET Framework 4.0/4.5. ** Potentially Incompatible Change **
  • Allow semi-colons in the data source file name. Fix for [e47b3d8346]. ** Potentially Incompatible Change **
  • NULL values should be reported as type "object", not "DBNull". Fix for [48a6b8e4ca].

1.0.85.0 - April 18, 2013

  • Updated to SQLite 3.7.16.2.
  • Properly handle embedded NUL characters in parameter and column values. Fix for [3567020edf].
  • Make use of the sqlite3_prepare_v2 function when applicable.
  • Check for a valid row in the SQLiteDataReader.GetValue method.
  • Implement processor architecture detection when running on the .NET Compact Framework (via P/Invoke).
  • Support automated testing when running on the .NET Compact Framework 2.0.
  • Skip checking loaded assemblies for types tagged with the SQLiteFunction attribute when the No_SQLiteFunctions environment variable is set. Pursuant to [e4c8121f7b].
  • Add HexPassword connection string property to work around the inability to include a literal semicolon in a connection string property value. Pursuant to [1c456ae75f].
  • Add static Execute method to the SQLiteCommand class.
  • Support custom connection pool implementations by adding the ISQLiteConnectionPool interface, the static SQLiteConnection.ConnectionPool property, and the static CreateHandle method in addition to modifying the SQLiteConnectionPool class. Pursuant to [393d954be0].
  • Add public constructor to the SQLiteDataAdapter class that allows passing the parseViaFramework parameter to the SQLiteConnection constructor.
  • When built with the CHECK_STATE compile-time option, skip throwing exceptions from the SQLiteDataReader class when the object is being disposed.
  • Support automatic value conversions for columns with a declared type of BIGUINT, INTEGER8, INTEGER16, INTEGER32, INTEGER64, SMALLUINT, TINYSINT, UNSIGNEDINTEGER, UNSIGNEDINTEGER8, UNSIGNEDINTEGER16, UNSIGNEDINTEGER32, UNSIGNEDINTEGER64, INT8, INT16, INT32, INT64, UINT, UINT8, UINT16, UINT32, UINT64, or ULONG.
  • Add BindUInt32AsInt64 connection flag to force binding of UInt32 values as Int64 instead. Pursuant to [c010fa6584].
  • Add BindAllAsText and GetAllAsText connection flags to force binding and returning of all values as text.
  • Remove AUTOINCREMENT from the column type name map. ** Potentially Incompatible Change **
  • Avoid throwing overflow exceptions from the SQLite3.GetValue method for integral column types. Partial fix for [c010fa6584]. ** Potentially Incompatible Change **
  • Use the legacy connection closing algorithm when built with the INTEROP_LEGACY_CLOSE compile-time option.
  • Support using the directory containing the primary managed-only assembly as the basis for native library pre-loading.
  • Still further enhancements to the build and test automation.

1.0.84.0 - January 9, 2013

  • Updated to SQLite 3.7.15.2.
  • Explicitly dispose of all SQLiteCommand objects managed by the DbDataAdapter class. Fix for [6434e23a0f].
  • Add Cancel method to the SQLiteConnection class to interrupt a long running query.
  • Improve thread safety of the SQLiteLog.LogMessage method.

1.0.83.0 - December 29, 2012

  • Updated to SQLite 3.7.15.1.
  • Add Visual Studio 2012 support to all the applicable solution/project files, their associated supporting files, and the test suite.
  • Add Visual Studio 2012 support to the redesigned designer support installer.
  • Allow opened connections to skip adding the extension functions included in the interop assembly via the new NoExtensionFunctions connection flag.
  • Support loading of SQLite extensions via the new EnableExtensions and LoadExtension methods of the SQLiteConnection class. Pursuant to [17045010df].
  • Remove one set of surrounding single or double quotes from property names and values parsed from the connection string. Fix for [b4cc611998].
  • Modify parsing of connection strings to allow property names and values to be quoted. ** Potentially Incompatible Change **
  • Add ParseViaFramework property to the SQLiteConnection class to allow the built-in (i.e. framework provided) connection string parser to be used when opening a connection. Pursuant to [b4cc611998].
  • Add notifications before and after any connection is opened and closed, as well as other related notifications, via the new static Changed event.
  • Add an overload of the SQLiteLog.LogMessage method that takes a single string parameter.
  • Add an overload of the SQLiteConnection.LogMessage method that takes a SQLiteErrorCode parameter.
  • All applicable calls into the SQLite core library now return a SQLiteErrorCode instead of an integer error code.
  • Make sure the error code of the SQLiteException class gets serialized.
  • Make the test project for the .NET Compact Framework more flexible.
  • When available, the new sqlite3_errstr function from the core library is used to get the error message for a specific return code.
  • The SetMemoryStatus, Shutdown, ResultCode, ExtendedResultCode, and SetAvRetry methods of the SQLiteConnection class now return a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
  • The public constructor for the SQLiteException now takes a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
  • The ErrorCode property of the SQLiteException is now an Int32, to allow the property inherited from the base class to be properly overridden. ** Potentially Incompatible Change **
  • The ErrorCode field of the LogEventArgs is now an object instead of an integer. ** Potentially Incompatible Change **
  • The names and messages associated with the SQLiteErrorCode enumeration values have been normalized to match those in the SQLite core library. ** Potentially Incompatible Change **
  • Implement more robust locking semantics for the CriticalHandle derived classes when compiled for the .NET Compact Framework.
  • Cache column indexes as they are looked up when using the SQLiteDataReader to improve performance.
  • Prevent the SQLiteConnection.Close method from throwing non-fatal exceptions during its disposal.
  • Rename the interop assembly functions sqlite3_cursor_rowid, sqlite3_context_collcompare, sqlite3_context_collseq, sqlite3_cursor_rowid, and sqlite3_table_cursor to include an "_interop" suffix. ** Potentially Incompatible Change **
  • Prevent the LastInsertRowId, MemoryUsed, and MemoryHighwater connection properties from throwing NotSupportedException when running on the .NET Compact Framework. Fix for [dd45aba387].
  • Improve automatic detection of the sqlite3_close_v2 function when compiled to use the standard SQLite library.
  • Add protection against ThreadAbortException asynchronously interrupting native resource initialization and finalization.
  • Add native logging callback for use with the sqlite3_log function to the interop assembly, enabled via the INTEROP_LOG preprocessor definition.
  • Add various diagnostic messages to the interop assembly, enabled via flags in the INTEROP_DEBUG preprocessor definition.
  • Further enhancements to the build and test automation.
  • Add test automation for the Windows CE binaries.

1.0.82.0 - September 3, 2012

  • Updated to SQLite 3.7.14.
  • Properly handle quoted data source values in the connection string. Fix for [8c3bee31c8].
  • The primary NuGet package now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).
  • Change the default value for the Synchronous connection string property to Full to match the default used by the SQLite core library itself. ** Potentially Incompatible Change **
  • Add the ability to skip applying default connection settings to opened databases via the new SetDefaults connection string property.
  • Add the ability to skip expanding data source file names to their fully qualified paths via the new ToFullPath connection string property.
  • Fix the database cleanup ordering in the tests for ticket [343d392b51].
  • Add support for the sqlite3_close_v2 function from the SQLite core library.
  • Add support for URI file names via the new FullUri connection string property.
  • Improve support for the standard SQLite core library in the LINQ assembly and the test suite.
  • Add SetMemoryStatus static method to the SQLiteConnection class.
  • Improve threaded handling of the delegate used by the SQLiteLog class.
  • Add define constants to support enabling or disabling individual groups of trace statements.

1.0.81.0 - May 27, 2012

  • Updated to SQLite 3.7.12.1.
  • Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.
  • Add DefineConstants property to the SQLiteConnection class to return the list of define constants used when compiling the core managed assembly.
  • Add release archive verification tool to the release automation.
  • Fix NullReferenceException when calling the SQLiteDataAdapter.FillSchema method on a query that returns multiple result sets. Fix for [3aa50d8413].
  • Fix subtle race condition between threads fetching connection handles from the connection pool and any garbage collection (GC) threads that may be running. Fix for [996d13cd87].
  • Add missing call to SetTimeout in the SQLite3_UTF16.Open method.
  • Add checks to prevent the SQLiteConnectionPool.Remove method from returning any connection handles that are closed or invalid.
  • Modify static SQLiteBase helper methods to prevent them from passing IntPtr.Zero to the SQLite native library.
  • Remove static locks from the static helper methods in the SQLiteBase class, replacing them with a lock on the connection handle instance being operated upon.
  • Revise CriticalHandle derived classes to make them more thread-safe.
  • Add connection pool related diagnostic messages when compiled with the DEBUG define constant.
  • Add PoolCount property to the SQLiteConnection class to return the number of pool entries for the file name associated with the connection.
  • Rename internal SQLiteLastError methods to GetLastError.
  • Add assembly file test constraints to all tests that execute the "test.exe" or "testlinq.exe" files.

1.0.80.0 - April 1, 2012

  • Updated to SQLite 3.7.11.
  • In the SQLiteFunction class, when calling user-provided methods from a delegate called by native code, avoid throwing exceptions, optionally tracing the caught exceptions. Fix for [8a426d12eb].
  • Add Visual Studio 2005 support to all the applicable solution/project files, their associated supporting files, and the test suite.
  • Add Visual Studio 2005 support to the redesigned designer support installer.
  • Add experimental support for "pre-loading" the native SQLite library based on the processor architecture of the current process. This feature is now enabled by default at compile-time.
  • Add support for the native SQLite Online Backup API. Fix for [c71846ed57].
  • Acquire and hold a static data lock while checking if the native SQLite library has been initialized to prevent a subtle race condition that can result in superfluous error messages. Fix for [72905c9a77].
  • Support tracing of all parameter binding activity and use the connection flags to control what is traced.
  • When converting a DateTime instance of an "Unspecified" kind to a string, use the same kind as the connection, if available.
  • Add overload of the SQLiteDataReader.GetValues method that returns a NameValueCollection.
  • Add static ToUnixEpoch method to the SQLiteConvert class to convert a DateTime value to the number of whole seconds since the Unix epoch.
  • In the implicit conversion operators (to IntPtr) for both the SQLiteConnectionHandle and SQLiteStatementHandle classes, return IntPtr.Zero if the instance being converted is null.
  • Write warning message to the active trace listeners (for the Debug build configuration only) if a column type or type name cannot be mapped properly. See [4bbf851fa5].
  • When tracing SQL statements to be prepared, bypass the internal length limit of the sqlite3_log function by using the SQLiteLog class directly instead. Also, detect null and/or empty strings and emit a special message in that case.
  • For the setup, the Visual Studio task should only be initially checked if the GAC task is available and vice-versa.
  • Improve compatibility with custom command processors by using __ECHO instead of _ECHO in batch tools.
  • Add OpenAndReturn method to the SQLiteConnection class to open a connection and return it.
  • Add missing CheckDisposed calls to the SQLiteConnection class.
  • Add missing throw statement to the SQLiteConnection class.
  • Make sure the interop project uses /fp:precise for Windows CE.
  • Regenerate package load key to support loading the designer package into Visual Studio 2008 without having the matching SDK installed.
  • Modify transaction object disposal so that it can never cause an exception to be thrown.

1.0.79.0 - January 28, 2012

  • Use the WoW64 registry keys when installing the VS designer components on 64-bit Windows. Fix for [d8491abd0b].
  • Correct resource name used by the LINQ assembly to locate several key string resources. Fix for [fbebb30da9].

1.0.78.0 - January 27, 2012

  • Updated to SQLite 3.7.10.
  • Redesign the VS designer support installer and integrate it into the setup packages.
  • When emitting SQL for foreign keys in the VS designer, be sure to take all returned schema rows into account. Remainder of fix for [b226147b37].
  • Add Flags connection string property to control extra behavioral flags for the connection.
  • Refactor all IDisposable implementations to conform to best practices, potentially eliminating leaks in certain circumstances.
  • Even more enhancements to the build and test automation.
  • Support parameter binding to more primitive types, including unsigned integer types.
  • Recognize the TIMESTAMP column data type as the DateTime type. Fix for [bb4b04d457].
  • Prevent logging superfluous messages having to do with library initialization checking. Fix for [3fc172d1be].
  • Support the DateTimeKind and BaseSchemaName connection string properties in the SQLiteConnectionStringBuilder class. Fix for [f3ec1e0066].
  • Overloads of the SQLiteConvert.ToDateTime and SQLiteConvert.ToJulianDay methods that do not require an instance should be static. Partial fix for [4bbf851fa5]. ** Potentially Incompatible Change **

1.0.77.0 - November 28, 2011

  • Updated to SQLite 3.7.9.
  • More enhancements to the build and test automation.
  • Plug native memory leak when closing a database connection containing a statement that cannot be finalized for some reason.
  • The SQLite3 class should always attempt to dispose the contained SQLiteConnectionHandle, even when called via the finalizer.
  • When compiled with DEBUG defined, emit diagnostic information related to resource cleanup to any TraceListener objects that may be registered.
  • Stop characterizing all log messages as errors. From now on, if the errorCode is zero, the message will not be considered an error.
  • Never attempt to configure the native logging interface if the SQLite core library has already been initialized for the process. Fix for [2ce0870fad].
  • Allow the SQLiteLog class to be used for logging messages without having an open connection.
  • Support building the core System.Data.SQLite assemblies using the .NET Framework 4.0 Client Profile. Fix for [566f1ad1e4].
  • When generating the schema based on the contents of a SQLiteDataReader, skip flagging columns as unique if the data reader is holding the result of some kind of multi-table construct (e.g. a cross join) because we must allow duplicate values in that case. Fix for [7e3fa93744].
  • When returning schema information that may be used by the .NET Framework to construct dynamic SQL, use a fake schema name (instead of null) so that the table names will be properly qualified with the catalog name (i.e. the attached database name). Partial fix for [343d392b51].
  • Add SQLiteSourceId property to the SQLiteConnection class to return the SQLite source identifier.
  • Add MemoryUsed and MemoryHighwater properties to the SQLiteConnection class to help determine the memory usage of SQLite.
  • Add DateTimeKind connection string property to control the DateTimeKind of parsed DateTime values. Partial fix for [343d392b51]. ** Potentially Incompatible Change **
  • Improve the robustness of the SQLiteLog class when it will be initialized and unloaded multiple times.
  • Fix the name of the interop assembly for Windows CE. Add unit tests to prevent this type of issue from happening again. Fix for [737ca4ff74].
  • Formally support the SQL type name BOOLEAN in addition to BOOL. Fix for [544dba0a2f].
  • Make sure the SQLiteConvert.TypeNameToDbType method is thread-safe. Fix for [84718e79fa].

1.0.76.0 - October 4, 2011

  • Prevent the domain unload event handler in SQLiteLog from being registered multiple times. Fix for [0d5b1ef362].
  • Stop allowing non-default application domains to initialize the SQLiteLog class. Fix for [ac47dd230a].

1.0.75.0 - October 3, 2011

  • Updated to SQLite 3.7.8.
  • More enhancements to the build system.
  • Add official NuGet packages for x86 and x64.
  • Add Changes and LastInsertRowId properties to the connection class.
  • Support more formats when converting data from/to the DateTime type.
  • Make all the assembly versioning attributes consistent.
  • Add unit testing infrastructure using Eagle.
  • Integrate all legacy unit tests, including the "testlinq" project, into the new test suite.
  • Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for [53f0c5cbf6].
  • Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly. Fix for [74807fbf27].
  • Fix mutex issues exposed when running the test suite with the debug version of SQLite.
  • Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for [ccfa69fc32].
  • Support the SQLITE_FCNTL_WIN32_AV_RETRY file control to mitigate the impact of file sharing violations caused by external processes.
  • Refactor the logging interface to be thread-safe and self-initializing.
  • Shutdown the SQLite native interface when the AppDomain is being unloaded. Fix for [b4a7ddc83f].
  • Support Skip operation for LINQ using OFFSET. Fix for [8b7d179c3c].
  • Support EndsWith operation for LINQ using SUBSTR. Fix for [59edc1018b].
  • Support all SQLite journal modes. Fix for [448d663d11].
  • Do not throw exceptions when disposing SQLiteDataReader. Fix for [e1b2e0f769].
  • The REAL type should be mapped to System.Double. Fix for [2c630bffa7] and [b0a5990f48].
  • Minor optimization to GetParamValueBytes(). Fix for [201128cc88].
  • Support the ON UPDATE, ON DELETE, and MATCH clause information when generating schema metadata for foreign keys. Partial fix for [b226147b37]. VS designer changes are not yet tested.
  • Fix incorrect resource name for SR.resx in the mixed-mode assembly.
  • Reduce the number of String.Compare() calls in the hot path for SQLiteCommand.ExecuteReader().

1.0.74.0 - July 4, 2011

  • Updated to SQLite 3.7.7.1.
  • Fix incorrect hard-coded .NET Framework version information SQLiteFactory_Linq.cs that was causing IServiceProvider.GetService to fail when running against the .NET Framework 3.5.
  • Fix all XML documentation warnings.
  • Restore support for the mixed-mode assembly (i.e. the one that can be registered in the Global Assembly Cache).
  • Restore support for the Compact Framework.
  • Remove unused "using" statements from the System.Data.SQLite and System.Data.SQLite.Linq projects.
  • Remove hard-coded System.Data.SQLite.Linq version from SQLiteFactory_Linq.cs
  • Modify the setup to support bundled packages (i.e. with the mixed-mode assembly) and standard packages (i.e. with the managed assembly separate from the native interop library).
  • Disable the ability to register with the Global Assembly Cache in the standard setup package (i.e. it is available in the bundled setup only).
  • Remove PATH modification from the setup.
  • Modify the naming scheme for the source, setup, and binary packages to allow for the necessary variants.
  • In the build automation, attempt to automatically detect if Visual Studio 2008 and/or 2010 are installed and support building binaries for both at once, when available.
  • Add release automation to build the source, setup, and binary packages in all supported build variants.
  • Add the testlinq project to the new build system and make it work properly with Visual Studio 2008 and 2010.

1.0.73.0 - June 2, 2011

  • Updated to SQLite 3.7.6.3.
  • Minor optimization to GetBytes(). Fix for [8c1650482e].
  • Update various assembly information settings.
  • Correct System.Data.SQLite.Linq version and resource information. Fix for [6489c5a396] and [133daf50d6].
  • Moved log handler from SQLiteConnection object to SQLiteFactory object to prevent if from being prematurely GCed.
  • We should block x64 installs on x86 and we should install native only if the setup package itself is native. Fix for [e058ce156e].

1.0.72.0 - May 1, 2011

  • Add the correct directory to the path. Fix for [50515a0c8e].

1.0.71.0 - April 27, 2011

  • Updated to SQLite 3.7.6+ [1bd1484cd7] to get additional Windows error logging.
  • Updated setup to optionally add install directory to PATH if GAC option selected.

1.0.70.0 - April 22, 2011

  • Added support for sqlite3_extended_result_codes(), sqlite3_errcode(), and sqlite3_extended_errcode() via SetExtendedResultCodes(), ResultCode(), and ExtendedResultCode().
  • Added support for SQLITE_CONFIG_LOG via SQLiteLogEventHandler().

1.0.69.0 - April 12, 2011

  • Code merge with SQLite 3.7.6.
  • New VS2008 and VS2010 solution files.
  • Build and packaging automation.
  • New Inno Setup files.
  • Designer support currently not ready for release.

1.0.68.0 - February 2011

  • Code merge with SQLite 3.7.5.
  • Continuing work on supporting Visual Studio 2010.

1.0.67.0 - January 3, 2011

  • Code merge with SQLite 3.7.4.
  • Continuing work on supporting Visual Studio 2010.

1.0.66.1 - August 1, 2010

  • Code merge with SQLite 3.7.0.1
  • Re-enabled VS2005 designer support, broken in previous versions during the 2008 transition
  • Implemented new forms of Take/Skip in the EF framework courtesy jlsantiago
  • Added "Foreign Keys" to the connection string parameters
  • Added the Truncate option to the Journal Modes enumeration

1.0.66.0 - April 18, 2010

  • Code merge with SQLite 3.6.23.1
  • Fixed a bug in the installer that accidentally modified the machine.config on .NET versions prior to 2.0, invaliding the config file.
  • Fixed INTERSECT and EXCEPT union query generation in EF
  • Fixed an out of memory error in the trigger designer in cases where a WHEN clause is used in the trigger

1.0.65.0 - July 26, 2009

  • Fixed a bug in the encryption module to prevent a double free() when rekeying a database.
  • Fixed a bug in the encryption module when ATTACHing an encrypted database.
  • Incorporated the WinCE locking fix from ticket #3991
  • Added "bigint" to the dropdown in the table designer, plus other minor table designer bugfixes.

1.0.64.0 - July 9, 2009

  • Fixed the missing resources problem from the 63 release.
  • Added preliminary support for the Visual Studio 2010 beta.
  • Fixed a bug in SQLiteCommand that threw a null reference exception when setting the Transaction object to null.
  • If SQLiteConnection.EnlistTransaction is called multiple times for the same transaction scope, just return without throwing an error.

1.0.63.0 - June 29, 2009

  • Code merge with SQLite 3.6.16
  • Check the autocommit mode of the connection to which a transaction is bound during the disposal of the transaction. If autocommit is enabled, then the database has already rolled back the transaction and we don't need to do it during dispose, and can quietly ignore the step without throwing an error.
  • Eliminated the mergebin step altogether. It was developed primarily to merge the Compact Framework binaries together, but since we're not doing that anymore, its use is limited. Its non-standard method of merging a binary on the desktop framework is redundant as well. The desktop binary now hard-links to MSCOREE, but as of Windows XP, this was redundant as well since XP and beyond automatically attempt to load MSCOREE on startup when a DLL has a .NET header.
  • More improvements to the test.exe program for running the tests against Sql Server for comparison purposes.

1.0.62.0 - June 20, 2009

  • Code merge with SQLite 3.6.15
  • Fixed the decimal reading bug in the SQLiteDataReader
  • Changed Join()'s to Sleep()'s in the statement retry code to prevent message pumping
  • Fixed a bad pointer conversion when retrieving blobs using GetBytes() in 64-bit land
  • Several changes to the Test program that comes with the provider. Tests can now be individually disabled, and the test program can run against several provider back-ends

1.0.61.0 - April 28, 2009

  • Code merge with SQLite 3.6.13. The new backup features are as yet unimplemented in the provider, but will be forthcoming in a subsequent release
  • Fixed the default-value lookups in SQLiteConnectionStringBuilder when accessing properties
  • Lock the SQLiteTransaction object during dispose to avoid potential race condition during cleanup
  • Fixed SQLiteDataReader.GetDecimal() processing and parsing of decimal values for cases when SQLite returns things like "1.0e-05" instead of "0.0001"

1.0.60.0 - October 3, 2008

  • Throw a NotSupported exception in the EF Sql Gen code instead of parsing illegal SQL during an update/insert/delete where no primary key is defined.
  • Fixed the Compact Framework interop library. Since the linker flag /subsystem had no version specified, it was causing a problem for many CE-based platforms.
  • Incorporated SQLite patch for ticket #3387 and reverted out the vfs override code I added in build 59 to work around this problem.
  • Fixed a designer issue when creating a new table from the Server Explorer. After initially saving it, if you then continued to edit it and tried to save it again, it would generate the change SQL using the old temporary table name rather than the new name.

1.0.59.0 - September 22, 2008

  • Code merge with SQLite 3.6.3. Solves a couple different EF issues that were either giving inconsistent results or crashing the engine.
  • Fixed the parsing of literal binaries in the EF SqlGen code. SQLite now passes nearly all the testcases in Microsoft's EF Query Samples application -- the exception being the datetimeoffset and time constants tests, and tests that use the APPLY keyword which are unsupported for now.
  • Revamped the Compact Framework mixed-mode assembly. Tired of playing cat and mouse with the Compact Framework's support for mixed-mode assemblies. The CF build now requires that you distribute both the System.Data.SQLite library and the paired SQLite.Interop.XXX library. The XXX denotes the build number of the library.
  • Implemented a workaround for Vista's overzealous caching by turning off FILE_FLAG_RANDOM_ACCESS for OS versions above XP. This is implemented as a custom (default override) VFS in the interop.c file, so no changes are made to the SQLite source code.
  • Fixed some registry issues in the designer install.exe, which prevented some design-time stuff from working on the Compact Framework when .NET 3.5 was installed.

1.0.58.0 - August 30, 2008

  • Code merge with SQLite 3.6.2. If only I'd waited one more day to release 57! Several LINQ issues have been resolved with this engine release relating to deeply-nested subqueries that the EF SqlGen creates.
  • Fixed the Rollback SQLiteConnection event to not require a connection be opened first.

1.0.57.0 - August 29, 2008

  • Compiled against 3.6.1 with checkin #3300 resolved, which fixes an Entity Framework bug I was seeing. I currently have 3 other tickets out on the engine, which are not yet resolved and relate to EF.
  • Fixed decimal types to store and fetch using InvariantCulture. If you're using decimal datatypes in your database and were affected by the 56 release, please issue an UPDATE <table> SET <column> = REPLACE(<column>, ',', '.'); to fix the decimal separators. Apologies for not testing that more thoroughly before releasing 56.
  • Too many LINQ fixes to list. Fixed views so they generate, fixed the LIMIT clause, implemented additional functionality and removed unnecessary code.
  • Fixed foreign key names in the designer so viewing the SQL script on a new unsaved table after renaming it in the properties toolwindow will reflect in the script properly.
  • Fixed the Update and Commit events on SQLiteConnection so they don't require the connection to be opened first.
  • Fixed userdef aggregate functions so they play nice with each other when appearing multiple times in the same statement.
  • Fixed the editing and saving of default values in the table designer.
  • Fixed ForeignKeys schema to support multi-column foreign keys. Also hacked support for them in the table designer, provided two foreign keys in the designer have the same name and reference the same foreign table and different columns. Will implement first-class support for this in the next release.

1.0.56.0 - August 11, 2008

  • Fixed a bug in the table designer when designing new tables, wherein you had to save the table first before being able to create indexes and foreign keys.
  • Tweaks to decimal type handling. The 'decimal' type can't be represented by Int64 or Double (without loss of precision) in SQLite, so we have to fudge it by treating it like a string and converting it back and forth in the provider. Unfortunately backing it to the db as a string causes sorting problems. See this post for details on using a custom collation sequence to overcome the sorting issue arising from this patch.
  • Minor tweaks and bugfixes to the test program and the provider.
  • More adjustments to make the managed-only version of the provider run and pass all tests on Mono.
  • LINQ to Entities bits heavily updated and compiled against VS2008 SP1 RTM. SQLite LINQ support is still considered beta.

1.0.55.0 - August 6, 2008

  • Code merge with SQLite 3.6.1
  • Added support for the user-contributed extension-functions at https://www.sqlite.org/contrib. Feel free to override any of them with your own implementation. The new functions are: acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi, replicate, charindex, leftstr, rightstr, reverse, proper, padl, padr, padc, strfilter, and aggregates stdev, variance, mode, median, lower_quartile, upper_quartile.
  • Moved the last_rows_affected() function to the C extension library.
  • Added a new class, SQLiteFunctionEx which extends SQLiteFunction and adds the ability for a user-defined function to get the collating sequence during the Invoke/Step methods. User-defined functions can use the collating sequence as a helper to compare values.
  • When registering user-defined collation sequences and functions, the provider will now register both a UTF8 and a UTF16 version instead of just UTF8.
  • Revamped connection pooling and added static ClearPool() and ClearAllPools() functions to SQLiteConnection. Behavior of the pool and its clearing mechanics match SqlClient.
  • Fixed connections going to the pool so that any unfinalized lingering commands from un-collected datareaders are automatically reset and any lurking transactions made on the connection are rolled back.
  • Transaction isolation levels are now partially supported. Serializable is the default, which obtains read/write locks immediately -- this is compatible with previous releases of the provider. Unspecified will default to whatever the default isolation mode is set to, and ReadCommitted will cause a deferred lock to be obtained. No other values are legal.
  • Revamped the test.exe program. It's now an interactive GUI application. Easier for me to add tests now.
  • Tweaks to the VS designer package and installer.
  • More adjustments to the internal SQLite3.Prepare() method to account for both kinds of lock errors when retrying.
  • Stripped a lot of unnecessary interop() calls and replaced with base sqlite calls. Revamped most of UnsafeNativeMethods to make it easier to port the code.
  • Rerigged internal callbacks for userdef functions and other native to managed callbacks. More portable this way.
  • Source can now can be compiled with the SQLITE_STANDARD preprocessor symbol to force the wrapper to use the stock sqlite3 library. Some functionality is missing, but its minimal. None of the precompiled binaries are compiled using this setting, but its useful for testing portability.
  • Added "boolean" and a couple other missing datatypes to the "DataTypes" schema xml file. Used by the VS designer when displaying tables and querying.
  • Added a new connection string option "Read Only". When set to True, the database will be opened in read-only mode.
  • Added a new connection string option "Max Pool Size" to set the maximum size of the connection pool for a given db file connection.
  • Added a new connection string option "Default IsolationLevel" to set the default isolation level of transactions. Possible values are Serializable and ReadCommitted.
  • Added a new connection string option "URI" as an optional parameter for compatibility with other ports of the provider.

1.0.54.0 - July 25, 2008

  • Fixed the setup project, which somehow "forgot" to include all the binaries in the 53 release.
  • Fixed a crash in the table designer when creating a new table and tabbing past the "Allow Nulls" cell in the grid while creating a new column.
  • Fixed a mostly-benign bug in SQLiteDataReader's GetEnumerator, which failed to pass along a flag to the underyling DbEnumerator it creates. This one's been around since day 1 and nobody's noticed it in all these years.
  • Added a new connection string parameter "Journal Mode" that allows you to set the SQLite journal mode to Delete, Persist or Off.

1.0.53.0 - July 24, 2008

  • Enabled sqlite_load_extension
  • Added retry/timeout code to SQLite3.Prepare() when preparing statements for execution and a SQLITE_BUSY error occurs.
  • Added a new schema to SQLiteConnection.GetSchema() called Triggers. Used to retrieve the trigger(s) associated with a database and/or table/view.
  • Extensive updates to table/view editing capabilities inside Visual Studio's Server Explorer. The program now parses and lets you edit CHECK constraints and triggers on a table, as well as define triggers on views. Experimental still, so e-mail me if you have issues.
  • Minor bugfix to the ViewColumns schema to return the proper base column name for a view that aliases a column.
  • Fixed the insert/update/delete DML support in the Linq module.
  • Changed the behavior of SQLiteCommand to allow a transaction to be set even if the command hasn't been associated with a connection yet.

1.0.52.0 - July 16, 2008

  • Code merge with SQLite 3.6.0
  • Added a lot of previously-missing exports to the DEF file for the native library.
  • Fixed SQLiteDataReader to check for an invalid connection before operating on an open cursor.
  • Implemented the Cancel() function of SQLiteCommand to cancel an active reader.
  • Added beta table and view designers to the Visual Studio Server Explorer. You can now edit/create tables and views, manage indexes and foreign keys from Visual Studio. This feature is still undergoing testing so use at your own risk!
  • Fixed the Server Explorer so VS2005 users can once again right-click tables and views and open the table data.
  • Added some new interop code to assist in returning more metadata not normally available through the SQLite API. Specifically, index column sort modes and collating sequences. Also added code to detect (but not parse) CHECK constraints, so the table designer can pop up a warning when editing a table with these constraints. Since I can't currently parse them.
  • Lots of LINQ SQL generation improvements and fixes.
  • Made some progress cleaning up and fixing up the schema definitions and manifests for EdmGen.
  • Added a built-in SQLiteFunction called last_rows_affected() which can be called from SQL to get the number of rows affected by the last update/insert operation on the connection. This is roughly equivalent to Sql Server's @@ROWCOUNT variable.

1.0.51.0 - July 1, 2008

  • VS2008 SP1 Beta1 LINQ Support
  • Added experimental Entity Framework support in a new library, System.Data.SQLite.Linq. Some things work, some don't. I haven't finished rigging everything up yet. The core library remains stable. All LINQ-specific code is completely separate from the core.
  • Added some columns to several existing schemas to support some of the EDM framework stuff.
  • Minor tweaks to the factory to better support dynamic loading of the Linq extension library for SQLite.
  • SQLite's busy handler was interfering with the provider's busy handling mechanism, so its been disabled.

1.0.50.0 - June 27, 2008

  • Fixed some lingering dispose issues and race conditions when some objects were finalized.
  • Fixed the SQLiteConvert.Split() routine to be a little smarter when splitting strings, which solves the quoted data source filename problem.
  • Enhanced the mergebin utility to work around the strong name validation bug on the Compact Framework. The old workaround kludged the DLL and caused WM6.1 to fail to load it. This new solution is permanent and no longer kludges the DLL.

1.0.49.0 - May 28, 2008

  • Code merge with SQLite 3.5.9
  • Fixed schema problems when querying the TEMP catalog.
  • Changed BLOB datatype schema to return IsLong = False instead of True. This was preventing DbCommandBuilder from using GUID's and BLOB's as primary keys.
  • Fix rollover issue with SQLite3.Reset() using TickCount.
  • Fixed SQLiteDataReader to dispose of its command (if called for) before closing the connection (when flagged to do so) instead of the other way around.
  • Fixed a DbNull error when retrieving items not backed by a table schema.
  • Fixed foreign key constraint parsing bug.
  • Added FailIfMissing property to the SQLiteConnectionStringBuilder.
  • Converted the source projects to Visual Studio 2008.

1.0.48.0 - December 28, 2007

  • Code merge with SQLite 3.5.4
  • Calling SQLiteDataReader.GetFieldType() on a column with no schema information and whos first row is initially NULL now returns type Object instead of type DbNull.
  • Added support for a new DateTime type, JulianDay. SQLite uses Julian dates internally.
  • Added a new connection string parameter "Default Timeout" and a corresponding method on the SQLiteConnection object to change the default command timeout. This is especially useful for changing the timeout on transactions, which use SQLiteCommand objects internally and have no ADO.NET-friendly way to adjust the command timeout on those commands.
  • FTS1 and FTS2 modules were removed from the codebase. Please upgrade all full-text indexes to use the FTS3 module.

1.0.47.2 - December 10, 2007

  • Fixed yet one more bug when closing a database with unfinalized command objects
  • Fixed the DataReader's GetFieldType function when dealing with untyped SQLite affinities

1.0.47.1 - December 5, 2007

  • Fixed a leftover bug from the codemerge with SQLite 3.5.3 that failed to close a database.
  • Fixed the broken Compact Framework distribution binary.
  • SQLite 3.5.x changed some internal infrastructure pieces in the encryption interface which I didn't catch initially. Fixed.

1.0.47.0 - December 4, 2007

  • Code merge with SQLite 3.5.3
  • Added installer support for Visual Studio 2008. Code is still using the VS2005 SDK so one or two bells and whistles are missing, but nothing significant.
  • This is the last version that the FTS1 and FTS2 extensions will appear. Everyone should rebuild their fulltext indexes using the new FTS3 module. FTS1 and FTS2 suffer from a design flaw that could cause database corruption with certain vacuum operations.
  • Fixed pooled connections so they rollback any outstanding transactions before going to the pool.
  • Fixed the unintended breaking of the TYPES keyword, and mis-typing of untyped or indeterminate column types.
  • Assert a FileIOPermission() requirement in the static SQLiteFunction constructor.
  • The CE-only SQLiteFunction.RegisterFunction() is now available on the desktop platform for dynamic registration of functions. You must still close and re-open a connection in order for the new function to be seen by a connection.
  • Fixed the "database is locked" errors by implementing behavioral changes in the interop.c file for SQLite. Closing a database force-finalizes any prepared statements on the database to ensure the connection is fully closed. This was rather tricky because the GC thread could still be finalizing statements itself.
  • Modifed the mergebin utility to help circumvent a long-standing strong name verification bug in the Compact Framework.

1.0.46.0 - September 30, 2007

  • Fixed faulty logic in type discovery code when using SQLiteDataReader.GetValue().
  • Fixed Connection.Open() bug when dealing with :memory: databases.
  • Fixed SQLiteCommand.ExecuteScalar() to return a properly-typed value.
  • Added support for SQLiteParameter.ResetDbType().
  • Added test cases for rigid and flexible type testing.

1.0.45.0 - September 25, 2007

  • Breaking change in GetSchema("Indexes") -- MetaDataCollections restrictions and identifier parts counts were wrong for this schema and I was using the wrong final parameter as the final restriction. Meaning, if you use the Indexes schema and are querying for a specific index the array should now be {catalog, null, table, index } instead of {catalog, null, table, null, index}
  • Fixed some errors in the encryption module, most notably when a non-default page size is specified in the connection string.
  • Fixed SQLiteDataReader to better handle type-less usage scenarios, which also fixes problems with null values and datetimes.
  • Fixed the leftover temp files problem on WinCE
  • Added connection pooling. The default is disabled for now, but may change in the future. Set "Pooling=True" in the connection string to enable it.
  • Sped up SQLiteConnection.Open() considerably.
  • Added some more robust cleanup code regarding SQLiteFunctions.
  • Minor additions to the code to allow for future LINQ integration into the main codebase.
  • Fixed a long-standing bug in the Open() command of SQLiteConnection which failed to honor the documented default behavior of the SQLite.NET provider to open the database in "Synchronous=Normal" mode. The default was "Full".
  • If Open() fails, it no longer sets the connection state to Broken. It instead reverts back to Closed, and cleans up after itself.
  • Added several new parameters to the ConnectionString for setting max page count, legacy file format, and another called FailIfMissing to raise an error rather than create the database file automatically if it does not already exist.
  • Fixed some designer toolbox references to the wrong version of the SQLite.Designer
  • Fixed a bug in the mergebin utility with regards to COR20 metadata rowsize computations.
  • Minor documentation corrections

1.0.44.0 - July 21, 2007

  • Code merge with SQLite 3.4.1
  • Fixed a bug in SQLiteConnection.Open() which threw the wrong kind of error in the wrong kind of way when a database file could not be opened or created.
  • Small enhancements to the TYPES keyword, and added documentation for it in the help file.
  • Hopefully fixed the occasional SQLITE_BUSY errors that cropped up when starting a transaction. Usually occurred in high-contention scenarios, and the underlying SQLite engine bypasses the busy handler in this scenario to return immediately.

1.0.43.0 - June 21, 2007

  • Code merge with SQLite 3.4.0
  • Fixed a reuse bug in the SQLiteDataAdapter in conjunction with the SQLiteCommandBuilder. It's been there unnoticed for more than a year, so it looks like most folks never encountered it.
  • Fixed an event handler bug in SQLiteCommandBuilder in which it could fail to unlatch from the DataAdapter when reused. Relates to the previous bugfix.
  • Fixed a double-dispose bug in SQLiteStatement that triggered a SQLiteException.

1.0.42.0 - June 1, 2007

  • Code merge with SQLite 3.3.17
  • Changed the SQLiteFunction static constructor so it only enumerates loaded modules that have referenced the SQLite assembly, which hopefully should cut down dramatically the time it takes for that function to execute.
  • Added the FTS2 full-text search extension to the project. Look for FTS1 to disappear within the next couple of revisions.
  • Fixed a bug introduced with the finalizers that triggered an error when statements ended with a semi-colon or had other non-parsable comments at the end of a statement
  • Fixed an intermittent multi-threaded race condition between the garbage collector thread and the main application thread which lead to an occasional SQLITE_MISUSE error.
  • Fixed another issue relating to SQLite's inherent typelessness when dealing with aggregate functions which could return Int64 or Double or even String for a given row depending on what was aggregated.
  • Remembered to recompile the DDEX portion of the engine this time, so Compact Framework users can once again use the design-time functionality

1.0.41.0 - April 23, 2007

  • Code merge with SQLite 3.3.16
  • Second go at implementing proper finalizers to cleanup after folks who've forgotten to Dispose() of the SQLite objects
  • Enhanced GetSchema(IndexColumns) to provide numeric scale and precision values
  • Fixed the column ordinals in GetSchema(IndexColumns) to report the ordinal of the column in the index, not the table
  • Fixed a bug whereby parameters named with an empty string (such as String.Empty) were treated like a named parameter instead of an unnamed parameter

1.0.40.0 - January 31, 2007

  • Code merge with SQLite 3.3.12
  • Lots of new code to handle misuse of the library. Implemented finalizers where it made sense, fixed numerous garbage collector issues when objects are not disposed properly, fixed some object lifetime issues, etc.
  • A failed Commit() on a transaction no longer leaves the transaction in an unusable state.

1.0.39.1 - January 11, 2007

  • Fixed a really dumb mistake that for some reason didn't trigger any errors in the testcases, whereby commands when associated with a connection were not adding or removing themselves from an internal list of commands for that connection -- causing a "database is locked" error when trying to close the connection.

1.0.39.0 - January 10, 2007

  • Code merge with SQLite 3.3.10
  • Fixed a multi-threaded race condition bug in the garbage collector when commands and/or connections are not properly disposed by the user.
  • Switched the encryption's internal deallocation code to use sqlite's built-in aux functions instead of modifying the pager.c source to free the crypt block. This eliminates the last of the code changes the provider makes to the original sqlite engine sources. Props to Ralf Junker for pointing that out.

1.0.38.0 - November 22, 2006

  • Fixed a bug when using CommandBehavior.KeyInfo whereby integer primary key columns may be duplicated in the results.
  • Enhanced the CommandBuilder so that update/delete statements are optimized when the affected table contains unique constraints and a primary key is present.
  • Fixed a bug in the DataReader when used in conjunction with CommandBehavior.CloseConnection.

1.0.37.0 - November 19, 2006

  • Added support for CommandBehavior.KeyInfo. When specified in a query, additional column(s) will be returned describing the key(s) defined for the table(s) selected in the query. This is optimized when INTEGER PRIMARY KEY is set for the given tables, but does additional work for other kinds of primary keys.
  • Removed the default values from SQLiteDataReader.GetTableSchema(), to better follow Sql Server's pattern and suppress schema errors when loading the records into a dataset/datatable.
  • Allow integers to implicitly convert to double/decimal/single.

1.0.36.1 - October 25, 2006

  • Added support for LONGVARCHAR, SMALLDATE and SMALLDATETIME. These were actually added in 1.0.36.0 but were undocumented.
  • Fixed the embedded helpfile which was accidentally built from old sources.
  • Fixed an unfortunate re-entry of a bug in the .36 codebase that caused the provider to "forget" about commands on a connection under certain circumstances.

1.0.36.0 - October 23, 2006

  • Code merge with SQLite 3.3.8, including support for full-text search via the FTS1 extension.
  • Fixed a bug retrieving data types when UseUtf16Encoding is true. Side-effect of further merging the common code between the two base classes.
  • Fixed a bug with System.Transactions whereby a connection closed/disposed within a transaction scope is rolled back and cannot be committed.
  • Added more error checking and reporting to transactions to help user's isolate the source of transaction failures.
  • Implemented a workaround for a Compact Framework issue regarding strong-named assemblies containing a PE section with a raw size less than the virtual size.

1.0.35.1 - September 12, 2006

  • Fixed the TYPES keyword to work when UseUTF16Encoding is true.
  • Fix another bug revealed in 1.0.35.0 regarding infinite loops when the 2nd or subsequent statements of a semi-colon separated command cannot be parsed.
  • Updated the help documentation.

1.0.35.0 - September 10, 2006

  • Fixed an infinite loop bug in SQLiteCommand caused when multiple semi-colon separated statements in a single command are executed via datareader and one of the statements contains a syntax error preventing it from being prepared.
  • Added the TYPES preparser keyword to be placed before a SELECT statement to aid the wrapper in converting expressions in a subsequent select clause into more robust types. Documentation yet to be integrated, but available on the forums.
  • Added a new connectionstring parameter "BinaryGUID=true/false" (default is "true"). When true, guid types are stored in the database as binary blobs to save space. Binary has been the default format since 1.0.32.0 but this parameter eases backward compatibility.

1.0.34.0 - September 4, 2006

  • Fixed a bug in SQLiteParameterCollection.RemoveAt(namedparam)
  • Fixed a bug in SQLiteDataReader introduced in 1.0.30 that broke DateTimes using the Ticks option in the connection string.
  • Fixed a bug in the recent changes to guid behavior wherein using a datareader's indexer to fetch a guid from a column containing both binary and text guids would sometimes return a byte array instead of a guid.
  • Enacted a workaround involving typed datasets in Compact Framework projects in which it took an excessive amount of time to open a form and generated a lot of temporary files in the user's Local Settings\Application Data\Microsoft\VisualStudio\8.0\Assembly References folder.

1.0.33.0 - August 21, 2006

  • Code merge with SQLite 3.3.7
  • Fixed a bug in SQLiteConnection that caused it to "forget" about commands bound to it and occasionally throw an error when a database is closed and opened repeatedly.

1.0.32.0 - August 6, 2006

  • Added AllowPartiallyTrustedCallers attribute to the assembly
  • Added the missing "nchar" type
  • Added support for binary Guid's. Guids are now stored as binary by default when using parameterized queries. Text guids are still fully supported.
  • Fixed a TransactionScope() error that caused the transaction not to be completed.
  • Enhanced parameter names so that if they are added to the Parameters collection without their prefix character (@ : or $) they are still properly mapped.

1.0.31.0 - July 16, 2006

  • Re-applied the view parsing bugfix in 1.0.29.0 that was accidentally reverted out of the 30 build.
  • Fixed SQLiteCommand.ExecuteScalar() to return null instead of DbNull.Value when no rows were returned.
  • Design-time installer now installs the package-based designer on full Visual Studio versions. Express editions continue to use the packageless designer.
  • In Visual Studio (not Express), you can now right-click a SQLite connection in the Server Explorer and vacuum the database and change the encryption password.

1.0.30.1 - July 2, 2006

  • Code merge with SQLite 3.3.6
  • Added support for the |DataDirectory| keyword in the Data Source filename string.
  • Added hook notification support to SQLiteConnection. Specifically, there are three new events on the SQLiteConnection object which are raised when an update/insert/delete occurs and when transactions are committed and rolled back.
  • Changed SQLiteTransaction to default to BEGIN IMMEDIATE instead of just BEGIN, which solves a multithreaded race condition.
  • Changed SQLiteDataReader to better support SQLite's typelessness. The data reader no longer caches column affinity, but re-evaluates it for each column/row.
  • Fixed a bug in Prepare() which caused an intermittant fault due to the code accessing the memory of an unpinned variable.
  • Fixed a multithreaded lock-retry bug in in SQLiteConnection.Open() and in SQLiteTransaction, which failed to use a command timeout before giving up.

1.0.29.0 - May 16, 2006

  • Fixed a bug in the Views schema information which caused multi-line view definition statements not to be parsed
  • Fixed a parsing bug in SQLiteDataReader.GetSchemaTable() to account for numeric(x,y) datatypes with specified precision and scale
  • Fixed a bug in SQLiteConnection.Open() which tried to automatically enlist in an ambient transaction but had not yet set the state of the database to Opened, thereby causing a transaction fault
  • Changed SQLiteException to inherit from DbException on the full framework

1.0.28.0 - April 14, 2006

  • Code merge with SQLite 3.3.5
  • You can now specify a relative path in the Compact Framework's "Data Source" by prefixing the file with ".\". i.e. "Data Source=.\\mydb.db3"
  • Several more changes and enhancements to schemas for better compatibility.
  • Fixed several bugs with the 64-bit builds of the provider. The x64 binary is now optimized.
  • Design-time installer now tries to install the 64-bit builds into the GAC along with the 32-bit build.
  • Fixed a bug in the SQLiteDataReader.GetSchemaTable() function when used with tables containing apostrophes.
  • Fixed an XSD-related bug whereby the XSD utility was unable to locate the provider and could not generate typed datasets.
  • Added NTEXT and STRING datatypes to the list of recognized keywords (used for schema retrieval).
  • Due to the XSD bug and other potential problems related to external build utilities, changes to the installation of the designer have had to be made. The installer used to write the DbProviderFactories XML into the devenv.exe.config file and its express cousins, but now has to write instead to the machine.config.
  • Installer writes to both the 32-bit machine.config and the 64-bit machine.config if it exists.

1.0.27.1 - February 28, 2006

  • Fixed a bug when doing data binding in Compact Framework projects that prevented you from assigning a typed dataset to a bindingsource. It turns out, the CF version of the SQLite provider needs to be flagged as retargetable so it'll work in the design-time desktop environment. No changes were made to the desktop build, but the revision was bumped on all libraries anyway in order to keep them sync'd.

1.0.27.0 - February 27, 2006

  • Many optimizations and a few more minor adjustments to schemas and schema retrieval performance.
  • Lots of design-time attributes added to the code. The DbDataAdapter, DbCommand, and DbConnection objects now have greatly enhanced design-time capabilities when added to the toolbox and dropped on a form.
  • Lots of Server Explorer enhancements.
  • Binaries are now distributed in a setup program for easier administration and configuration of the provider.

1.0.26.2 - February 15, 2006

  • Yet another bugfix to index schemas, which was incorrectly marking most indexes as primary key indexes.
  • Fixed GetSchema() to accept a null string array.
  • Fixed a misspelled export in the core C library that prevented databases opened with UTF16Encoding from getting schema information and would likely cause an error if attempted.

1.0.26.1 - February 14, 2006

  • Fixed even more minor schema bugs having to do with indexes.
  • Added two missing pieces in the SQLite designer which were preventing it from being used from within VS Express editions.
  • Several bugfixes to the design-time installer program, including supporting 64-bit environments.

1.0.26.0 - February 11, 2006

  • Code merge with SQLite 3.3.4
  • Fixed an encryption bug when changing the password of databases over 1gb in size.
  • Fixed various designer issues related to construction of named parameters.
  • Retooled the GetSchema() method of SQLiteDataReader to use the new 3.3.4 API functions, and made several enhancements and fixes to schemas.
  • Implemented the SourceColumnNullMapping property of SQLiteParameter to fix a DbCommandBuilder code generation bug.
  • Removed the runtime dependency on MSVCR80.DLL. File size is somewhat larger for the varying desktop versions, but the Compact Framework version remains the same.
  • Created an install program to manage installation and uninstallation of the SQLite design-time support.
  • Designer support now works for all Visual Studio editions, including all Express Editions.
  • Design-time installer will now remove (if present) the machine.config SQLite entries in favor of installing the xml code into the devenv.exe.config file (or any of the variations for express editions). The officially-accepted behavior of using DbProviderFactories is to add the code to your app.config file, and the machine.config file should not be touched.

1.0.25.0 - January 31, 2006

  • Code merge with SQLite 3.3.3
  • Added automatic distributed transaction enlistment and implemented the DbConnection.EnlistTransaction method for manual enlistment.
  • Nested transactions are now supported.
  • Rearranged the timing of SetPassword(), which now must be called before the database is opened instead of afterwards. Optionally, the password can be supplied in the ConnectionString.
  • Fixed a bug in SQLiteFunction that caused a failure when an empty resultset was returned and a custom user aggregate function was used in the query.
  • The designer has had another round of cleanup applied, in preparation for moving to a VS package.
  • Added SQLiteMetaDataCollectionNames class.

1.0.24.6 beta - January 23, 2006

  • This beta is built from sqlite.org's 3.3.2 beta.
  • Eliminated the static linking of mscoree from all binaries. Native projects can now use the library without any dependencies on the .NET Framework, while managed projects continue to be able to use the library normally.

1.0.24.5 beta - January 20, 2006

  • This beta is built from sqlite.org's 3.3.1 alpha and contains development-in-progress code. Therefore no guarantees can be made regarding its suitability for production use.
  • You no longer need to distribute 2 files on the CompactFramework. You can delete SQLite.Interop.DLL entirely. I wrote a custom tool called "mergebin" (available in the source zip file) which combines the two libraries and gets around a glaring defect in the VS2005 linker for ARM processors which doesn't allow you to link netmodules.
  • x64 and ia64 builds now use the same strong name as the x86 build. This means breaking backward compatibility, but it was necessary in order to allow you to drop any of those 3 builds onto a PC and have your .NET program run properly. Prior to this, you'd get an error if you built your program using the x86 build, and then installed the x64 version on a target machine and tried to run your program against it.
  • The entire source project has been gone over top to bottom. A debug build no longer combines the binaries into a single module, which was preventing proper debugging.

1.0.24.4 beta - January 16, 2006

  • This beta is built from sqlite.org's 3.3.1 alpha and contains development-in-progress code. Therefore no guarantees can be made regarding its suitability for production use.
  • Fixed a bug in the UTF-16 handling code for preparing statements due to a behavioral change in SQLite 3.3.0.
  • Added pager.c code necessary to cleanup after an encrypted file is closed.
  • Fixed an encryption bug that caused a fault when an encrypted file was rolled back.
  • Modified the testcase code to take advantage of optimizations regarding the use of a DbCommandBuilder. DataAdapter insert speed increased dramatically as a result.

1.0.24.3 beta - January 10, 2006

  • This beta is built from sqlite.org's CVS HEAD (as it appeared at of the date of this beta) and contains development-in-progress code. Therefore no guarantees can be made regarding its suitability for production use.
  • Added support for database encryption at the pager level. Databases are encrypted using a 128-bit RC4 stream algorithm. To open an existing encrypted database, you may now specify a "Password={password}" text in the ConnectionString, or you may call the SQLiteConnection.SetPassword() function to set the password on an open connection. To encrypt existing non-encrypted databases or to change the password on an encrypted database, you must use the SQLiteConnection.ChangePassword() function. If you use SetPassword() instead of specifying a password in the connection string, or call ChangePassword() you may use a binary byte array or a text string as the password.
  • Rewrote the locking implementation for the Compact Framework. It is now more robust and incorporates into the SQLite codebase more efficiently than the previous CE adaptation.
  • Moved some of the embedded schema XML data into a resource file to ease code readability.
  • Automated the fixup of the original sqlite codebase's source prior to compiling, to ease merging with sqlite.org's source.

1.0.24.2 - December 30, 2005

  • Fixed the SQLiteDataReader.HasRows property to return the proper value.
  • Implemented the inadvertently neglected RecordsAffected property on SQLiteDataReader.
  • SQLiteFunction static constructor was changed to pre-filter classes with only the SQLiteFunctionAttribute. The code was throwing an exception when certain assemblies were referenced in a project.
  • Fixed the SQLiteDataAdapter OnRowUpdated event, which was using the wrong variable to find the attached event handler and subsequently not raising the event.
  • Small optimizations and fixes to SQLiteDataReader.NextResult().

1.0.24.1 - December 19, 2005

  • Update core SQLite engine to 3.2.8

1.0.24 - December 9, 2005

  • Fixed the Catalogs schema bug that caused attached databases not to be re-attached to a cloned connection
  • Enhanced transactions to allow for a deferred or immediate writelock. SQLiteConnection.BeginTransaction() now has an additional overload to support it
  • Commands are now prepared as they are executed instead of beforehand. This fixes a bug whereby a multi-statement command that alters the database and subsequently references the altered data would fail during Prepare().
  • Tightened up the SQLiteDataReader to prevent reading columns before calling the first Read() and to prevent reading columns after the last Read().
  • A more descriptive error is thrown if there aren't enough parameters in the command to satisfy the parameters required by the statement(s).

1.0.23 - November 21, 2005

  • Named parameters may now begin with @ to ease portability of the provider. SQLite's named parameters are ordinarily prefixed with a : or $. The designer will still use the $ prefix however, since its more compatible with the default SQLite engine.
  • Added several alternate ISO8601 date/time formats to SQLiteConvert.cs to increase compatibility.
  • Relaxed coersion restrictions to work better with SQLite's inherent typelessenss.

1.0.22 - November 11, 2005

  • Fixed some globalization issues which resulted in incorrect case-insensitive comparisons
  • Fixed a bug in the routine that finds all user-defined functions in a loaded assembly. It would throw an exception if any of the types in the assembly could not be loaded. The exception is now caught and handled appropriately.

1.0.21 - November 4, 2005

  • Fixed a designer bug when creating typed datasets with parameterized queries.
  • The above fix then exposed another bug in the datareader's ability to query schema information on parameterized commands, which was also fixed.
  • Compiled against the RTM version of VS2005.
  • Rewrote the design-time install script to use the XML DOM objects when writing to the machine.config and to automatically register the DLL in the GAC.
  • Made changes to the app.config descriptions and help file to improve version-independent factory support.

1.0.20 - October 19, 2005

  • Fixed a shortcut in SQLiteBase.GetValue which was insufficient for international environments. The shortcut was removed and the "proper" procedure put in.

1.0.19 - October 5, 2005

  • Code merge with SQLite 3.2.7
  • Fixed bugs in the CE port code (os_wince.c) which were brought to light by recent changes in the SQLite engine.
  • Recompiled and modified to be compatible with the September VS2005 Release Candidate.
    Beta 2 users should continue to use 1.0.18.1

1.0.18.1 - September 19, 2005

  • Code merge with SQLite 3.2.6

1.0.18 - September 1, 2005

  • Added type-specific method calls when using the various SQLite classes that would've normally returned a a generic Db base class, which aligns the code better with the Microsoft-supplied data providers.

1.0.17 - August 26, 2005

  • Code merge with SQLite 3.2.5
  • Added Itanium and x64 build settings to the project (needs testing)
  • Bugfixes and enhancements to several schema types
  • Additional design-time support to include index and foreign key enumerations. Requires re-registering the designer using INSTALL.CMD. The new designer code now allows the VS query designer and typed datasets to automatically link up foreign keys, use indexes, and automatically generate relationships from the schema.
  • Additional static methods on SQLiteConnection to create a database file, encrypt a file using the Encrypted File System (EFS) on NTFS (requires NT 2K or above) and NTFS file compression

1.0.16 - August 24, 2005

  • Code merge with SQLite 3.2.4 with the large delete bugfix in CVS (which will become 3.2.5 soon)
  • Added new GetSchema() types: IndexColumns, ViewColumns, ForeignKeys

1.0.15 - August 22, 2005

  • Code merge with SQLite 3.2.3
  • Minor updates for better design-time experience. More design-time code to follow in subsequent releases.

1.0.14 - August 16, 2005

  • Fixed a bug in the SQLiteDataAdapter due to insufficient implementation of the class. The RowUpdating and RowUpdated events are now properly implemented, but unfortunately inserting and updating data in a DataTable or DataSet is now much slower. This is the proper design however, so the changes are here to stay.
  • Lots of schema changes to support Visual Studio's Data Designer architecture.
  • Added Designer support for the provider. It's not 100%, but you can design queries, add typed datasets and perform quite a number of tasks all within Visual Studio now.

1.0.13 - August 8, 2005

  • Fixed a named parameter bug in the base SQLite_UTF16 class, which of course only showed up when a database connection was opened using the UseUTF16Encoding=True parameter.
  • Fixed a performance issue in SQLite_UTF16 involving string marshaling.

1.0.12 - August 5, 2005

  • Full support for the Compact Framework. Each build (Debug/Release) now has a platform, either Win32 or Compact Framework. The correct projects are built accordingly. See the Distributing SQLite section for information on what files need to be distributed for each platform.
  • Modified SQLite3.Reset() and Step() functions to transparently handle timeouts while waiting on the database to become available (typically when a writer is waiting on a reader to finish, or a reader is waiting on a writer to finish).
  • Lots of code cleanup as suggested by the Code Analyzer (FxCop).
  • Lots of updates to the helpfile (as you can see).
  • Statements were already prepared lazily in a SQLiteCommand, but now its even more lazy. Statements are now only prepared if the statements haven't been previously prepared and a Prepare() function is called (and the command is associated with a connection) or just prior to the command being executed.

1.0.11 - August 1, 2005

  • For everything except the Compact Framework, System.Data.SQLite.DLL is now the only DLL required to use this provider! The assembly is now a multi-module assembly, containing both the native SQLite3 codebase and the C# classes built on top of it. The Compact Framework version (when completed) will not be able to support this feature, so backwards compatibility with the Compact Framework has been preserved for the future.
  • Fixed a bug in SQLiteCommand.ExecuteScalar() that caused it to stop executing commands once it obtained the first column of the first row-returning resultset. Any remaining statements after the row-returning statement was ignored.

1.0.10 - June 10, 2005

  • Fixed a bug in the SQLite3.cs Prepare() function that created a statement even when the SQLite engine returned a NULL pointer. Typically this occurs when multiple statements are processed and there are trailing comments at the end of the statement.
  • Fixed a bug in SQLiteStatement.cs that retrieved parameter names for a parameterized query. SQLite's parameters are 1-based, and the function was starting at 0. This was fine when all parameters were unnamed, but for named parameters it caused the parameters to be out of whack.

1.0.09a - May 25, 2005

  • Fixed a broken helpfile and corrected some obsolete help remarks in SQLiteFunction.cs
  • Added a version resource to the SQLite.Interop.DLL.

1.0.09 - May 24, 2005

  • Code merge with the latest 3.21 version of SQLite.
  • Removed obsolete methods and properties for Whidbey Beta 2

1.0.08 Refresh - Mar 24, 2005

  • Code merge with the latest 3.20 version of SQLite.
  • Recompiled the help file to fix a build error in it.

1.0.08 - Mar 11, 2005

  • Added additional #if statements to support the old beta 1 edition of VS2005.
  • Code merged the SQLite 3.14 source.

1.0.07 - Mar 5, 2005

  • Made more optimizations to frequently-called functions, resulting in significant performance gains in all tests.
  • Recompiled the binaries using the latest VS2005 February CTP, resulting in yet more significant speed gains. The 100k insert test used to take 3.5 seconds and the insertwithidentity took almost 8 seconds. With the above two changes, those tests are now executing in 1.9 and 4.9 seconds respectively.

1.0.06 - Mar 1, 2005

  • Speed-ups to SQLiteDataReader. It was interop'ing unnecessarily every time it tried to fetch a field due to a logic error.
  • Changed/Added some code to SQLiteConvert's internal DbType, Type and TypeAffinity functions.
  • Fixed the SQLiteDataReader to obey the flags set in the optional CommandBehavior flag from SQLiteCommand.ExecuteReader().
  • Changed the default page size to 1024 to reflect the defaults of SQLite. Ignores the "Page Size" connection string option for memory databases, as tests revealed that changing it resulted in memory corruption errors.
  • Performance enhancements to the SQLiteCommand and SQLiteStatement classes which reduced the 100,000 row insert execution time as well as the various Function execution times significantly.

1.0.05 - Feb 25, 2005

  • Fixed the SQLite3 C# class step/reset functions to accomodate schema changes that invalidate a prepared statement. Statements are recompiled transparently.
  • Moved all native DLL declarations to an UnsafeNativeMethods class.
  • Split several classes into their own modules for readability.
  • Renamed many internal variables, reviewed access to variables marked as internal and altered their protection levels accordingly.
  • Due to the presence of the altered sqlite3 codebase and so many added interop functions, I decided to rename the sqlite3 C project and the DLL to SQLite.Interop.DLL. This is the same core sqlite3 codebase but designed specifically for this ADO.NET provider. This eliminates any possibility of someone dropping another build of sqlite3.dll into the system and rendering the provider inoperable. In the future if the folks at sqlite.org finally introduce a method of retrieving column usage for an arbitrary prepared statement, I'll retool this library to be a lightweight function call wrapper around the core binary distribution.
  • Added [SuppressUnmanagedCodeSecurity] attribute to the UnsafeNativeMethods class which brings VS2005 November CTP execution speeds inline with the December CTP.
  • Added a bin directory to the project root where pre-compiled binaries can be found.
  • Added a doc directory where preliminary documentation on the class library can be found.
  • Documented a lot more of the classes internally.

1.0.04 - Feb 24, 2005

  • Removed the SQLiteContext class and revamped the way UserFunctions work to simplify the imlementation.
  • Fixed a counting bug in the TestCases class, specifically in the function tests where I wasn't resetting the counter and it was consequently reporting intrinsic and raw select calls as being much much faster than they actually were. The numbers are now much closer to what I expected for performance, with .NET user-functions still being the slowest, but only by a small margin.
  • Small performance tweaks to SQLiteDataReader.
  • Added PageSize to the SQLiteConnectionStringBuilder and subsequently to the SQLiteConnection
  • Added a PRAGMA encoding=XXX execution statement to the SQLiteConnection after opening a connection.

1.0.03 - Feb 23, 2005

  • Fixed up SQLiteCommandBuilder to correct implementation errors, which resulted in an enormous performance boost in the InsertMany test. 10,000 row insert that executed in 1500ms now executes in 500ms.
  • Fixed several errors in the SQLite3_UTF16 class. ToString() was working incorrectly and the Open() method failed to register user defined functions and collations.
  • Fixed a bug in SQLiteCommand.ClearCommands() whereby only the first statement was being properly cleaned up.
  • Fixed a bug in SQLiteDataReader whereby calling NextResult() would not properly reset the previously-executed command in the sequence.
  • Added an InsertManyWithIdentityFetch test, which appends a select clause to populate the ID of the last inserted row into the InsertCommand, demonstrating ADO.NET's ability to auto-fetch identity columns on insert.

1.0.02 - Feb 21, 2005

  • Tweaks to the xxx_interop functions that return char *'s, so they also return the length. Saves an interop call to get the UTF-8 string length during conversion to a .NET string.
  • Reworked the whole interop.c thing into interop.h and reduced the code required to merge the main sqlite3 codebase.
  • Added support for user-defined collations.


Query Language Understood by SQLite

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

SQL As Understood By SQLite

SQLite understands most of the standard SQL language. But it does omit some features while at the same time adding a few features of its own. This document attempts to describe precisely what parts of the SQL language SQLite does and does not support. A list of SQL keywords is also provided. The SQL language syntax is described by syntax diagrams.

The following syntax documentation topics are available:

    • aggregate functions
    • ALTER TABLE
    • ANALYZE
    • ATTACH DATABASE
    • BEGIN TRANSACTION
    • comment
    • COMMIT TRANSACTION
    • core functions
    • CREATE INDEX
    • CREATE TABLE
    • CREATE TRIGGER
    • CREATE VIEW
    • CREATE VIRTUAL TABLE
    • date and time functions
    • DELETE
    • DETACH DATABASE
    • DROP INDEX
    • DROP TABLE
    • DROP TRIGGER
    • DROP VIEW
    • END TRANSACTION
    • EXPLAIN
    • expression
    • INDEXED BY
    • INSERT
    • keywords
    • ON CONFLICT clause
    • PRAGMA
    • REINDEX
    • RELEASE SAVEPOINT
    • REPLACE
    • RETURNING clause
    • ROLLBACK TRANSACTION
    • SAVEPOINT
    • SELECT
    • UPDATE
    • UPSERT
    • VACUUM
    • WITH clause

The routines sqlite3_prepare_v2(), sqlite3_prepare(),
sqlite3_prepare16(), sqlite3_prepare16_v2(),
sqlite3_exec(), and sqlite3_get_table() accept
an SQL statement list (sql-stmt-list) which is a semicolon-separated
list of statements.

sql-stmt-list:

sql-stmt ;

Each SQL statement in the statement list is an instance of the following:

sql-stmt:

EXPLAIN QUERY PLAN alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt


JSON Functions And Operators

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
JSON Functions And Operators
► Table Of Contents
1. Overview
2. Compiling in JSON Support
3. Interface Overview
3.1. JSON arguments
3.2. PATH arguments
3.3. VALUE arguments
3.4. Compatibility
3.5. JSON5 Extensions
4. Function Details
4.1. The json() function
4.2. The json_array() function
4.3. The json_array_length() function
4.4. The json_error_position() function
4.5. The json_extract() function
4.6. The -> and ->> operators
4.7. The json_insert(), json_replace, and json_set() functions
4.8. The json_object() function
4.9. The json_patch() function
4.10. The json_remove() function
4.11. The json_type() function
4.12. The json_valid() function
4.13. The json_quote() function
4.14. The json_group_array() and json_group_object() aggregate SQL functions
4.15. The json_each() and json_tree() table-valued functions
4.15.1. Examples using json_each() and json_tree()

1. Overview

By default, SQLite supports sixteen functions and two operators for dealing with JSON values. There are also two table-valued functions that can be used to decompose a JSON string.

There are 15 scalar functions and operators:

  1. json(json)
  2. json_array(value1,value2,...)
  3. json_array_length(json)
    json_array_length(json,path)
  4. json_error_position(json)
  5. json_extract(json,path,...)
  6. json -> path
  7. json ->> path
  8. json_insert(json,path,value,...)
  9. json_object(label1,value1,...)
  10. json_patch(json1,json2)
  11. json_remove(json,path,...)
  12. json_replace(json,path,value,...)
  13. json_set(json,path,value,...)
  14. json_type(json)
    json_type(json,path)
  15. json_valid(json)
  16. json_quote(value)

There are two aggregate SQL functions:

  17. json_group_array(value)
  18. json_group_object(name,value)

The two table-valued functions are:

  19. json_each(json)
    json_each(json,path)
  20. json_tree(json)
    json_tree(json,path)

2. Compiling in JSON Support

The JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22). They can be omitted by adding the -DSQLITE_OMIT_JSON compile-time option. Prior to version 3.38.0, the JSON functions were an extension that would only be included in builds if the -DSQLITE_ENABLE_JSON1 compile-time option was included. In other words, the JSON functions went from being opt-in with SQLite version 3.37.2 and earlier to opt-out with SQLite version 3.38.0 and later.

3. Interface Overview

SQLite stores JSON as ordinary text. Backwards compatibility constraints mean that SQLite is only able to store values that are NULL, integers, floating-point numbers, text, and BLOBs. It is not possible to add a sixth "JSON" type.

SQLite does not (currently) support a binary encoding of JSON. Experiments have been unable to find a binary encoding that is smaller or faster than a plain text encoding. (The present implementation parses JSON text at over 1 GB/s.) All JSON functions currently throw an error if any of their arguments are BLOBs because BLOBs are reserved for a future enhancement in which BLOBs will store the binary encoding for JSON.

3.1. JSON arguments

For functions that accept JSON as their first argument, that argument can be a JSON object, array, number, string, or null. SQLite numeric values and NULL values are interpreted as JSON numbers and nulls, respectively. SQLite text values can be understood as JSON objects, arrays, or strings. If an SQLite text value that is not a well-formed JSON object, array, or string is passed into JSON function, that function will usually throw an error. (Exceptions to this rule are json_valid(), json_quote(), and json_error_position().)

These routines understand all rfc-7159 JSON syntax and also JSON5 extensions. JSON text generated by these routines always strictly conforms to the canonical JSON definition and does not contain any JSON5 or other extensions. The ability to read and understand JSON5 was added in version 3.42.0 (2023-05-16). Prior versions of SQLite would only read canonical JSON.

3.2. PATH arguments

For functions that accept PATH arguments, that PATH must be well-formed or else the function will throw an error. A well-formed PATH is a text value that begins with exactly one '$' character followed by zero or more instances of ".objectlabel" or "[arrayindex]".

The arrayindex is usually a non-negative integer N. In that case, the array element selected is the N-th element of the array, starting with zero on the left. The arrayindex can also be of the form "#-N" in which case the element selected is the N-th from the right. The last element of the array is "#-1". Think of the "#" characters as the "number of elements in the array". Then the expression "#-1" evaluates to the integer that corresponds to the last entry in the array. It is sometimes useful for the array index to be just the # character, for example when appending a value to an existing JSON array:

  • json_set('[0,1,2]','$[#]','new') → '[0,1,2,"new"]'

3.3. VALUE arguments

For functions that accept "value" arguments (also shown as "value1" and "value2"), those arguments are usually understood to be literal strings that are quoted and become JSON string values in the result. Even if the input value strings look like well-formed JSON, they are still interpreted as literal strings in the result.

However, if a value argument comes directly from the result of another JSON function or from the -> operator (but not the ->> operator), then the argument is understood to be actual JSON and the complete JSON is inserted rather than a quoted string.

For example, in the following call to json_object(), the value argument looks like a well-formed JSON array. However, because it is just ordinary SQL text, it is interpreted as a literal string and added to the result as a quoted string:

  • json_object('ex','[52,3.14159]') → '{"ex":"[52,3.14159]"}'
  • json_object('ex',('52,3.14159]'->>'$')) → '{"ex":"[52,3.14159]"}'

But if the value argument in the outer json_object() call is the result of another JSON function like json() or json_array(), then the value is understood to be actual JSON and is inserted as such:

  • json_object('ex',json('[52,3.14159]')) → '{"ex":[52,3.14159]}'
  • json_object('ex',json_array(52,3.14159)) → '{"ex":[52,3.14159]}'
  • json_object('ex','[52,3.14159]'->'$') → '{"ex":[52,3.14159]}'

To be clear: "json" arguments are always interpreted as JSON regardless of where the value for that argument comes from. But "value" arguments are only interpreted as JSON if those arguments come directly from another JSON function or the -> operator.

Within JSON value arguments interpreted as JSON strings, Unicode escape sequences are not treated as equivalent to the characters or escaped control characters represented by the expressed Unicode code point. Such escape sequences are not translated or specially treated; they are treated as plain text by SQLite's JSON functions.

3.4. Compatibility

The current implementation of this JSON library uses a recursive descent parser. In order to avoid using excess stack space, any JSON input that has more than 1000 levels of nesting is considered invalid. Limits on nesting depth are allowed for compatible implementations of JSON by RFC-7159 section 9.

3.5. JSON5 Extensions

Beginning in version 3.42.0 (2023-05-16), these routines will read and interpret input JSON text that includes JSON5 extensions. However, JSON text generated by these routines will always be strictly conforming to the canonical definition of JSON.

Here is a synopsis of JSON5 extensions (adapted from the JSON5 specification):

  • Object keys may be unquoted identifiers.
  • Objects may have a single trailing comma.
  • Arrays may have a single trailing comma.
  • Strings may be single quoted.
  • Strings may span multiple lines by escaping new line characters.
  • Strings may include new character escapes.
  • Numbers may be hexadecimal.
  • Numbers may have a leading or trailing decimal point.
  • Numbers may be "Infinity", "-Infinity", and "NaN".
  • Numbers may begin with an explicit plus sign.
  • Single (//...) and multi-line (/*...*/) comments are allowed.
  • Additional white space characters are allowed.

To convert string X from JSON5 into canonical JSON, invoke "json(X)". The output of the "json()" function will be canonical JSON regardless of any JSON5 extensions that are present in the input. For backwards compatibility, the json_valid(X) function continues to report false for inputs that are not canonical JSON, even if the input is JSON5 that the function is able to understand. To determine whether or not an input string is valid JSON5, use the expression: "json_error_position(X)==0".

These routines understand all of JSON5, plus a little more. SQLite extends the JSON5 syntax in these two ways:

  1. Strict JSON5 requires that unquoted object keys must be ECMAScript 5.1 IdentifierNames. But large unicode tables and lots of code is required in order to determine whether or not a key is an ECMAScript 5.1 IdentifierName. For this reason, SQLite allows object keys to include any unicode characters greater than U+007f that are not whitespace characters. This relaxed definition of "identifier" greatly simplifies the implementation and allows the JSON parser to be smaller and run faster.

  2. JSON5 allows floating-point infinities to be expressed as "Infinity", "-Infinity", or "+Infinity" in exactly that case - the initial "I" is capitalized and all other characters are lower case. SQLite also allows the abbreviation "Inf" to be used in place of "Infinity" and it allows both keywords to appear in any combination of upper and lower case letters. Similarly, JSON5 allows "NaN" for not-a-number. SQLite extends this to also allow "QNaN" and "SNaN" in any combination of upper and lower case letters. Note that SQLite interprets NaN, QNaN, and SNaN as just an alternative spellings for "null". This extension has been added because (we are told) there exists a lot of JSON in the wild that includes these non-standard representations for infinity and not-a-number.

4. Function Details

The following sections provide additional detail on the operation of the various JSON functions and operators:

4.1. The json() function

The json(X) function verifies that its argument X is a valid JSON string and returns a minified version of that JSON string (with all unnecessary whitespace removed). If X is not a well-formed JSON string, then this routine throws an error.

In other words, this function converts raw text that looks like JSON into actual JSON so that it may be passed into the value argument of some other json function and will be interpreted as JSON rather than a string. This function is not appropriate for testing whether or not a particular string is well-formed JSON - use the json_valid() and/or json_error_position() routines below for that task.

If the argument X to json(X) contains JSON objects with duplicate labels, then it is undefined whether or not the duplicates are preserved. The current implementation preserves duplicates. However, future enhancements to this routine may choose to silently remove duplicates.

Example:

  • json(' { "this" : "is", "a": [ "test" ] } ') → '{"this":"is","a":["test"]}'

4.2. The json_array() function

The json_array() SQL function accepts zero or more arguments and returns a well-formed JSON array that is composed from those arguments. If any argument to json_array() is a BLOB then an error is thrown.

An argument with SQL type TEXT is normally converted into a quoted JSON string. However, if the argument is the output from another json1 function, then it is stored as JSON. This allows calls to json_array() and json_object() to be nested. The json() function can also be used to force strings to be recognized as JSON.

Examples:

  • json_array(1,2,'3',4) → '[1,2,"3",4]'
  • json_array('[1,2]') → '["[1,2]"]'
  • json_array(json_array(1,2)) → '[[1,2]]'
  • json_array(1,null,'3','[4,5]','{"six":7.7}') → '[1,null,"3","[4,5]","{\"six\":7.7}"]'
  • json_array(1,null,'3',json('[4,5]'),json('{"six":7.7}')) → '[1,null,"3",[4,5],{"six":7.7}]'

4.3. The json_array_length() function

The json_array_length(X) function returns the number of elements in the JSON array X, or 0 if X is some kind of JSON value other than an array. The json_array_length(X,P) locates the array at path P within X and returns the length of that array, or 0 if path P locates an element in X that is not a JSON array, and NULL if path P does not locate any element of X. Errors are thrown if either X is not well-formed JSON or if P is not a well-formed path.

Examples:

  • json_array_length('[1,2,3,4]') → 4
  • json_array_length('[1,2,3,4]', '$') → 4
  • json_array_length('[1,2,3,4]', '$[2]') → 0
  • json_array_length('{"one":[1,2,3]}') → 0
  • json_array_length('{"one":[1,2,3]}', '$.one') → 3
  • json_array_length('{"one":[1,2,3]}', '$.two') → NULL

4.4. The json_error_position() function

The json_error_positionf(X) function returns 0 if the input X is a well-formed JSON or JSON5 string. If the input X contains one or more syntax errors, then this function returns the character position of the first syntax error. The left-most character is position 1.

This routine is useful for at least two purposes:

  1. To determine is a text string X is valid JSON or JSON5 as understood by SQLite, run "json_error_position(X)==0". This is similar to json_valid() except that json_valid(X) requires X to be strictly conforming canonical JSON whereas json_error_position() allows the input to contains JSON5 extensions.

  2. Use this routine to find the location of a syntax error in a large JSON string during interactive debugging, or to generate a better error messages for human users.

The json_error_position() function was added with SQLite version 3.42.0 (2023-05-16).

4.5. The json_extract() function

The json_extract(X,P1,P2,...) extracts and returns one or more values from the well-formed JSON at X. If only a single path P1 is provided, then the SQL datatype of the result is NULL for a JSON null, INTEGER or REAL for a JSON numeric value, an INTEGER zero for a JSON false value, an INTEGER one for a JSON true value, the dequoted text for a JSON string value, and a text representation for JSON object and array values. If there are multiple path arguments (P1, P2, and so forth) then this routine returns SQLite text which is a well-formed JSON array holding the various values.

Examples:

  • json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$') → '{"a":2,"c":[4,5,{"f":7}]}'
  • json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c') → '[4,5,{"f":7}]'
  • json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2]') → '{"f":7}'
  • json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c[2].f') → 7
  • json_extract('{"a":2,"c":[4,5],"f":7}','$.c','$.a') → '[[4,5],2]'
  • json_extract('{"a":2,"c":[4,5],"f":7}','$.c[#-1]') → 5
  • json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x') → NULL
  • json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x', '$.a') → '[null,2]'
  • json_extract('{"a":"xyz"}', '$.a') → 'xyz'
  • json_extract('{"a":null}', '$.a') → NULL

There is a subtle incompatibility between the json_extract() function in SQLite and the json_extract() function in MySQL. The MySQL version of json_extract() always returns JSON. The SQLite version of json_extract() only returns JSON if there are two or more PATH arguments (because the result is then a JSON array) or if the single PATH argument references an array or object. In SQLite, if json_extract() has only a single PATH argument and that PATH references a JSON null or a string or a numeric value, then json_extract() returns the corresponding SQL NULL, TEXT, INTEGER, or REAL value.

The difference between MySQL json_extract() and SQLite json_extract() really only stands out when accessing individual values within the JSON that are strings or NULLs. The following table demonstrates the difference:

Operation | SQLite Result | MySQL Result
json_extract('{"a":null,"b":"xyz"}','$.a') | NULL | 'null'
json_extract('{"a":null,"b":"xyz"}','$.b') | 'xyz' | '"xyz"'

4.6. The -> and ->> operators

Beginning with SQLite version 3.38.0 (2022-02-22), the -> and ->> operators are available for extracting subcomponents of JSON. The SQLite implementation of -> and ->> strives to be compatible with both MySQL and PostgreSQL. The -> and ->> operators take a JSON string as their left operand and a PATH expression or object field label or array index as their right operand. The -> operator returns a JSON representation of the selected subcomponent or NULL if that subcomponent does not exist. The ->> operator returns an SQL TEXT, INTEGER, REAL, or NULL value that represents the selected subcomponent, or NULL if the subcomponent does not exist.

Both the -> and ->> operators select the same subcomponent of the JSON to their left. The difference is that -> always returns a JSON representation of that subcomponent and the ->> operator always returns an SQL representation of that subcomponent. Thus, these operators are subtly different from a two-argument json_extract() function call. A call to json_extract() with two arguments will return a JSON representation of the subcomponent if and only if the subcomponent is a JSON array or object, and will return an SQL representation of the subcomponent if the subcomponent is a JSON null, string, or numeric value.

The right-hand operand to the -> and ->> operators can be a well-formed JSON path expression. This is the form used by MySQL. For compatibility with PostgreSQL, the -> and ->> operators also accept a text label or integer as their right-hand operand. If the right operand is a text label X, then it is interpreted as the JSON path '$.X'. If the right operand is an integer value N, then it is interpreted as the JSON path '$[N]'.

Examples:

  • '{"a":2,"c":[4,5,{"f":7}]}' -> '$' → '{"a":2,"c":[4,5,{"f":7}]}'
  • '{"a":2,"c":[4,5,{"f":7}]}' -> '$.c' → '[4,5,{"f":7}]'
  • '{"a":2,"c":[4,5,{"f":7}]}' -> 'c' → '[4,5,{"f":7}]'
  • '{"a":2,"c":[4,5,{"f":7}]}' -> '$.c[2]' → '{"f":7}'
  • '{"a":2,"c":[4,5,{"f":7}]}' -> '$.c[2].f' → '7'
  • '{"a":2,"c":[4,5],"f":7}' -> '$.c[#-1]' → '5'
  • '{"a":2,"c":[4,5,{"f":7}]}' -> '$.x' → NULL
  • '[11,22,33,44]' -> 3 → '44'
  • '[11,22,33,44]' ->> 3 → 44
  • '{"a":"xyz"}' -> '$.a' → '"xyz"'
  • '{"a":"xyz"}' ->> '$.a' → 'xyz'
  • '{"a":null}' -> '$.a' → 'null'
  • '{"a":null}' ->> '$.a' → NULL

4.7. The json_insert(), json_replace, and json_set() functions

The json_insert(), json_replace, and json_set() functions all take a single JSON value as their first argument followed by zero or more pairs of path and value arguments, and return a new JSON string formed by updating the input JSON by the path/value pairs. The functions differ only in how they deal with creating new values and overwriting preexisting values.

Function | Overwrite if already exists? | Create if does not exist?
json_insert() | No | Yes
json_replace() | Yes | No
json_set() | Yes | Yes

The json_insert(), json_replace(), and json_set() functions always take an odd number of arguments. The first argument is always the original JSON to be edited. Subsequent arguments occur in pairs with the first element of each pair being a path and the second element being the value to insert or replace or set on that path.

Edits occur sequentially from left to right. Changes caused by prior edits can affect the path search for subsequent edits.

If the value of a path/value pair is an SQLite TEXT value, then it is normally inserted as a quoted JSON string, even if the string looks like valid JSON. However, if the value is the result of another json function (such as json() or json_array() or json_object()) or if it is the result of the -> operator, then it is interpreted as JSON and is inserted as JSON retaining all of its substructure. Values that are the result of the ->> operator are always interpreted as TEXT and are inserted as a JSON string even if they look like valid JSON.

These routines throw an error if the first JSON argument is not well-formed or if any PATH argument is not well-formed or if any argument is a BLOB.

To append an element onto the end of an array, using json_insert() with an array index of "#". Examples:

  • json_insert('[1,2,3,4]','$[#]',99) → '[1,2,3,4,99]'
  • json_insert('[1,[2,3],4]','$[1][#]',99) → '[1,[2,3,99],4]'

Other examples:

  • json_insert('{"a":2,"c":4}', '$.a', 99) → '{"a":2,"c":4}'
  • json_insert('{"a":2,"c":4}', '$.e', 99) → '{"a":2,"c":4,"e":99}'
  • json_replace('{"a":2,"c":4}', '$.a', 99) → '{"a":99,"c":4}'
  • json_replace('{"a":2,"c":4}', '$.e', 99) → '{"a":2,"c":4}'
  • json_set('{"a":2,"c":4}', '$.a', 99) → '{"a":99,"c":4}'
  • json_set('{"a":2,"c":4}', '$.e', 99) → '{"a":2,"c":4,"e":99}'
  • json_set('{"a":2,"c":4}', '$.c', '[97,96]') → '{"a":2,"c":"[97,96]"}'
  • json_set('{"a":2,"c":4}', '$.c', json('[97,96]')) → '{"a":2,"c":[97,96]}'
  • json_set('{"a":2,"c":4}', '$.c', json_array(97,96)) → '{"a":2,"c":[97,96]}'

4.8. The json_object() function

The json_object() SQL function accepts zero or more pairs of arguments and returns a well-formed JSON object that is composed from those arguments. The first argument of each pair is the label and the second argument of each pair is the value. If any argument to json_object() is a BLOB then an error is thrown.

The json_object() function currently allows duplicate labels without complaint, though this might change in a future enhancement.

An argument with SQL type TEXT it is normally converted into a quoted JSON string even if the input text is well-formed JSON. However, if the argument is the direct result from another JSON function or the -> operator (but not the ->> operator), then it is treated as JSON and all of its JSON type information and substructure is preserved. This allows calls to json_object() and json_array() to be nested. The json() function can also be used to force strings to be recognized as JSON.

Examples:

  • json_object('a',2,'c',4) → '{"a":2,"c":4}'
  • json_object('a',2,'c','{e:5}') → '{"a":2,"c":"{e:5}"}'
  • json_object('a',2,'c',json_object('e',5)) → '{"a":2,"c":{"e":5}}'

4.9. The json_patch() function

The json_patch(T,P) SQL function runs the RFC-7396 MergePatch algorithm to apply patch P against input T. The patched copy of T is returned.

MergePatch can add, modify, or delete elements of a JSON Object, and so for JSON Objects, the json_patch() routine is a generalized replacement for json_set() and json_remove(). However, MergePatch treats JSON Array objects as atomic. MergePatch cannot append to an Array nor modify individual elements of an Array. It can only insert, replace, or delete the whole Array as a single unit. Hence, json_patch() is not as useful when dealing with JSON that includes Arrays, especially Arrays with lots of substructure.

Examples:

  • json_patch('{"a":1,"b":2}','{"c":3,"d":4}') → '{"a":1,"b":2,"c":3,"d":4}'
  • json_patch('{"a":[1,2],"b":2}','{"a":9}') → '{"a":9,"b":2}'
  • json_patch('{"a":[1,2],"b":2}','{"a":null}') → '{"b":2}'
  • json_patch('{"a":1,"b":2}','{"a":9,"b":null,"c":8}') → '{"a":9,"c":8}'
  • json_patch('{"a":{"x":1,"y":2},"b":3}','{"a":{"y":9},"c":8}') → '{"a":{"x":1,"y":9},"b":3,"c":8}'

4.10. The json_remove() function

The json_remove(X,P,...) function takes a single JSON value as its first argument followed by zero or more path arguments. The json_remove(X,P,...) function returns a copy of the X parameter with all the elements identified by path arguments removed. Paths that select elements not found in X are silently ignored.

Removals occurs sequentially from left to right. Changes caused by prior removals can affect the path search for subsequent arguments.

If the json_remove(X) function is called with no path arguments, then it returns the input X reformatted, with excess whitespace removed.

The json_remove() function throws an error if the first argument is not well-formed JSON or if any later argument is not a well-formed path, or if any argument is a BLOB.

Examples:

  • json_remove('[0,1,2,3,4]','$[2]') → '[0,1,3,4]'
  • json_remove('[0,1,2,3,4]','$[2]','$[0]') → '[1,3,4]'
  • json_remove('[0,1,2,3,4]','$[0]','$[2]') → '[1,2,4]'
  • json_remove('[0,1,2,3,4]','$[#-1]','$[0]') → '[1,2,3]'
  • json_remove('{"x":25,"y":42}') → '{"x":25,"y":42}'
  • json_remove('{"x":25,"y":42}','$.z') → '{"x":25,"y":42}'
  • json_remove('{"x":25,"y":42}','$.y') → '{"x":25}'
  • json_remove('{"x":25,"y":42}','$') → NULL

4.11. The json_type() function

The json_type(X) function returns the "type" of the outermost element of X. The json_type(X,P) function returns the "type" of the element in X that is selected by path P. The "type" returned by json_type() is one of the following SQL text values: 'null', 'true', 'false', 'integer', 'real', 'text', 'array', or 'object'. If the path P in json_type(X,P) selects an element that does not exist in X, then this function returns NULL.

The json_type() function throws an error if any of its arguments is not well-formed or is a BLOB.

Examples:

  • json_type('{"a":[2,3.5,true,false,null,"x"]}') → 'object'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$') → 'object'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a') → 'array'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[0]') → 'integer'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[1]') → 'real'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[2]') → 'true'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[3]') → 'false'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[4]') → 'null'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[5]') → 'text'
  • json_type('{"a":[2,3.5,true,false,null,"x"]}','$.a[6]') → NULL

4.12. The json_valid() function

The json_valid(X) function return 1 if the argument X is well-formed canonical RFC-7159 JSON without any extensions, or return 0 if the argument X is not well-formed JSON or is JSON that includes JSON5 extensions.

Examples:

  • json_valid('{"x":35}') → 1
  • json_valid('{"x":35') → 0

Use the expression "json_error_position(X)==0" to determine if a string is well-formed JSON5. Use the "json(X)" routine to convert JSON5 into canonical JSON.

4.13. The json_quote() function

The json_quote(X) function converts the SQL value X (a number or a string) into its corresponding JSON representation. If X is a JSON value returned by another JSON function, then this function is a no-op.

Examples:

  • json_quote(3.14159) → 3.14159
  • json_quote('verdant') → '"verdant"'
  • json_quote('[1]') → '"[1]"'
  • json_quote(json('[1]')) → '[1]'
  • json_quote('[1,') → '"[1,"'

4.14. The json_group_array() and json_group_object() aggregate SQL functions

The json_group_array(X) function is an aggregate SQL function that returns a JSON array comprised of all X values in the aggregation. Similarly, the json_group_object(NAME,VALUE) function returns a JSON object comprised of all NAME/VALUE pairs in the aggregation.

4.15. The json_each() and json_tree() table-valued functions

The json_each(X) and json_tree(X) table-valued functions walk the JSON value provided as their first argument and return one row for each element. The json_each(X) function only walks the immediate children of the top-level array or object, or just the top-level element itself if the top-level element is a primitive value. The json_tree(X) function recursively walks through the JSON substructure starting with the top-level element.

The json_each(X,P) and json_tree(X,P) functions work just like their one-argument counterparts except that they treat the element identified by path P as the top-level element.

The schema for the table returned by json_each() and json_tree() is as follows:

CREATE TABLE json_tree(
    key ANY,             -- key for current element relative to its parent
    value ANY,           -- value for the current element
    type TEXT,           -- 'object','array','string','integer', etc.
    atom ANY,            -- value for primitive types, null for array & object
    id INTEGER,          -- integer ID for this element
    parent INTEGER,      -- integer ID for the parent of this element
    fullkey TEXT,        -- full path describing the current element
    path TEXT,           -- path to the container of the current row
    json JSON HIDDEN,    -- 1st input parameter: the raw JSON
    root TEXT HIDDEN     -- 2nd input parameter: the PATH at which to start
);

The "key" column is the integer array index for elements of a JSON array and the text label for elements of a JSON object. The key column is NULL in all other cases.

The "atom" column is the SQL value corresponding to primitive elements - elements other than JSON arrays and objects. The "atom" column is NULL for a JSON array or object. The "value" column is the same as the "atom" column for primitive JSON elements but takes on the text JSON value for arrays and objects.

The "type" column is an SQL text value taken from ('null', 'true', 'false', 'integer', 'real', 'text', 'array', 'object') according to the type of the current JSON element.

The "id" column is an integer that identifies a specific JSON element within the complete JSON string. The "id" integer is an internal housekeeping number, the computation of which might change in future releases. The only guarantee is that the "id" column will be different for every row.

The "parent" column is always NULL for json_each(). For json_tree(), the "parent" column is the "id" integer for the parent of the current element, or NULL for the top-level JSON element or the element identified by the root path in the second argument.

The "fullkey" column is a text path that uniquely identifies the current row element within the original JSON string. The complete key to the true top-level element is returned even if an alternative starting point is provided by the "root" argument.

The "path" column is the path to the array or object container that holds the current row, or the path to the current row in the case where the iteration starts on a primitive type and thus only provides a single row of output.

4.15.1. Examples using json_each() and json_tree()

Suppose the table "CREATE TABLE user(name,phone)" stores zero or more phone numbers as a JSON array object in the user.phone field. To find all users who have any phone number with a 704 area code:

SELECT DISTINCT user.name
  FROM user, json_each(user.phone)
 WHERE json_each.value LIKE '704-%';

Now suppose the user.phone field contains plain text if the user has only a single phone number and a JSON array if the user has multiple phone numbers. The same question is posed: "Which users have a phone number in the 704 area code?" But now the json_each() function can only be called for those users that have two or more phone numbers since json_each() requires well-formed JSON as its first argument:

SELECT name FROM user WHERE phone LIKE '704-%'
UNION
SELECT user.name
  FROM user, json_each(user.phone)
 WHERE json_valid(user.phone)
   AND json_each.value LIKE '704-%';

Consider a different database with "CREATE TABLE big(json JSON)". To see a complete line-by-line decomposition of the data:

SELECT big.rowid, fullkey, value
  FROM big, json_tree(big.json)
 WHERE json_tree.type NOT IN ('object','array');

In the previous, the "type NOT IN ('object','array')" term of the WHERE clause suppresses containers and only lets through leaf elements. The same effect could be achieved this way:

SELECT big.rowid, fullkey, atom
  FROM big, json_tree(big.json)
 WHERE atom IS NOT NULL;

Suppose each entry in the BIG table is a JSON object with a '$.id' field that is a unique identifier and a '$.partlist' field that can be a deeply nested object. You want to find the id of every entry that contains one or more references to uuid '6fa5181e-5721-11e5-a04e-57f3d7b32808' anywhere in its '$.partlist'.

SELECT DISTINCT json_extract(big.json,'$.id')
  FROM big, json_tree(big.json, '$.partlist')
 WHERE json_tree.key='uuid'
   AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';

This page last modified on 2023-05-12 17:36:51 UTC


Built-in Aggregate Functions

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
Built-in Aggregate Functions

1. Syntax

aggregate-function-invocation:

aggregate-func ( DISTINCT expr ) filter-clause , *

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

filter-clause:

FILTER ( WHERE expr )

The aggregate functions shown below are available by default. Additional aggregate functions written in C may be added using the sqlite3_create_function() API.

In any aggregate function that takes a single argument, that argument can be preceded by the keyword DISTINCT. In such cases, duplicate elements are filtered before being passed into the aggregate function. For example, the function "count(distinct X)" will return the number of distinct values of column X instead of the total number of non-null values in column X.

If a FILTER clause is provided, then only rows for which the expr is true are included in the aggregate.

2. List of built-in aggregate functions

  • avg(X)
  • count(*)
  • count(X)
  • group_concat(X)
  • group_concat(X,Y)
  • max(X)
  • min(X)
  • sum(X)
  • total(X)

3. Descriptions of built-in aggregate functions

avg(X)

The avg() function returns the average value of all non-NULL X within a group. String and BLOB values that do not look like numbers are interpreted as 0. The result of avg() is always a floating point value whenever there is at least one non-NULL input even if all inputs are integers. The result of avg() is NULL if and only if there are no non-NULL inputs.

count(X)
count(*)

The count(X) function returns a count of the number of times that X is not NULL in a group. The count(*) function (with no arguments) returns the total number of rows in the group.

group_concat(X)
group_concat(X,Y)

The group_concat() function returns a string which is the concatenation of all non-NULL values of X. If parameter Y is present then it is used as the separator between instances of X. A comma (",") is used as the separator if Y is omitted. The order of the concatenated elements is arbitrary.

max(X)

The max() aggregate function returns the maximum value of all values in the group. The maximum value is the value that would be returned last in an ORDER BY on the same column. Aggregate max() returns NULL if and only if there are no non-NULL values in the group.

min(X)

The min() aggregate function returns the minimum non-NULL value of all values in the group. The minimum value is the first non-NULL value that would appear in an ORDER BY of the column. Aggregate min() returns NULL if and only if there are no non-NULL values in the group.

sum(X)
total(X)

The sum() and total() aggregate functions return the sum of all non-NULL values in the group. If there are no non-NULL input rows then sum() returns NULL but total() returns 0.0. NULL is not normally a helpful result for the sum of no rows but the SQL standard requires it and most other SQL database engines implement sum() that way so SQLite does it in the same way in order to be compatible. The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.

The result of total() is always a floating point value. The result of sum() is an integer value if all non-NULL inputs are integers. If any input to sum() is neither an integer nor a NULL, then sum() returns a floating point value which is an approximation of the mathematical sum.

Sum() will throw an "integer overflow" exception if all inputs are integers or NULL and an integer overflow occurs at any point during the computation. Total() never throws an integer overflow.


ALTER TABLE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
ALTER TABLE

1. Overview

alter-table-stmt:

ALTER TABLE schema-name . table-name RENAME TO new-table-name RENAME COLUMN column-name TO new-column-name ADD COLUMN column-def DROP COLUMN column-name

column-def:

column-name type-name column-constraint

column-constraint:

CONSTRAINT name PRIMARY KEY DESC conflict-clause AUTOINCREMENT ASC NOT NULL conflict-clause UNIQUE conflict-clause CHECK ( expr ) DEFAULT ( expr ) literal-value signed-number COLLATE collation-name foreign-key-clause GENERATED ALWAYS AS ( expr ) VIRTUAL STORED

conflict-clause:

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

foreign-key-clause:

REFERENCES foreign-table ( column-name ) , ON DELETE SET NULL UPDATE SET DEFAULT CASCADE RESTRICT NO ACTION MATCH name NOT DEFERRABLE INITIALLY DEFERRED INITIALLY IMMEDIATE

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

signed-number:

+ numeric-literal -

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows these alterations of an existing table: it can be renamed; a column can be renamed; a column can be added to it; or a column can be dropped from it.

2. ALTER TABLE RENAME

The RENAME TO syntax changes the name of table-name to new-table-name. This command cannot be used to move a table between attached databases, only to rename a table within the same database. If the table being renamed has triggers or indices, then these remain attached to the table after it has been renamed.

Compatibility Note: The behavior of ALTER TABLE when renaming a table was enhanced in versions 3.25.0 (2018-09-15) and 3.26.0 (2018-12-01) in order to carry the rename operation forward into triggers and views that reference the renamed table. This is considered an improvement. Applications that depend on the older (and arguably buggy) behavior can use the PRAGMA legacy_alter_table=ON statement or the SQLITE_DBCONFIG_LEGACY_ALTER_TABLE configuration parameter on sqlite3_db_config() interface to make ALTER TABLE RENAME behave as it did prior to version 3.25.0.

Beginning with release 3.25.0 (2018-09-15), references to the table within trigger bodies and view definitions are also renamed.

Prior to version 3.26.0 (2018-12-01), FOREIGN KEY references to a table that is renamed were only edited if the PRAGMA foreign_keys=ON, or in other words if foreign key constraints were being enforced. With PRAGMA foreign_keys=OFF, FOREIGN KEY constraints would not be changed when the table that the foreign key referred to (the "parent table") was renamed. Beginning with version 3.26.0, FOREIGN KEY constraints are always converted when a table is renamed, unless the PRAGMA legacy_alter_table=ON setting is engaged. The following table summarizes the difference:

PRAGMA foreign_keys | PRAGMA legacy_alter_table | Parent Table references are updated | SQLite version
Off | Off | No | < 3.26.0
Off | Off | Yes | >= 3.26.0
On | Off | Yes | all
Off | On | No | all
On | On | Yes | all

3. ALTER TABLE RENAME COLUMN

The RENAME COLUMN TO syntax changes the column-name of table table-name into new-column-name. The column name is changed both within the table definition itself and also within all indexes, triggers, and views that reference the column. If the column name change would result in a semantic ambiguity in a trigger or view, then the RENAME COLUMN fails with an error and no changes are applied.

4. ALTER TABLE ADD COLUMN

The ADD COLUMN syntax is used to add a new column to an existing table. The new column is always appended to the end of the list of existing columns. The column-def rule defines the characteristics of the new column. The new column may take any of the forms permissible in a CREATE TABLE statement, with the following restrictions:

  • The column may not have a PRIMARY KEY or UNIQUE constraint.
  • The column may not have a default value of CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP, or an expression in parentheses.
  • If a NOT NULL constraint is specified, then the column must have a default value other than NULL.
  • If foreign key constraints are enabled and a column with a REFERENCES clause is added, the column must have a default value of NULL.
  • The column may not be GENERATED ALWAYS ... STORED, though VIRTUAL columns are allowed.

When adding a column with a CHECK constraint, or a NOT NULL constraint on a generated column, the added constraints are tested against all preexisting rows in the table and the ADD COLUMN fails if any constraint fails. The testing of added constraints against preexisting rows is a new enhancement as of SQLite version 3.37.0 (2021-11-27).

The ALTER TABLE command works by modifying the SQL text of the schema stored in the sqlite_schema table. No changes are made to table content for renames or column addition without constraints. Because of this, the execution time of such ALTER TABLE commands is independent of the amount of data in the table and such commands will run as quickly on a table with 10 million rows as on a table with 1 row. When adding new columns that have CHECK constraints, or adding generated columns with NOT NULL constraints, or when deleting columns, then all existing data in the table must be either read (to test new constraints against existing rows) or written (to remove deleted columns). In those cases, the ALTER TABLE command takes time that is proportional to the amount of content in the table being altered.

After ADD COLUMN has been run on a database, that database will not be readable by SQLite version 3.1.3 (2005-02-20) and earlier.

5. ALTER TABLE DROP COLUMN

The DROP COLUMN syntax is used to remove an existing column from a table. The DROP COLUMN command removes the named column from the table, and rewrites its content to purge the data associated with that column. The DROP COLUMN command only works if the column is not referenced by any other parts of the schema and is not a PRIMARY KEY and does not have a UNIQUE constraint. Possible reasons why the DROP COLUMN command can fail include:

  • The column is a PRIMARY KEY or part of one.
  • The column has a UNIQUE constraint.
  • The column is indexed.
  • The column is named in the WHERE clause of a partial index.
  • The column is named in a table or column CHECK constraint not associated with the column being dropped.
  • The column is used in a foreign key constraint.
  • The column is used in the expression of a generated column.
  • The column appears in a trigger or view.

5.1. How It Works

SQLite stores the schema as plain text in the sqlite_schema table. The DROP COLUMN command (and all of the other variations of ALTER TABLE as well) modify that text and then attempt to reparse the entire schema. The command is only successful if the schema is still valid after the text has been modified. In the case of the DROP COLUMN command, the only text modified is that the column definition is removed from the CREATE TABLE statement. The DROP COLUMN command will fail if there are any traces of the column in other parts of the schema that will prevent the schema from parsing after the CREATE TABLE statement has been modified.

6. Disable Error Checking Using PRAGMA writable_schema=ON

ALTER TABLE will normally fail and make no changes if it encounters any entries in the sqlite_schema table that do not parse. For example, if there is a malformed VIEW or TRIGGER associated with table named "tbl1", then an attempt to rename "tbl1" to "tbl1neo" will fail because the associated views and triggers could not be parsed.

Beginning with SQLite 3.38.0 (2022-02-22), this error checking can be disabled by setting "PRAGMA writable_schema=ON;". When the schema is writable, ALTER TABLE silently ignores any rows of the sqlite_schema table that do not parse.

7. Making Other Kinds Of Table Schema Changes

The only schema altering commands directly supported by SQLite are the "rename table", "rename column", "add column", "drop column" commands shown above. However, applications can make other arbitrary changes to the format of a table using a simple sequence of operations. The steps to make arbitrary changes to the schema design of some table X are as follows:

  1. If foreign key constraints are enabled, disable them using PRAGMA foreign_keys=OFF.

  2. Start a transaction.

  3. Remember the format of all indexes, triggers, and views associated with table X. This information will be needed in step 8 below. One way to do this is to run a query like the following: SELECT type, sql FROM sqlite_schema WHERE tbl_name='X'.

  4. Use CREATE TABLE to construct a new table "new_X" that is in the desired revised format of table X. Make sure that the name "new_X" does not collide with any existing table name, of course.

  5. Transfer content from X into new_X using a statement like: INSERT INTO new_X SELECT ... FROM X.

  6. Drop the old table X: DROP TABLE X.

  7. Change the name of new_X to X using: ALTER TABLE new_X RENAME TO X.

  8. Use CREATE INDEX, CREATE TRIGGER, and CREATE VIEW to reconstruct indexes, triggers, and views associated with table X. Perhaps use the old format of the triggers, indexes, and views saved from step 3 above as a guide, making changes as appropriate for the alteration.

  9. If any views refer to table X in a way that is affected by the schema change, then drop those views using DROP VIEW and recreate them with whatever changes are necessary to accommodate the schema change using CREATE VIEW.

  10. If foreign key constraints were originally enabled then run PRAGMA foreign_key_check to verify that the schema change did not break any foreign key constraints.

  11. Commit the transaction started in step 2.

  12. If foreign keys constraints were originally enabled, reenable them now.

Caution: Take care to follow the procedure above precisely. The boxes below summarize two procedures for modifying a table definition. At first glance, they both appear to accomplish the same thing. However, the procedure on the right does not always work, especially with the enhanced rename table capabilities added by versions 3.25.0 and 3.26.0. In the procedure on the right, the initial rename of the table to a temporary name might corrupt references to that table in triggers, views, and foreign key constraints. The safe procedure on the left constructs the revised table definition using a new temporary name, then renames the table into its final name, which does not break links.

  1. Create new table
  2. Copy data
  3. Drop old table
  4. Rename new into old
  1. Rename old table
  2. Create new table
  3. Copy data
  4. Drop old table
↑
Correct 		↑
Incorrect

The 12-step generalized ALTER TABLE procedure above will work even if the schema change causes the information stored in the table to change. So the full 12-step procedure above is appropriate for dropping a column, changing the order of columns, adding or removing a UNIQUE constraint or PRIMARY KEY, adding CHECK or FOREIGN KEY or NOT NULL constraints, or changing the datatype for a column, for example. However, a simpler and faster procedure can optionally be used for some changes that do no affect the on-disk content in any way. The following simpler procedure is appropriate for removing CHECK or FOREIGN KEY or NOT NULL constraints, or adding, removing, or changing default values on a column.

  1. Start a transaction.

  2. Run PRAGMA schema_version to determine the current schema version number. This number will be needed for step 6 below.

  3. Activate schema editing using PRAGMA writable_schema=ON.

  4. Run an UPDATE statement to change the definition of table X in the sqlite_schema table: UPDATE sqlite_schema SET sql=... WHERE type='table' AND name='X';

    Caution: Making a change to the sqlite_schema table like this will render the database corrupt and unreadable if the change contains a syntax error. It is suggested that careful testing of the UPDATE statement be done on a separate blank database prior to using it on a database containing important data.

  5. If the change to table X also affects other tables or indexes or triggers are views within schema, then run UPDATE statements to modify those other tables indexes and views too. For example, if the name of a column changes, all FOREIGN KEY constraints, triggers, indexes, and views that refer to that column must be modified.

    Caution: Once again, making changes to the sqlite_schema table like this will render the database corrupt and unreadable if the change contains an error. Carefully test this entire procedure on a separate test database prior to using it on a database containing important data and/or make backup copies of important databases prior to running this procedure.

  6. Increment the schema version number using PRAGMA schema_version=X where X is one more than the old schema version number found in step 2 above.

  7. Disable schema editing using PRAGMA writable_schema=OFF.

  8. (Optional) Run PRAGMA integrity_check to verify that the schema changes did not damage the database.

  9. Commit the transaction started on step 1 above.

If some future version of SQLite adds new ALTER TABLE capabilities, those capabilities will very likely use one of the two procedures outlined above.

8. Why ALTER TABLE is such a problem for SQLite

Most SQL database engines store the schema already parsed into various system tables. On those database engines, ALTER TABLE merely has to make modifications to the corresponding system tables.

SQLite is different in that it stores the schema in the sqlite_schema table as the original text of the CREATE statements that define the schema. Hence ALTER TABLE needs to revise the text of the CREATE statement. Doing so can be tricky for certain "creative" schema designs.

The SQLite approach of storing the schema as text has advantages for an embedded relational database. For one, it means that the schema takes up less space in the database file. This is important since a common SQLite usage pattern is to have many small, separate database files instead of putting everything in one big global database file, which is the usual approach for client/server database engines. Since the schema is duplicated in each separate database file, it is important to keep the schema representation compact.

Storing the schema as text rather than as parsed tables also give flexibility to the implementation. Since the internal parse of the schema is regenerated each time the database is opened, the internal representation of the schema can change from one release to the next. This is important, as sometimes new features require enhancements to the internal schema representation. Changing the internal schema representation would be much more difficult if the schema representation was exposed in the database file. So, in other words, storing the schema as text helps maintain backwards compatibility, and helps ensure that older database files can be read and written by newer versions of SQLite.

Storing the schema as text also makes the SQLite database file format easier to define, document, and understand. This helps make SQLite database files a recommended storage format for long-term archiving of data.

The downside of storing schema a text is that it can make the schema tricky to modify. And for that reason, the ALTER TABLE support in SQLite has traditionally lagged behind other SQL database engines that store their schemas as parsed system tables that are easier to modify.


ANALYZE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
ANALYZE

1. Overview

analyze-stmt:

ANALYZE schema-name . table-or-index-name schema-name index-or-table-name

The ANALYZE command gathers statistics about tables and indices and stores the collected information in internal tables of the database where the query optimizer can access the information and use it to help make better query planning choices. If no arguments are given, all attached databases are analyzed. If a schema name is given as the argument, then all tables and indices in that one database are analyzed. If the argument is a table name, then only that table and the indices associated with that table are analyzed. If the argument is an index name, then only that one index is analyzed.

1.1. Recommended usage pattern

Applications with long-lived databases that use complex queries should consider running the following commands just prior to closing each database connection:

PRAGMA analysis_limit=400;
PRAGMA optimize;

The optimize pragma is usually a no-op but it will occasionally run ANALYZE if it seems like doing so will be useful to the query planner. The analysis_limit pragma limits the scope of any ANALYZE command that the optimize pragma runs so that it does not consume too many CPU cycles. The constant "400" can be adjusted as needed. Values between 100 and 1000 work well for most applications.

2. Details

The default implementation stores all statistics in a single table named "sqlite_stat1". If SQLite is compiled with the SQLITE_ENABLE_STAT4 option, then additional histogram data is collected and stored in sqlite_stat4. Older versions of SQLite would make use of the sqlite_stat2 table or sqlite_stat3 table when compiled with SQLITE_ENABLE_STAT2 or SQLITE_ENABLE_STAT3, but all recent versions of SQLite ignore the sqlite_stat2 and sqlite_stat3 tables. Future enhancements may create additional internal tables with the same name pattern except with final digit larger than "4". All of these tables are collectively referred to as "statistics tables".

The content of the statistics tables can be queried using SELECT and can be changed using the DELETE, INSERT, and UPDATE commands. The DROP TABLE command works on statistics tables as of SQLite version 3.7.9. (2011-11-01) The ALTER TABLE command does not work on statistics tables. Appropriate care should be used when changing the content of the statistics tables as invalid content can cause SQLite to select inefficient query plans. Generally speaking, one should not modify the content of the statistics tables by any mechanism other than invoking the ANALYZE command. See "Manual Control Of Query Plans Using SQLITE_STAT Tables" for further information.

Statistics gathered by ANALYZE are not automatically updated as the content of the database changes. If the content of the database changes significantly, or if the database schema changes, then one should consider rerunning the ANALYZE command in order to update the statistics.

The query planner loads the content of the statistics tables into memory when the schema is read. Hence, when an application changes the statistics tables directly, SQLite will not immediately notice the changes. An application can force the query planner to reread the statistics tables by running ANALYZE sqlite_schema.

3. Automatically Running ANALYZE

The PRAGMA optimize command will automatically run ANALYZE on individual tables on an as-needed basis. The recommended practice is for applications to invoke the PRAGMA optimize statement just before closing each database connection.

Each SQLite database connection records cases when the query planner would benefit from having accurate results of ANALYZE at hand. These records are held in memory and accumulate over the life of a database connection. The PRAGMA optimize command looks at those records and runs ANALYZE on only those tables for which new or updated ANALYZE data seems likely to be useful. In most cases PRAGMA optimize will not run ANALYZE, but it will occasionally do so either for tables that have never before been analyzed, or for tables that have grown significantly since they were last analyzed.

Since the actions of PRAGMA optimize are determined to some extent by prior queries that have been evaluated on the same database connection, it is recommended that PRAGMA optimize be deferred until the database connection is closing and has thus had an opportunity to accumulate as much usage information as possible. It is also reasonable to set a timer to run PRAGMA optimize every few hours, or every few days, for database connections that stay open for a long time.

Applications that desire more control can run PRAGMA optimize(0x03) to obtain a list of ANALYZE commands that SQLite thinks are appropriate to run, but without actually running those commands. If the returned set is non-empty, the application can then make a decision about whether or not to run the suggested ANALYZE commands, perhaps after prompting the user for guidance.

The PRAGMA optimize command was first introduced with SQLite 3.18.0 (2017-03-28) and is a no-op for all prior releases of SQLite.

4. Approximate ANALYZE For Large Databases

By default, ANALYZE does a full scan of every index. This can be slow for large databases. So beginning with SQLite version 3.32.0 (2020-05-22), the PRAGMA analysis_limit command can be used to limit the amount of scanning performed by ANALYZE, and thus help ANALYZE to run faster, even on very large database files. We call this running an "approximate ANALYZE".

The recommended usage pattern for the analysis_limit pragma is like this:

PRAGMA analysis_limit=1000;

This pragma tells the ANALYZE command to start a full scan of the index as it normally would. But when the number of rows visited reaches 1000 (or whatever other limit is specified by the pragma), the ANALYZE command will begin taking actions to stop the scan. If the left-most column of the index has changed at least once during the previous 1000 steps, then the analysis stops immediately. But if the left-most column has always been the same, then ANALYZE skips ahead to the first entry with a different left-most column and reads an additional 1000 rows before terminating.

The details of the effects of the analysis limit described in the previous paragraph are subject to change in future versions of SQLite. But the core idea will remain the same. An analysis limit of N will strive to limit the number of rows visited in each index to approximately N.

Values of N between 100 and 1000 are recommended. Or, to disable the analysis limit, causing ANALYZE to do a complete scan of each index, set the analysis limit to 0. The default value for the analysis limit is 0 for backwards compatibility.

The values placed in the sqlite_stat1 table by an approximate ANALYZE are not exactly the same as what would be computed by an unrestricted analysis. But they are usually close enough. The index statistics in the sqlite_stat1 table are approximations in any case, so the fact that the results of an approximate ANALYZE are slightly different from a traditional full scan ANALYZE has little practical impact. It is possible to construct a pathological case where an approximate ANALYZE is noticeably inferior to a full-scan ANALYZE, but such cases rare in real-world problems.

A good rule of thumb seems to be to always set "PRAGMA analysis_limit=N" for N between 100 and 1000 prior to running either "ANALYZE" or "PRAGMA optimize". The results are not quite as precise, but they are precise enough, and the fact that the results are computed so much faster means that developers are more likely to compute them. An approximate ANALYZE is better than not running ANALYZE at all.

4.1. Limitations of approximate ANALYZE

The content in the sqlite_stat4 table cannot be computed with anything less than a full scan. Hence, if a non-zero analysis limit is specified, the sqlite_stat4 table is not computed.

This page last modified on 2022-01-08 05:02:57 UTC


ATTACH DATABASE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
ATTACH DATABASE

1. Overview

attach-stmt:

ATTACH DATABASE expr AS schema-name

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

The ATTACH DATABASE statement adds another database file to the current database connection. Database files that were previously attached can be removed using the DETACH DATABASE command.

2. Details

The filename for the database to be attached is the value of the expression that occurs before the AS keyword. The filename of the database follows the same semantics as the filename argument to sqlite3_open() and sqlite3_open_v2(); the special name ":memory:" results in an in-memory database and an empty string results in a new temporary database. The filename argument can be a URI filename if URI filename processing is enable on the database connection. The default behavior is for URI filenames to be disabled, however that might change in a future release of SQLite, so application developers are advised to plan accordingly.

The name that occurs after the AS keyword is the name of the database used internally by SQLite. The schema-names 'main' and 'temp' refer to the main database and the database used for temporary tables. The main and temp databases cannot be attached or detached.

Tables in an attached database can be referred to using the syntax schema-name.table-name. If the name of the table is unique across all attached databases and the main and temp databases, then the schema-name prefix is not required. If two or more tables in different databases have the same name and the schema-name prefix is not used on a table reference, then the table chosen is the one in the database that was least recently attached.

Transactions involving multiple attached databases are atomic, assuming that the main database is not ":memory:" and the journal_mode is not WAL. If the main database is ":memory:" or if the journal_mode is WAL, then transactions continue to be atomic within each individual database file. But if the host computer crashes in the middle of a COMMIT where two or more database files are updated, some of those files might get the changes where others might not.

There is a limit, set using sqlite3_limit() and SQLITE_LIMIT_ATTACHED, to the number of databases that can be simultaneously attached to a single database connection.

This page last modified on 2022-01-08 05:02:57 UTC


SQL Comment Syntax

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
SQL Comment Syntax

comment-syntax:

-- anything-except-newline newline end-of-input /* anything-except-*/ */

Comments are not SQL commands, but can occur within the text of SQL queries passed to sqlite3_prepare_v2() and related interfaces. Comments are treated as whitespace by the parser. Comments can begin anywhere whitespace can be found, including inside expressions that span multiple lines.

SQL comments begin with two consecutive "-" characters (ASCII 0x2d) and extend up to and including the next newline character (ASCII 0x0a) or until the end of input, whichever comes first.

C-style comments begin with "/*" and extend up to and including the next "*/" character pair or until the end of input, whichever comes first. C-style comments can span multiple lines.

Comments can appear anywhere whitespace can occur, including inside expressions and in the middle of other SQL statements. Comments do not nest.

This page last modified on 2022-01-08 05:02:57 UTC


The ON CONFLICT Clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
The ON CONFLICT Clause

conflict-clause:

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE

The ON CONFLICT clause is a non-standard extension specific to SQLite that can appear in many other SQL commands. It is given its own section in this document because it is not part of standard SQL and therefore might not be familiar.

The ON CONFLICT clause described here has been a part of SQLite since before version 3.0.0 (2004-06-18). The phrase "ON CONFLICT" is also part of UPSERT, which is an extension to INSERT added in version 3.24.0 (2018-06-04). Do not confuse these two separate uses of the "ON CONFLICT" phrase.

The syntax for the ON CONFLICT clause is as shown above for the CREATE TABLE command. For the INSERT and UPDATE commands, the keywords "ON CONFLICT" are replaced by "OR" so that the syntax reads more naturally. For example, instead of "INSERT ON CONFLICT IGNORE" we have "INSERT OR IGNORE". The keywords change but the meaning of the clause is the same either way.

The ON CONFLICT clause applies to UNIQUE, NOT NULL, CHECK, and PRIMARY KEY constraints. The ON CONFLICT algorithm does not apply to FOREIGN KEY constraints. There are five conflict resolution algorithm choices: ROLLBACK, ABORT, FAIL, IGNORE, and REPLACE. The default conflict resolution algorithm is ABORT. This is what they mean:

ROLLBACK

When an applicable constraint violation occurs, the ROLLBACK resolution algorithm aborts the current SQL statement with an SQLITE_CONSTRAINT error and rolls back the current transaction. If no transaction is active (other than the implied transaction that is created on every command) then the ROLLBACK resolution algorithm works the same as the ABORT algorithm.

ABORT

When an applicable constraint violation occurs, the ABORT resolution algorithm aborts the current SQL statement with an SQLITE_CONSTRAINT error and backs out any changes made by the current SQL statement; but changes caused by prior SQL statements within the same transaction are preserved and the transaction remains active. This is the default behavior and the behavior specified by the SQL standard.

FAIL

When an applicable constraint violation occurs, the FAIL resolution algorithm aborts the current SQL statement with an SQLITE_CONSTRAINT error. But the FAIL resolution does not back out prior changes of the SQL statement that failed nor does it end the transaction. For example, if an UPDATE statement encountered a constraint violation on the 100th row that it attempts to update, then the first 99 row changes are preserved but changes to rows 100 and beyond never occur.

The FAIL behavior only works for uniqueness, NOT NULL, and CHECK constraints. A foreign key constraint violation causes an ABORT.

IGNORE

When an applicable constraint violation occurs, the IGNORE resolution algorithm skips the one row that contains the constraint violation and continues processing subsequent rows of the SQL statement as if nothing went wrong. Other rows before and after the row that contained the constraint violation are inserted or updated normally. No error is returned for uniqueness, NOT NULL, and UNIQUE constraint errors when the IGNORE conflict resolution algorithm is used. However, the IGNORE conflict resolution algorithm works like ABORT for foreign key constraint errors.

REPLACE

When a UNIQUE or PRIMARY KEY constraint violation occurs, the REPLACE algorithm deletes pre-existing rows that are causing the constraint violation prior to inserting or updating the current row and the command continues executing normally. If a NOT NULL constraint violation occurs, the REPLACE conflict resolution replaces the NULL value with the default value for that column, or if the column has no default value, then the ABORT algorithm is used. If a CHECK constraint or foreign key constraint violation occurs, the REPLACE conflict resolution algorithm works like ABORT.

When the REPLACE conflict resolution strategy deletes rows in order to satisfy a constraint, delete triggers fire if and only if recursive triggers are enabled.

The update hook is not invoked for rows that are deleted by the REPLACE conflict resolution strategy. Nor does REPLACE increment the change counter. The exceptional behaviors defined in this paragraph might change in a future release.

The algorithm specified in the OR clause of an INSERT or UPDATE overrides any algorithm specified in a CREATE TABLE. If no algorithm is specified anywhere, the ABORT algorithm is used.


Built-In Scalar SQL Functions

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
Built-In Scalar SQL Functions

1. Overview

The core functions shown below are available by default. Date & Time functions, aggregate functions, window functions, math functions, and JSON functions are documented separately. An application may define additional functions written in C and added to the database engine using the sqlite3_create_function() API.

  • abs(X)
  • changes()
  • char(X1,X2,...,XN)
  • coalesce(X,Y,...)
  • format(FORMAT,...)
  • glob(X,Y)
  • hex(X)
  • ifnull(X,Y)
  • iif(X,Y,Z)
  • instr(X,Y)
  • last_insert_rowid()
  • length(X)
  • like(X,Y)
  • like(X,Y,Z)
  • likelihood(X,Y)
  • likely(X)
  • load_extension(X)
  • load_extension(X,Y)
  • lower(X)
  • ltrim(X)
  • ltrim(X,Y)
  • max(X,Y,...)
  • min(X,Y,...)
  • nullif(X,Y)
  • printf(FORMAT,...)
  • quote(X)
  • random()
  • randomblob(N)
  • replace(X,Y,Z)
  • round(X)
  • round(X,Y)
  • rtrim(X)
  • rtrim(X,Y)
  • sign(X)
  • soundex(X)
  • sqlite_compileoption_get(N)
  • sqlite_compileoption_used(X)
  • sqlite_offset(X)
  • sqlite_source_id()
  • sqlite_version()
  • substr(X,Y)
  • substr(X,Y,Z)
  • substring(X,Y)
  • substring(X,Y,Z)
  • total_changes()
  • trim(X)
  • trim(X,Y)
  • typeof(X)
  • unhex(X)
  • unhex(X,Y)
  • unicode(X)
  • unlikely(X)
  • upper(X)
  • zeroblob(N)

2. Descriptions of built-in scalar SQL functions

abs(X)

The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL. Abs(X) returns 0.0 if X is a string or blob that cannot be converted to a numeric value. If X is the integer -9223372036854775808 then abs(X) throws an integer overflow error since there is no equivalent positive 64-bit two complement value.

changes()

The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers. The changes() SQL function is a wrapper around the sqlite3_changes64() C/C++ function and hence follows the same rules for counting changes.

char(X1,X2,...,XN)

The char(X1,X2,...,XN) function returns a string composed of characters having the unicode code point values of integers X1 through XN, respectively.

coalesce(X,Y,...)

The coalesce() function returns a copy of its first non-NULL argument, or NULL if all arguments are NULL. Coalesce() must have at least 2 arguments.

format(FORMAT,...)

The format(FORMAT,...) SQL function works like the sqlite3_mprintf() C-language function and the printf() function from the standard C library. The first argument is a format string that specifies how to construct the output string using values taken from subsequent arguments. If the FORMAT argument is missing or NULL then the result is NULL. The %n format is silently ignored and does not consume an argument. The %p format is an alias for %X. The %z format is interchangeable with %s. If there are too few arguments in the argument list, missing arguments are assumed to have a NULL value, which is translated into 0 or 0.0 for numeric formats or an empty string for %s. See the built-in printf() documentation for additional information.

glob(X,Y)

The glob(X,Y) function is equivalent to the expression "Y GLOB X". Note that the X and Y arguments are reversed in the glob() function relative to the infix GLOB operator. Y is the string and X is the pattern. So, for example, the following expressions are equivalent:

     name GLOB '*helium*'
     glob('*helium*',name)

If the sqlite3_create_function() interface is used to override the glob(X,Y) function with an alternative implementation then the GLOB operator will invoke the alternative implementation.

hex(X)

The hex() function interprets its argument as a BLOB and returns a string which is the upper-case hexadecimal rendering of the content of that blob.

If the argument X in "hex(X)" is an integer or floating point number, then "interprets its argument as a BLOB" means that the binary number is first converted into a UTF8 text representation, then that text is interpreted as a BLOB. Hence, "hex(12345678)" renders as "3132333435363738" not the binary representation of the integer value "0000000000BC614E".

See also: unhex()

ifnull(X,Y)

The ifnull() function returns a copy of its first non-NULL argument, or NULL if both arguments are NULL. Ifnull() must have exactly 2 arguments. The ifnull() function is equivalent to coalesce() with two arguments.

iif(X,Y,Z)

The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwise. The iif(X,Y,Z) function is logically equivalent to and generates the same bytecode as the CASE expression "CASE WHEN X THEN Y ELSE Z END".

instr(X,Y)

The instr(X,Y) function finds the first occurrence of string Y within string X and returns the number of prior characters plus 1, or 0 if Y is nowhere found within X. Or, if X and Y are both BLOBs, then instr(X,Y) returns one more than the number bytes prior to the first occurrence of Y, or 0 if Y does not occur anywhere within X. If both arguments X and Y to instr(X,Y) are non-NULL and are not BLOBs then both are interpreted as strings. If either X or Y are NULL in instr(X,Y) then the result is NULL.

last_insert_rowid()

The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function.

length(X)

For a string value X, the length(X) function returns the number of characters (not bytes) in X prior to the first NUL character. Since SQLite strings do not normally contain NUL characters, the length(X) function will usually return the total number of characters in the string X. For a blob value X, length(X) returns the number of bytes in the blob. If X is NULL then length(X) is NULL. If X is numeric then length(X) returns the length of a string representation of X.

Note that for strings, the length(X) function returns the character length of the string, not the byte length. The character length is the number of characters in the string. The character length is always different from the byte length for UTF-16 strings, and can be different from the byte length for UTF-8 strings if the string contains multi-byte characters.

For BLOB values, length(X) always returns the byte-length of the BLOB.

For string values, length(X) must read the entire string into memory in order to compute the character length. But for BLOB values, that is not necessary as SQLite knows how many bytes are in the BLOB. Hence, for multi-megabyte values, the length(X) function is usually much faster for BLOBs than for strings, since it does not need to load the value into memory.

like(X,Y)
like(X,Y,Z)

The like() function is used to implement the "Y LIKE X [ESCAPE Z]" expression. If the optional ESCAPE clause is present, then the like() function is invoked with three arguments. Otherwise, it is invoked with two arguments only. Note that the X and Y parameters are reversed in the like() function relative to the infix LIKE operator. X is the pattern and Y is the string to match against that pattern. Hence, the following expressions are equivalent:

     name LIKE '%neon%'
     like('%neon%',name)

The sqlite3_create_function() interface can be used to override the like() function and thereby change the operation of the LIKE operator. When overriding the like() function, it may be important to override both the two and three argument versions of the like() function. Otherwise, different code may be called to implement the LIKE operator depending on whether or not an ESCAPE clause was specified.

likelihood(X,Y)

The likelihood(X,Y) function returns argument X unchanged. The value Y in likelihood(X,Y) must be a floating point constant between 0.0 and 1.0, inclusive. The likelihood(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles during run-time (that is, during calls to sqlite3_step()). The purpose of the likelihood(X,Y) function is to provide a hint to the query planner that the argument X is a boolean that is true with a probability of approximately Y. The unlikely(X) function is short-hand for likelihood(X,0.0625). The likely(X) function is short-hand for likelihood(X,0.9375).

likely(X)

The likely(X) function returns the argument X unchanged. The likely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the likely(X) function is to provide a hint to the query planner that the argument X is a boolean value that is usually true. The likely(X) function is equivalent to likelihood(X,0.9375). See also: unlikely(X).

load_extension(X)
load_extension(X,Y)

The load_extension(X,Y) function loads SQLite extensions out of the shared library file named X using the entry point Y. The result of load_extension() is always a NULL. If Y is omitted then the default entry point name is used. The load_extension() function raises an exception if the extension fails to load or initialize correctly.

The load_extension() function will fail if the extension attempts to modify or delete an SQL function or collating sequence. The extension can add new functions or collating sequences, but cannot modify or delete existing functions or collating sequences because those functions and/or collating sequences might be used elsewhere in the currently running SQL statement. To load an extension that changes or deletes functions or collating sequences, use the sqlite3_load_extension() C-language API.

For security reasons, extension loading is disabled by default and must be enabled by a prior call to sqlite3_enable_load_extension().

lower(X)

The lower(X) function returns a copy of string X with all ASCII characters converted to lower case. The default built-in lower() function works for ASCII characters only. To do case conversions on non-ASCII characters, load the ICU extension.

ltrim(X)
ltrim(X,Y)

The ltrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the left side of X. If the Y argument is omitted, ltrim(X) removes spaces from the left side of X.

max(X,Y,...)

The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.

min(X,Y,...)

The multi-argument min() function returns the argument with the minimum value. The multi-argument min() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to min() define a collating function, then the BINARY collating function is used. Note that min() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.

nullif(X,Y)

The nullif(X,Y) function returns its first argument if the arguments are different and NULL if the arguments are the same. The nullif(X,Y) function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If neither argument to nullif() defines a collating function then the BINARY collating function is used.

printf(FORMAT,...)

The printf() SQL function is an alias for the format() SQL function. The format() SQL function was original named printf(). But the name was later changed to format() for compatibility with other database engines. The original printf() name is retained as an alias so as not to break any legacy code.

quote(X)

The quote(X) function returns the text of an SQL literal which is the value of its argument suitable for inclusion into an SQL statement. Strings are surrounded by single-quotes with escapes on interior quotes as needed. BLOBs are encoded as hexadecimal literals. Strings with embedded NUL characters cannot be represented as string literals in SQL and hence the returned string literal is truncated prior to the first NUL.

random()

The random() function returns a pseudo-random integer between -9223372036854775808 and +9223372036854775807.

randomblob(N)

The randomblob(N) function return an N-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte random blob is returned.

Hint: applications can generate globally unique identifiers using this function together with hex() and/or lower() like this:

hex(randomblob(16))

lower(hex(randomblob(16)))

replace(X,Y,Z)

The replace(X,Y,Z) function returns a string formed by substituting string Z for every occurrence of string Y in string X. The BINARY collating sequence is used for comparisons. If Y is an empty string then return X unchanged. If Z is not initially a string, it is cast to a UTF-8 string prior to processing.

round(X)
round(X,Y)

The round(X,Y) function returns a floating-point value X rounded to Y digits to the right of the decimal point. If the Y argument is omitted or negative, it is taken to be 0.

rtrim(X)
rtrim(X,Y)

The rtrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the right side of X. If the Y argument is omitted, rtrim(X) removes spaces from the right side of X.

sign(X)

The sign(X) function returns -1, 0, or +1 if the argument X is a numeric value that is negative, zero, or positive, respectively. If the argument to sign(X) is NULL or is a string or blob that cannot be losslessly converted into a number, then sign(X) returns NULL.

soundex(X)

The soundex(X) function returns a string that is the soundex encoding of the string X. The string "?000" is returned if the argument is NULL or contains no ASCII alphabetic characters. This function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX compile-time option is used when SQLite is built.

sqlite_compileoption_get(N)

The sqlite_compileoption_get() SQL function is a wrapper around the sqlite3_compileoption_get() C/C++ function. This routine returns the N-th compile-time option used to build SQLite or NULL if N is out of range. See also the compile_options pragma.

sqlite_compileoption_used(X)

The sqlite_compileoption_used() SQL function is a wrapper around the sqlite3_compileoption_used() C/C++ function. When the argument X to sqlite_compileoption_used(X) is a string which is the name of a compile-time option, this routine returns true (1) or false (0) depending on whether or not that option was used during the build.

sqlite_offset(X)

The sqlite_offset(X) function returns the byte offset in the database file for the beginning of the record from which value would be read. If X is not a column in an ordinary table, then sqlite_offset(X) returns NULL. The value returned by sqlite_offset(X) might reference either the original table or an index, depending on the query. If the value X would normally be extracted from an index, the sqlite_offset(X) returns the offset to the corresponding index record. If the value X would be extracted from the original table, then sqlite_offset(X) returns the offset to the table record.

The sqlite_offset(X) SQL function is only available if SQLite is built using the -DSQLITE_ENABLE_OFFSET_SQL_FUNC compile-time option.

sqlite_source_id()

The sqlite_source_id() function returns a string that identifies the specific version of the source code that was used to build the SQLite library. The string returned by sqlite_source_id() is the date and time that the source code was checked in followed by the SHA3-256 hash for that check-in. This function is an SQL wrapper around the sqlite3_sourceid() C interface.

sqlite_version()

The sqlite_version() function returns the version string for the SQLite library that is running. This function is an SQL wrapper around the sqlite3_libversion() C-interface.

substr(X,Y,Z)
substr(X,Y)
substring(X,Y,Z)
substring(X,Y)

The substr(X,Y,Z) function returns a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted then substr(X,Y) returns all characters through the end of the string X beginning with the Y-th. The left-most character of X is number 1. If Y is negative then the first character of the substring is found by counting from the right rather than the left. If Z is negative then the abs(Z) characters preceding the Y-th character are returned. If X is a string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.

"substring()" is an alias for "substr()" beginning with SQLite version 3.34.

total_changes()

The total_changes() function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the current database connection was opened. This function is a wrapper around the sqlite3_total_changes64() C/C++ interface.

trim(X)
trim(X,Y)

The trim(X,Y) function returns a string formed by removing any and all characters that appear in Y from both ends of X. If the Y argument is omitted, trim(X) removes spaces from both ends of X.

typeof(X)

The typeof(X) function returns a string that indicates the datatype of the expression X: "null", "integer", "real", "text", or "blob".

unhex(X)
unhex(X,Y)

The unhex(X,Y) function returns a BLOB value which is the decoding of the hexadecimal string X. If X contains any characters that are not hexadecimal digits and which are not in Y, then unhex(X,Y) returns NULL. If Y is omitted, it is understood to be an empty string and hence X must be a pure hexadecimal string. All hexadecimal digits in X must occur in pairs, with both digits of each pair beginning immediately adjacent to one another, or else unhex(X,Y) returns NULL. If either parameter X or Y is NULL, then unhex(X,Y) returns NULL. The X input may contain an arbitrary mix of upper and lower case hexadecimal digits. Hexadecimal digits in Y have no affect on the translation of X. Only characters in Y that are not hexadecimal digits are ignored in X.

See also: hex()

unicode(X)

The unicode(X) function returns the numeric unicode code point corresponding to the first character of the string X. If the argument to unicode(X) is not a string then the result is undefined.

unlikely(X)

The unlikely(X) function returns the argument X unchanged. The unlikely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the unlikely(X) function is to provide a hint to the query planner that the argument X is a boolean value that is usually not true. The unlikely(X) function is equivalent to likelihood(X, 0.0625).

upper(X)

The upper(X) function returns a copy of input string X in which all lower-case ASCII characters are converted to their upper-case equivalent.

zeroblob(N)

The zeroblob(N) function returns a BLOB consisting of N bytes of 0x00. SQLite manages these zeroblobs very efficiently. Zeroblobs can be used to reserve space for a BLOB that is later written using incremental BLOB I/O. This SQL function is implemented using the sqlite3_result_zeroblob() routine from the C/C++ interface.

This page last modified on 2023-01-27 13:42:47 UTC


CREATE INDEX

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
CREATE INDEX

1. Syntax

create-index-stmt:

CREATE UNIQUE INDEX IF NOT EXISTS schema-name . index-name ON table-name ( indexed-column ) , WHERE expr

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

indexed-column:

column-name COLLATE collation-name DESC expr ASC

The CREATE INDEX command consists of the keywords "CREATE INDEX" followed by the name of the new index, the keyword "ON", the name of a previously created table that is to be indexed, and a parenthesized list of table column names and/or expressions that are used for the index key. If the optional WHERE clause is included, then the index is a "partial index".

If the optional IF NOT EXISTS clause is present and another index with the same name already exists, then this command becomes a no-op.

There are no arbitrary limits on the number of indices that can be attached to a single table. The number of columns in an index is limited to the value set by sqlite3_limit(SQLITE_LIMIT_COLUMN,...).

Indexes are removed with the DROP INDEX command.

1.1. Unique Indexes

If the UNIQUE keyword appears between CREATE and INDEX then duplicate index entries are not allowed. Any attempt to insert a duplicate entry will result in an error.

For the purposes of unique indices, all NULL values are considered different from all other NULL values and are thus unique. This is one of the two possible interpretations of the SQL-92 standard (the language in the standard is ambiguous). The interpretation used by SQLite is the same and is the interpretation followed by PostgreSQL, MySQL, Firebird, and Oracle. Informix and Microsoft SQL Server follow the other interpretation of the standard, which is that all NULL values are equal to one another.

1.2. Indexes on Expressions

Expressions in an index may not reference other tables and may not use subqueries nor functions whose result might change (ex: random() or sqlite_version()). Expressions in an index may only refer to columns in the table that is being indexed. Indexes on expression will not work with versions of SQLite prior to version 3.9.0 (2015-10-14). See the Indexes On Expressions document for additional information about using general expressions in CREATE INDEX statements.

1.3. Descending Indexes

Each column name or expression can be followed by one of the "ASC" or "DESC" keywords to indicate sort order. The sort order may or may not be ignored depending on the database file format, and in particular the schema format number. The "legacy" schema format (1) ignores index sort order. The descending index schema format (4) takes index sort order into account. Only versions of SQLite 3.3.0 (2006-01-11) and later are able to understand the descending index format. For compatibility, version of SQLite between 3.3.0 and 3.7.9 use the legacy schema format by default. The newer schema format is used by default in version 3.7.10 (2012-01-16) and later. The legacy_file_format pragma can be used to change set the specific behavior for any version of SQLite.

1.4. NULLS FIRST and NULLS LAST

The NULLS FIRST and NULLS LAST predicates are not supported for indexes. For sorting purposes, SQLite considers NULL values to be smaller than all other values. Hence NULL values always appear at the beginning of an ASC index and at the end of a DESC index.

1.5. Collations

The COLLATE clause optionally following each column name or expression defines a collating sequence used for text entries in that column. The default collating sequence is the collating sequence defined for that column in the CREATE TABLE statement. Or if no collating sequence is otherwise defined, the built-in BINARY collating sequence is used.


CREATE TABLE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
CREATE TABLE
► Table Of Contents
1. Syntax
2. The CREATE TABLE command
2.1. CREATE TABLE ... AS SELECT Statements
3. Column Definitions
3.1. Column Data Types
3.2. The DEFAULT clause
3.3. The COLLATE clause
3.4. The GENERATED ALWAYS AS clause
3.5. The PRIMARY KEY
3.6. UNIQUE constraints
3.7. CHECK constraints
3.8. NOT NULL constraints
4. Constraint enforcement
4.1. Response to constraint violations
5. ROWIDs and the INTEGER PRIMARY KEY

1. Syntax

create-table-stmt:

CREATE TEMP TEMPORARY TABLE IF NOT EXISTS schema-name . table-name ( column-def table-constraint , ) table-options , AS select-stmt

column-def:

column-name type-name column-constraint

column-constraint:

CONSTRAINT name PRIMARY KEY DESC conflict-clause AUTOINCREMENT ASC NOT NULL conflict-clause UNIQUE conflict-clause CHECK ( expr ) DEFAULT ( expr ) literal-value signed-number COLLATE collation-name foreign-key-clause GENERATED ALWAYS AS ( expr ) VIRTUAL STORED

conflict-clause:

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

foreign-key-clause:

REFERENCES foreign-table ( column-name ) , ON DELETE SET NULL UPDATE SET DEFAULT CASCADE RESTRICT NO ACTION MATCH name NOT DEFERRABLE INITIALLY DEFERRED INITIALLY IMMEDIATE

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

signed-number:

+ numeric-literal -

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

table-constraint:

CONSTRAINT name PRIMARY KEY ( indexed-column ) conflict-clause , UNIQUE CHECK ( expr ) FOREIGN KEY ( column-name ) foreign-key-clause ,

conflict-clause:

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

foreign-key-clause:

REFERENCES foreign-table ( column-name ) , ON DELETE SET NULL UPDATE SET DEFAULT CASCADE RESTRICT NO ACTION MATCH name NOT DEFERRABLE INITIALLY DEFERRED INITIALLY IMMEDIATE

indexed-column:

column-name COLLATE collation-name DESC expr ASC

table-options:

WITHOUT ROWID STRICT ,

2. The CREATE TABLE command

The "CREATE TABLE" command is used to create a new table in an SQLite database. A CREATE TABLE command specifies the following attributes of the new table:

  • The name of the new table.

  • The database in which the new table is created. Tables may be created in the main database, the temp database, or in any attached database.

  • The name of each column in the table.

  • The declared type of each column in the table.

  • A default value or expression for each column in the table.

  • A default collation sequence to use with each column.

  • Optionally, a PRIMARY KEY for the table. Both single column and composite (multiple column) primary keys are supported.

  • A set of SQL constraints for each table. SQLite supports UNIQUE, NOT NULL, CHECK and FOREIGN KEY constraints.

  • Optionally, a generated column constraint.

  • Whether the table is a WITHOUT ROWID table.

  • Whether the table is subject to strict type checking.

Every CREATE TABLE statement must specify a name for the new table. Table names that begin with "sqlite_" are reserved for internal use. It is an error to attempt to create a table with a name that starts with "sqlite_".

If a schema-name is specified, it must be either "main", "temp", or the name of an attached database. In this case the new table is created in the named database. If the "TEMP" or "TEMPORARY" keyword occurs between the "CREATE" and "TABLE" then the new table is created in the temp database. It is an error to specify both a schema-name and the TEMP or TEMPORARY keyword, unless the schema-name is "temp". If no schema name is specified and the TEMP keyword is not present then the table is created in the main database.

It is usually an error to attempt to create a new table in a database that already contains a table, index or view of the same name. However, if the "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and a table or view of the same name already exists, the CREATE TABLE command simply has no effect (and no error message is returned). An error is still returned if the table cannot be created because of an existing index, even if the "IF NOT EXISTS" clause is specified.

It is not an error to create a table that has the same name as an existing trigger.

Tables are removed using the DROP TABLE statement.

2.1. CREATE TABLE ... AS SELECT Statements

A "CREATE TABLE ... AS SELECT" statement creates and populates a database table based on the results of a SELECT statement. The table has the same number of columns as the rows returned by the SELECT statement. The name of each column is the same as the name of the corresponding column in the result set of the SELECT statement. The declared type of each column is determined by the expression affinity of the corresponding expression in the result set of the SELECT statement, as follows:

Expression Affinity | Column Declared Type
TEXT | "TEXT"
NUMERIC | "NUM"
INTEGER | "INT"
REAL | "REAL"
BLOB (a.k.a "NONE") | "" (empty string)

A table created using CREATE TABLE AS has no PRIMARY KEY and no constraints of any kind. The default value of each column is NULL. The default collation sequence for each column of the new table is BINARY.

Tables created using CREATE TABLE AS are initially populated with the rows of data returned by the SELECT statement. Rows are assigned contiguously ascending rowid values, starting with 1, in the order that they are returned by the SELECT statement.

3. Column Definitions

Unless it is a CREATE TABLE ... AS SELECT statement, a CREATE TABLE includes one or more column definitions, optionally followed by a list of table constraints. Each column definition consists of the name of the column, optionally followed by the declared type of the column, then one or more optional column constraints. Included in the definition of "column constraints" for the purposes of the previous statement are the COLLATE and DEFAULT clauses, even though these are not really constraints in the sense that they do not restrict the data that the table may contain. The other constraints - NOT NULL, CHECK, UNIQUE, PRIMARY KEY and FOREIGN KEY constraints - impose restrictions on the table data.

The number of columns in a table is limited by the SQLITE_MAX_COLUMN compile-time parameter. A single row of a table cannot store more than SQLITE_MAX_LENGTH bytes of data. Both of these limits can be lowered at runtime using the sqlite3_limit() C/C++ interface.

3.1. Column Data Types

Unlike most SQL databases, SQLite does not restrict the type of data that may be inserted into a column based on the columns declared type. Instead, SQLite uses dynamic typing. The declared type of a column is used to determine the affinity of the column only.

3.2. The DEFAULT clause

The DEFAULT clause specifies a default value to use for the column if no value is explicitly provided by the user when doing an INSERT. If there is no explicit DEFAULT clause attached to a column definition, then the default value of the column is NULL. An explicit DEFAULT clause may specify that the default value is NULL, a string constant, a blob constant, a signed-number, or any constant expression enclosed in parentheses. A default value may also be one of the special case-independent keywords CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the DEFAULT clause, an expression is considered constant if it contains no sub-queries, column or table references, bound parameters, or string literals enclosed in double-quotes instead of single-quotes.

Each time a row is inserted into the table by an INSERT statement that does not provide explicit values for all table columns the values stored in the new row are determined by their default values, as follows:

  • If the default value of the column is a constant NULL, text, blob or signed-number value, then that value is used directly in the new row.

  • If the default value of a column is an expression in parentheses, then the expression is evaluated once for each row inserted and the results used in the new row.

  • If the default value of a column is CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP, then the value used in the new row is a text representation of the current UTC date and/or time. For CURRENT_TIME, the format of the value is "HH:MM:SS". For CURRENT_DATE, "YYYY-MM-DD". The format for CURRENT_TIMESTAMP is "YYYY-MM-DD HH:MM:SS".

3.3. The COLLATE clause

The COLLATE clause specifies the name of a collating sequence to use as the default collation sequence for the column. If no COLLATE clause is specified, the default collation sequence is BINARY.

3.4. The GENERATED ALWAYS AS clause

A column that includes a GENERATED ALWAYS AS clause is a generated column. Generated columns are supported beginning with SQLite version 3.31.0 (2020-01-22). See the separate documentation for details on the capabilities and limitations of generated columns.

3.5. The PRIMARY KEY

Each table in SQLite may have at most one PRIMARY KEY. If the keywords PRIMARY KEY are added to a column definition, then the primary key for the table consists of that single column. Or, if a PRIMARY KEY clause is specified as a table-constraint, then the primary key of the table consists of the list of columns specified as part of the PRIMARY KEY clause. The PRIMARY KEY clause must contain only column names — the use of expressions in an indexed-column of a PRIMARY KEY is not supported. An error is raised if more than one PRIMARY KEY clause appears in a CREATE TABLE statement. The PRIMARY KEY is optional for ordinary tables but is required for WITHOUT ROWID tables.

If a table has a single column primary key and the declared type of that column is "INTEGER" and the table is not a WITHOUT ROWID table, then the column is known as an INTEGER PRIMARY KEY. See below for a description of the special properties and behaviors associated with an INTEGER PRIMARY KEY.

Each row in a table with a primary key must have a unique combination of values in its primary key columns. For the purposes of determining the uniqueness of primary key values, NULL values are considered distinct from all other values, including other NULLs. If an INSERT or UPDATE statement attempts to modify the table content so that two or more rows have identical primary key values, that is a constraint violation.

According to the SQL standard, PRIMARY KEY should always imply NOT NULL. Unfortunately, due to a bug in some early versions, this is not the case in SQLite. Unless the column is an INTEGER PRIMARY KEY or the table is a WITHOUT ROWID table or a STRICT table or the column is declared NOT NULL, SQLite allows NULL values in a PRIMARY KEY column. SQLite could be fixed to conform to the standard, but doing so might break legacy applications. Hence, it has been decided to merely document the fact that SQLite allows NULLs in most PRIMARY KEY columns.

3.6. UNIQUE constraints

A UNIQUE constraint is similar to a PRIMARY KEY constraint, except that a single table may have any number of UNIQUE constraints. For each UNIQUE constraint on the table, each row must contain a unique combination of values in the columns identified by the UNIQUE constraint. For the purposes of UNIQUE constraints, NULL values are considered distinct from all other values, including other NULLs. As with PRIMARY KEYs, a UNIQUE table-constraint clause must contain only column names — the use of expressions in an indexed-column of a UNIQUE table-constraint is not supported.

In most cases, UNIQUE and PRIMARY KEY constraints are implemented by creating a unique index in the database. (The exceptions are INTEGER PRIMARY KEY and PRIMARY KEYs on WITHOUT ROWID tables.) Hence, the following schemas are logically equivalent:

  1. CREATE TABLE t1(a, b UNIQUE);

  2. CREATE TABLE t1(a, b PRIMARY KEY);

  3. CREATE TABLE t1(a, b);
    CREATE UNIQUE INDEX t1b ON t1(b);

3.7. CHECK constraints

A CHECK constraint may be attached to a column definition or specified as a table constraint. In practice it makes no difference. Each time a new row is inserted into the table or an existing row is updated, the expression associated with each CHECK constraint is evaluated and cast to a NUMERIC value in the same way as a CAST expression. If the result is zero (integer value 0 or real value 0.0), then a constraint violation has occurred. If the CHECK expression evaluates to NULL, or any other non-zero value, it is not a constraint violation. The expression of a CHECK constraint may not contain a subquery.

CHECK constraints are only verified when the table is written, not when it is read. Furthermore, verification of CHECK constraints can be temporarily disabled using the "PRAGMA ignore_check_constraints=ON;" statement. Hence, it is possible that a query might produce results that violate the CHECK constraints.

3.8. NOT NULL constraints

A NOT NULL constraint may only be attached to a column definition, not specified as a table constraint. Not surprisingly, a NOT NULL constraint dictates that the associated column may not contain a NULL value. Attempting to set the column value to NULL when inserting a new row or updating an existing one causes a constraint violation. NOT NULL constraints are not verified during queries, so a query of a column might produce a NULL value even though the column is marked as NOT NULL, if the database file is corrupt.

4. Constraint enforcement

Constraints are checked during INSERT and UPDATE and by PRAGMA integrity_check and PRAGMA quick_check and sometimes by ALTER TABLE. Queries and DELETE statements do not normally verify constraints. Hence, if a database file has been corrupted (perhaps by an external program making direct changes to the database file without going through the SQLite library) a query might return data that violates a constraint. For example:

CREATE TABLE t1(x INT CHECK( x>3 ));
/* Insert a row with X less than 3 by directly writing into the
** database file using an external program */
PRAGMA integrity_check;  -- Reports row with x less than 3 as corrupt
INSERT INTO t1(x) VALUES(2);  -- Fails with SQLITE_CORRUPT
SELECT x FROM t1;  -- Returns an integer less than 3 in spite of the CHECK constraint

Enforcement of CHECK constraints can be temporarily disabled using the PRAGMA ignore_check_constraints=ON; statement.

4.1. Response to constraint violations

The response to a constraint violation is determined by the constraint conflict resolution algorithm. Each PRIMARY KEY, UNIQUE, NOT NULL and CHECK constraint has a default conflict resolution algorithm. PRIMARY KEY, UNIQUE and NOT NULL constraints may be explicitly assigned another default conflict resolution algorithm by including a conflict-clause in their definitions. Or, if a constraint definition does not include a conflict-clause, the default conflict resolution algorithm is ABORT. The conflict resolution algorithm for CHECK constraints is always ABORT. (For historical compatibility only, table CHECK constraints are allowed to have a conflict resolution clause, but that has no effect.) Different constraints within the same table may have different default conflict resolution algorithms. See the section titled ON CONFLICT for additional information.

5. ROWIDs and the INTEGER PRIMARY KEY

Except for WITHOUT ROWID tables, all rows within SQLite tables have a 64-bit signed integer key that uniquely identifies the row within its table. This integer is usually called the "rowid". The rowid value can be accessed using one of the special case-independent names "rowid", "oid", or "_rowid_" in place of a column name. If a table contains a user defined column named "rowid", "oid" or "_rowid_", then that name always refers the explicitly declared column and cannot be used to retrieve the integer rowid value.

The rowid (and "oid" and "_rowid_") is omitted in WITHOUT ROWID tables. WITHOUT ROWID tables are only available in SQLite version 3.8.2 (2013-12-06) and later. A table that lacks the WITHOUT ROWID clause is called a "rowid table".

The data for rowid tables is stored as a B-Tree structure containing one entry for each table row, using the rowid value as the key. This means that retrieving or sorting records by rowid is fast. Searching for a record with a specific rowid, or for all records with rowids within a specified range is around twice as fast as a similar search made by specifying any other PRIMARY KEY or indexed value.

With one exception noted below, if a rowid table has a primary key that consists of a single column and the declared type of that column is "INTEGER" in any mixture of upper and lower case, then the column becomes an alias for the rowid. Such a column is usually referred to as an "integer primary key". A PRIMARY KEY column only becomes an integer primary key if the declared type name is exactly "INTEGER". Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary table column with integer affinity and a unique index, not as an alias for the rowid.

The exception mentioned above is that if the declaration of a column with declared type "INTEGER" includes an "PRIMARY KEY DESC" clause, it does not become an alias for the rowid and is not classified as an integer primary key. This quirk is not by design. It is due to a bug in early versions of SQLite. But fixing the bug could result in backwards incompatibilities. Hence, the original behavior has been retained (and documented) because odd behavior in a corner case is far better than a compatibility break. This means that the following three table declarations all cause the column "x" to be an alias for the rowid (an integer primary key):

  • CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);
  • CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC));
  • CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC));

But the following declaration does not result in "x" being an alias for the rowid:

  • CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z);

Rowid values may be modified using an UPDATE statement in the same way as any other column value can, either using one of the built-in aliases ("rowid", "oid" or "_rowid_") or by using an alias created by an integer primary key. Similarly, an INSERT statement may provide a value to use as the rowid for each row inserted. Unlike normal SQLite columns, an integer primary key or rowid column must contain integer values. Integer primary key or rowid columns are not able to hold floating point values, strings, BLOBs, or NULLs.

If an UPDATE statement attempts to set an integer primary key or rowid column to a NULL or blob value, or to a string or real value that cannot be losslessly converted to an integer, a "datatype mismatch" error occurs and the statement is aborted. If an INSERT statement attempts to insert a blob value, or a string or real value that cannot be losslessly converted to an integer into an integer primary key or rowid column, a "datatype mismatch" error occurs and the statement is aborted.

If an INSERT statement attempts to insert a NULL value into a rowid or integer primary key column, the system chooses an integer value to use as the rowid automatically. A detailed description of how this is done is provided separately.

The parent key of a foreign key constraint is not allowed to use the rowid. The parent key must used named columns only.

This page last modified on 2023-02-27 02:07:35 UTC


CREATE TRIGGER

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
CREATE TRIGGER
► Table Of Contents
1. Syntax
2. Description
2.1. Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within Triggers
3. INSTEAD OF triggers
4. Some Example Triggers
5. Cautions On The Use Of BEFORE triggers
6. The RAISE() function
7. TEMP Triggers on Non-TEMP Tables

1. Syntax

create-trigger-stmt:

CREATE TEMP TEMPORARY TRIGGER IF NOT EXISTS schema-name . trigger-name BEFORE AFTER INSTEAD OF DELETE INSERT UPDATE OF column-name , ON table-name FOR EACH ROW WHEN expr BEGIN update-stmt ; END insert-stmt delete-stmt select-stmt

delete-stmt:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name returning-clause expr WHERE

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED

returning-clause:

RETURNING expr AS column-alias * ,

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

insert-stmt:

WITH RECURSIVE common-table-expression , REPLACE INSERT OR ROLLBACK INTO ABORT FAIL IGNORE REPLACE schema-name . table-name AS alias ( column-name ) , VALUES ( expr ) , , upsert-clause select-stmt upsert-clause DEFAULT VALUES returning-clause

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

returning-clause:

RETURNING expr AS column-alias * ,

upsert-clause:

ON CONFLICT ( indexed-column ) WHERE expr DO , conflict target UPDATE SET column-name-list = expr WHERE expr NOTHING , column-name

column-name-list:

( column-name ) ,

indexed-column:

column-name COLLATE collation-name DESC expr ASC

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

update-stmt:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause

column-name-list:

( column-name ) ,

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED

returning-clause:

RETURNING expr AS column-alias * ,

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

2. Description

The CREATE TRIGGER statement is used to add triggers to the database schema. Triggers are database operations that are automatically performed when a specified database event occurs.

Each trigger must specify that it will fire for one of the following operations: DELETE, INSERT, UPDATE. The trigger fires once for each row that is deleted, inserted, or updated. If the "UPDATE OF column-name" syntax is used, then the trigger will only fire if column-name appears on the left-hand side of one of the terms in the SET clause of the UPDATE statement.

Due to an historical oversight, columns named in the "UPDATE OF" clause do not actually have to exist in the table being updated. Unrecognized column names are silently ignored. It would be more helpful if SQLite would fail the CREATE TRIGGER statement if any of the names in the "UPDATE OF" clause are not columns in the table. However, as this problem was discovered many years after SQLite was widely deployed, we have resisted fixing the problem for fear of breaking legacy applications.

At this time SQLite supports only FOR EACH ROW triggers, not FOR EACH STATEMENT triggers. Hence explicitly specifying FOR EACH ROW is optional. FOR EACH ROW implies that the SQL statements specified in the trigger may be executed (depending on the WHEN clause) for each database row being inserted, updated or deleted by the statement causing the trigger to fire.

Both the WHEN clause and the trigger actions may access elements of the row being inserted, deleted or updated using references of the form "NEW.column-name" and "OLD.column-name", where column-name is the name of a column from the table that the trigger is associated with. OLD and NEW references may only be used in triggers on events for which they are relevant, as follows:

INSERT | NEW references are valid
UPDATE | NEW and OLD references are valid
DELETE | OLD references are valid

If a WHEN clause is supplied, the SQL statements specified are only executed if the WHEN clause is true. If no WHEN clause is supplied, the SQL statements are executed every time the trigger fires.

The BEFORE or AFTER keyword determines when the trigger actions will be executed relative to the insertion, modification or removal of the associated row. BEFORE is the default when neither keyword is present.

An ON CONFLICT clause may be specified as part of an UPDATE or INSERT action within the body of the trigger. However if an ON CONFLICT clause is specified as part of the statement causing the trigger to fire, then conflict handling policy of the outer statement is used instead.

Triggers are automatically dropped when the table that they are associated with (the table-name table) is dropped. However if the trigger actions reference other tables, the trigger is not dropped or modified if those other tables are dropped or modified.

Triggers are removed using the DROP TRIGGER statement.

2.1. Syntax Restrictions On UPDATE, DELETE, and INSERT Statements Within Triggers

The UPDATE, DELETE, and INSERT statements within triggers do not support the full syntax for UPDATE, DELETE, and INSERT statements. The following restrictions apply:

  • The name of the table to be modified in an UPDATE, DELETE, or INSERT statement must be an unqualified table name. In other words, one must use just "tablename" not "database.tablename" when specifying the table.

  • For non-TEMP triggers, the table to be modified or queried must exist in the same database as the table or view to which the trigger is attached. TEMP triggers are not subject to the same-database rule. A TEMP trigger is allowed to query or modify any table in any ATTACH-ed database.

  • The "INSERT INTO table DEFAULT VALUES" form of the INSERT statement is not supported.

  • The INDEXED BY and NOT INDEXED clauses are not supported for UPDATE and DELETE statements.

  • The ORDER BY and LIMIT clauses on UPDATE and DELETE statements are not supported. ORDER BY and LIMIT are not normally supported for UPDATE or DELETE in any context but can be enabled for top-level statements using the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option. However, that compile-time option only applies to top-level UPDATE and DELETE statements, not UPDATE and DELETE statements within triggers.

  • Common table expression are not supported for statements inside of triggers.

3. INSTEAD OF triggers

BEFORE and AFTER triggers work only on ordinary tables. INSTEAD OF triggers work only on views.

If an INSTEAD OF INSERT trigger exists on a view, then it is possible to execute an INSERT statement against that view. No actual insert occurs. Instead, the statements contained within the trigger are run. INSTEAD OF DELETE and INSTEAD OF UPDATE triggers work the same way for DELETE and UPDATE statements against views.

Note that the sqlite3_changes() and sqlite3_total_changes() interfaces do not count INSTEAD OF trigger firings, but the count_changes pragma does count INSTEAD OF trigger firing.

4. Some Example Triggers

Assuming that customer records are stored in the "customers" table, and that order records are stored in the "orders" table, the following UPDATE trigger ensures that all associated orders are redirected when a customer changes his or her address:

CREATE TRIGGER update_customer_address UPDATE OF address ON customers
  BEGIN
    UPDATE orders SET address = new.address WHERE customer_name = old.name;
  END;

With this trigger installed, executing the statement:

UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones';

causes the following to be automatically executed:

UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';

For an example of an INSTEAD OF trigger, consider the following schema:

CREATE TABLE customer(
  cust_id INTEGER PRIMARY KEY,
  cust_name TEXT,
  cust_addr TEXT
);
CREATE VIEW customer_address AS
   SELECT cust_id, cust_addr FROM customer;
CREATE TRIGGER cust_addr_chng
INSTEAD OF UPDATE OF cust_addr ON customer_address
BEGIN
  UPDATE customer SET cust_addr=NEW.cust_addr
   WHERE cust_id=NEW.cust_id;
END;

With the schema above, a statement of the form:

UPDATE customer_address SET cust_addr=$new_address WHERE cust_id=$cust_id;

Causes the customer.cust_addr field to be updated for a specific customer entry that has customer.cust_id equal to the $cust_id parameter. Note how the values assigned to the view are made available as field in the special "NEW" table within the trigger body.

5. Cautions On The Use Of BEFORE triggers

If a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes a row that was to have been updated or deleted, then the result of the subsequent update or delete operation is undefined. Furthermore, if a BEFORE trigger modifies or deletes a row, then it is undefined whether or not AFTER triggers that would have otherwise run on those rows will in fact run.

The value of NEW.rowid is undefined in a BEFORE INSERT trigger in which the rowid is not explicitly set to an integer.

Because of the behaviors described above, programmers are encouraged to prefer AFTER triggers over BEFORE triggers.

6. The RAISE() function

A special SQL function RAISE() may be used within a trigger-program, with the following syntax

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

When one of RAISE(ROLLBACK,...), RAISE(ABORT,...) or RAISE(FAIL,...) is called during trigger-program execution, the specified ON CONFLICT processing is performed and the current query terminates. An error code of SQLITE_CONSTRAINT is returned to the application, along with the specified error message.

When RAISE(IGNORE) is called, the remainder of the current trigger program, the statement that caused the trigger program to execute and any subsequent trigger programs that would have been executed are abandoned. No database changes are rolled back. If the statement that caused the trigger program to execute is itself part of a trigger program, then that trigger program resumes execution at the beginning of the next step.

7. TEMP Triggers on Non-TEMP Tables

A trigger normally exists in the same database as the table named after the "ON" keyword in the CREATE TRIGGER statement. Except, it is possible to create a TEMP TRIGGER on a table in another database. Such a trigger will only fire when changes are made to the target table by the application that defined the trigger. Other applications that modify the database will not be able to see the TEMP trigger and hence cannot run the trigger.

When defining a TEMP trigger on a non-TEMP table, it is important to specify the database holding the non-TEMP table. For example, in the following statement, it is important to say "main.tab1" instead of just "tab1":

CREATE TEMP TRIGGER ex1 AFTER INSERT ON main.tab1 BEGIN ...

Failure to specify the schema name on the target table could result in the TEMP trigger being reattached to a table with the same name in another database whenever any schema change occurs.


CREATE VIEW

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
CREATE VIEW

1. Syntax

create-view-stmt:

CREATE TEMP TEMPORARY VIEW IF NOT EXISTS schema-name . view-name ( column-name ) AS select-stmt ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

2. Description

The CREATE VIEW command assigns a name to a pre-packaged SELECT statement. Once the view is created, it can be used in the FROM clause of another SELECT in place of a table name.

If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE" and "VIEW" then the view that is created is only visible to the database connection that created it and is automatically deleted when the database connection is closed.

If a schema-name is specified, then the view is created in the specified database. It is an error to specify both a schema-name and the TEMP keyword on a VIEW, unless the schema-name is "temp". If no schema name is specified, and the TEMP keyword is not present, the VIEW is created in the main database.

You cannot DELETE, INSERT, or UPDATE a view. Views are read-only in SQLite. However, in many cases you can use an INSTEAD OF trigger on the view to accomplish the same thing. Views are removed with the DROP VIEW command.

If a column-name list follows the view-name, then that list determines the names of the columns for the view. If the column-name list is omitted, then the names of the columns in the view are derived from the names of the result-set columns in the select-stmt. The use of column-name list is recommended. Or, if column-name list is omitted, then the result columns in the SELECT statement that defines the view should have well-defined names using the "AS column-alias" syntax. SQLite allows you to create views that depend on automatically generated column names, but you should avoid using them since the rules used to generate column names are not a defined part of the interface and might change in future releases of SQLite.

The column-name list syntax was added in SQLite versions 3.9.0 (2015-10-14).

This page last modified on 2022-01-08 05:02:57 UTC


CREATE VIRTUAL TABLE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
CREATE VIRTUAL TABLE

create-virtual-table-stmt:

CREATE VIRTUAL TABLE IF NOT EXISTS schema-name . table-name USING module-name ( module-argument ) ,

A virtual table is an interface to an external storage or computation engine that appears to be a table but does not actually store information in the database file.

In general, you can do anything with a virtual table that can be done with an ordinary table, except that you cannot create indices or triggers on a virtual table. Some virtual table implementations might impose additional restrictions. For example, many virtual tables are read-only.

The module-name is the name of an object that implements the virtual table. The module-name must be registered with the SQLite database connection using sqlite3_create_module() or sqlite3_create_module_v2() prior to issuing the CREATE VIRTUAL TABLE statement. The module takes zero or more comma-separated arguments. The arguments can be just about any text as long as it has balanced parentheses. The argument syntax is sufficiently general that the arguments can be made to appear as column definitions in a traditional CREATE TABLE statement. SQLite passes the module arguments directly to the xCreate and xConnect methods of the module implementation without any interpretation. It is the responsibility of the module implementation to parse and interpret its own arguments.

A virtual table is destroyed using the ordinary DROP TABLE statement. There is no DROP VIRTUAL TABLE statement.

This page last modified on 2022-01-08 05:02:57 UTC


Date And Time Functions

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
Date And Time Functions
► Table Of Contents
1. Overview
2. Time Values
3. Modifiers
4. Examples
5. Caveats And Bugs

1. Overview

SQLite supports six date and time functions as follows:

  1. date(time-value, modifier, modifier, ...)
  2. time(time-value, modifier, modifier, ...)
  3. datetime(time-value, modifier, modifier, ...)
  4. julianday(time-value, modifier, modifier, ...)
  5. unixepoch(time-value, modifier, modifier, ...)
  6. strftime(format, time-value, modifier, modifier, ...)

All six date and time functions take an optional time value as an argument, followed by zero or more modifiers. The strftime() function also takes a format string as its first argument.

Date and time values can be stored as

  • text in a subset of the ISO-8601 format,
  • numbers representing the Julian day, or
  • numbers representing the number of seconds since (or before) 1970-01-01 00:00:00 UTC (the unix timestamp).

All of the date time functions access time-values in any of the above time formats.

The date() function returns the date as text in this format: YYYY-MM-DD.

The time() function returns the time as text in this format: HH:MM:SS.

The datetime() function returns the date and time as text in this formats: YYYY-MM-DD HH:MM:SS.

The julianday() function returns the Julian day - the fractional number of days since noon in Greenwich on November 24, 4714 B.C. (Proleptic Gregorian calendar).

The unixepoch() function returns a unix timestamp - the number of seconds since 1970-01-01 00:00:00 UTC. The unixepoch() function normally returns an integer number of seconds, but with the optional subsec modifier it will return a floating point number which is the fractional number of seconds.

The strftime() routine returns the date formatted according to the format string specified as the first argument. The format string supports the most common substitutions found in the strftime() function from the standard C library plus two new substitutions, %f and %J. The following is a complete list of valid strftime() substitutions:

%d | day of month: 00
%f | fractional seconds: SS.SSS
%H | hour: 00-24
%j | day of year: 001-366
%J | Julian day number (fractional)
%m | month: 01-12
%M | minute: 00-59
%s | seconds since 1970-01-01
%S | seconds: 00-59
%w | day of week 0-6 with Sunday==0
%W | week of year: 00-53
%Y | year: 0000-9999
%% %

All other date and time functions can be expressed in terms of strftime():

Function | Equivalent (or nearly) strftime()
date(...) | strftime('%Y-%m-%d', ...)
time(...) | strftime('%H:%M:%S', ...)
datetime(...) | strftime('%Y-%m-%d %H:%M:%S', ...)
julianday(...) | strftime('%J', ...) -- (numeric return)
unixepoch(...) | strftime('%s', ...) -- (numeric return)

The date(), time(), and datetime() functions all return text, and so their strftime() equivalents are exact. However, the julianday() and unixepoch() functions return numeric values. Their strftime() equivalents return a string that is the text representation of the corresponding number.

The main reasons for providing functions other than strftime() are for convenience and for efficiency. The julianday() and unixepoch() functions return real and integer values respectively, and do not incur the format conversion costs or inexactitude resulting from use of the '%J' or '%s' format specifiers with the strftime() function.

2. Time Values

A time value can be in any of the following formats shown below. The value is usually a string, though it can be an integer or floating point number in the case of format 12.

  1. YYYY-MM-DD
  2. YYYY-MM-DD HH:MM
  3. YYYY-MM-DD HH:MM:SS
  4. YYYY-MM-DD HH:MM:SS.SSS
  5. YYYY-MM-DD T HH:MM
  6. YYYY-MM-DD T HH:MM:SS
  7. YYYY-MM-DD T HH:MM:SS.SSS
  8. HH:MM
  9. HH:MM:SS
  10. HH:MM:SS.SSS
  11. now
  12. DDDDDDDDDD

In formats 5 through 7, the "T" is a literal character separating the date and the time, as required by ISO-8601. Formats 8 through 10 that specify only a time assume a date of 2000-01-01. Format 11, the string 'now', is converted into the current date and time as obtained from the xCurrentTime method of the sqlite3_vfs object in use. The 'now' argument to date and time functions always returns exactly the same value for multiple invocations within the same sqlite3_step() call. Universal Coordinated Time (UTC) is used. Format 12 is the Julian day number expressed as an integer or floating point value. Format 12 might also be interpreted as a unix timestamp if it is immediately followed either the 'auto' or 'unixepoch' modifier.

Formats 2 through 10 may be optionally followed by a timezone indicator of the form "[+-]HH:MM" or just "Z". The date and time functions use UTC or "zulu" time internally, and so the "Z" suffix is a no-op. Any non-zero "HH:MM" suffix is subtracted from the indicated date and time in order to compute zulu time. For example, all of the following time values are equivalent:

2013-10-07 08:23:19.120
2013-10-07T08:23:19.120Z
2013-10-07 04:23:19.120-04:00
2456572.84952685

In formats 4, 7, and 10, the fractional seconds value SS.SSS can have one or more digits following the decimal point. Exactly three digits are shown in the examples because only the first three digits are significant to the result, but the input string can have fewer or more than three digits and the date/time functions will still operate correctly. Similarly, format 12 is shown with 10 significant digits, but the date/time functions will really accept as many or as few digits as are necessary to represent the Julian day number.

The time-value (and all modifiers) may be omitted, in which case a time value of 'now' is assumed.

3. Modifiers

The time value can be followed by zero or more modifiers that alter date and/or time. Each modifier is a transformation that is applied to the time value to its left. Modifiers are applied from left to right; order is important. The available modifiers are as follows.

  1. NNN days
  2. NNN hours
  3. NNN minutes
  4. NNN.NNNN seconds
  5. NNN months
  6. NNN years
  7. start of month
  8. start of year
  9. start of day
  10. weekday N
  11. unixepoch
  12. julianday
  13. auto
  14. localtime
  15. utc
  16. subsec
  17. subsecond

The first six modifiers (1 through 6) simply add the specified amount of time to the date and time specified by the arguments to the left. The 's' character at the end of the modifier names is optional. Note that "±NNN months" works by rendering the original date into the YYYY-MM-DD format, adding the ±NNN to the MM month value, then normalizing the result. Thus, for example, the date 2001-03-31 modified by '+1 month' initially yields 2001-04-31, but April only has 30 days so the date is normalized to 2001-05-01. A similar effect occurs when the original date is February 29 of a leapyear and the modifier is ±N years where N is not a multiple of four.

The "start of" modifiers (7 through 9) shift the date backwards to the beginning of the subject month, year or day.

The "weekday" modifier advances the date forward, if necessary, to the next date where the weekday number is N. Sunday is 0, Monday is 1, and so forth. If the date is already on the desired weekday, the "weekday" modifier leaves the date unchanged.

The "unixepoch" modifier (11) only works if it immediately follows a time value in the DDDDDDDDDD format. This modifier causes the DDDDDDDDDD to be interpreted not as a Julian day number as it normally would be, but as Unix Time - the number of seconds since 1970. If the "unixepoch" modifier does not follow a time value of the form DDDDDDDDDD which expresses the number of seconds since 1970 or if other modifiers separate the "unixepoch" modifier from prior DDDDDDDDDD then the behavior is undefined. For SQLite versions before 3.16.0 (2017-01-02), the "unixepoch" modifier only works for dates between 0000-01-01 00:00:00 and 5352-11-01 10:52:47 (unix times of -62167219200 through 106751991167).

The "julianday" modifier must immediately follow the initial time-value which must be of the form DDDDDDDDD. Any other use of the 'julianday' modifier is an error and causes the function to return NULL. The 'julianday' modifier forces the time-value number to be interpreted as a julian-day number. As this is the default behavior, the 'julianday' modifier is scarcely more than a no-op. The only difference is that adding 'julianday' forces the DDDDDDDDD time-value format, and causes a NULL to be returned if any other time-value format is used.

The "auto" modifier must immediately follow the initial time-value. If the time-value is numeric (the DDDDDDDDDD format) then the 'auto' modifier causes the time-value to interpreted as either a julian day number or a unix timestamp, depending on its magnitude. If the value is between 0.0 and 5373484.499999, then it is interpreted as a julian day number (corresponding to dates between -4713-11-24 12:00:00 and 9999-12-31 23:59:59, inclusive). For numeric values outside of the range of valid julian day numbers, but within the range of -210866760000 to 253402300799, the 'auto' modifier causes the value to be interpreted as a unix timestamp. Other numeric values are out of range and cause a NULL return. The 'auto' modifier is a no-op for text time-values.

The 'auto' modifier can be used to work with date/time values even in cases where it is not known if the julian day number or unix timestamp formats are in use. The 'auto' modifier will automatically select the appropriate format. However, there is a region of ambiguity. Unix timestamps for the first 63 days of 1970 will be interpreted as julian day numbers. The 'auto' modifier is very useful when the dataset is guaranteed to not contain any dates within that region, but should be avoided for applications that might make use of dates in the opening months of 1970.

The "localtime" modifier (14) assumes the time value to its left is in Universal Coordinated Time (UTC) and adjusts that time value so that it is in localtime. If "localtime" follows a time that is not UTC, then the behavior is undefined. The "utc" modifier is the opposite of "localtime". "utc" assumes that the time value to its left is in the local timezone and adjusts that time value to be in UTC. If the time to the left is not in localtime, then the result of "utc" is undefined.

The "subsecond" modifier (which may be abbreviated as just "subsec") increases the resolution of the output for datetime(), time(), and unixepoch(), and for the "%s" format string in strftime(). The "subsecond" modifier has no effect on other date/time functions. The current implemention increases the resolution from seconds to milliseconds, but this might increase to a higher resolution in future releases of SQLite. When "subsec" is used with datetime() or time(), the seconds field at the end is followed by a decimal point and one or more digits to show fractional seconds. When "subsec" is used with unixepoch(), the result is a floating point value which is the number of seconds and fractional seconds since 1970-01-01.

The "subsecond" and "subsec" modifiers have the special property that they can occur as the first argument to date/time functions (or as the first argument after the format string for strftime()). When this occurs, the time value that is normally in the first argument is understood to be "now". For example, a short cut to get the current time in seconds since 1970 with millisecond precision is to say:

SELECT unixepoch('subsec');

4. Examples

Compute the current date.

SELECT date();

Compute the last day of the current month.

SELECT date('now','start of month','+1 month','-1 day');

Compute the date and time given a unix timestamp 1092941466.

SELECT datetime(1092941466, 'unixepoch');
SELECT datetime(1092941466, 'auto'); -- Does not work for early 1970!

Compute the date and time given a unix timestamp 1092941466, and compensate for your local timezone.

SELECT datetime(1092941466, 'unixepoch', 'localtime');

Compute the current unix timestamp.

SELECT unixepoch();
SELECT strftime('%s');

Compute the number of days since the signing of the US Declaration of Independence.

SELECT julianday('now') - julianday('1776-07-04');

Compute the number of seconds since a particular moment in 2004:

SELECT unixepoch() - unixepoch('2004-01-01 02:34:56');

Compute the date of the first Tuesday in October for the current year.

SELECT date('now','start of year','+9 months','weekday 2');

Compute the time since the unix epoch in seconds with millisecond precision:

SELECT (julianday('now') - 2440587.5)*86400.0;

5. Caveats And Bugs

The computation of local time depends heavily on the whim of politicians and is thus difficult to get correct for all locales. In this implementation, the standard C library function localtime_r() is used to assist in the calculation of local time. The localtime_r() C function normally only works for years between 1970 and 2037. For dates outside this range, SQLite attempts to map the year into an equivalent year within this range, do the calculation, then map the year back.

These functions only work for dates between 0000-01-01 00:00:00 and 9999-12-31 23:59:59 (julian day numbers 1721059.5 through 5373484.5). For dates outside that range, the results of these functions are undefined.

Non-Vista Windows platforms only support one set of DST rules. Vista only supports two. Therefore, on these platforms, historical DST calculations will be incorrect. For example, in the US, in 2007 the DST rules changed. Non-Vista Windows platforms apply the new 2007 DST rules to all previous years as well. Vista does somewhat better getting results correct back to 1986, when the rules were also changed.

All internal computations assume the Gregorian calendar system. They also assume that every day is exactly 86400 seconds in duration; no leap seconds are incorporated.

This page last modified on 2023-05-04 20:20:12 UTC


DELETE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
DELETE
► Table Of Contents
1. Overview
2. Restrictions on DELETE Statements Within CREATE TRIGGER
3. Optional LIMIT and ORDER BY clauses
4. The Truncate Optimization

1. Overview

delete-stmt:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name returning-clause expr WHERE

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED

returning-clause:

RETURNING expr AS column-alias * ,

The DELETE command removes records from the table identified by the qualified-table-name.

If the WHERE clause is not present, all records in the table are deleted. If a WHERE clause is supplied, then only those rows for which the WHERE clause boolean expression is true are deleted. Rows for which the expression is false or NULL are retained.

2. Restrictions on DELETE Statements Within CREATE TRIGGER

The following restrictions apply to DELETE statements that occur within the body of a CREATE TRIGGER statement:

  • The table-name specified as part of a DELETE statement within a trigger body must be unqualified. In other words, the schema-name. prefix on the table name is not allowed within triggers. If the table to which the trigger is attached is not in the temp database, then DELETE statements within the trigger body must operate on tables within the same database as it. If the table to which the trigger is attached is in the TEMP database, then the unqualified name of the table being deleted is resolved in the same way as it is for a top-level statement (by searching first the TEMP database, then the main database, then any other databases in the order they were attached).

  • The INDEXED BY and NOT INDEXED clauses are not allowed on DELETE statements within triggers.

  • The LIMIT and ORDER BY clauses (described below) are unsupported for DELETE statements within triggers.

  • The RETURNING clause is not supported for triggers.

3. Optional LIMIT and ORDER BY clauses

If SQLite is compiled with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option, then the syntax of the DELETE statement is extended by the addition of optional ORDER BY and LIMIT clauses:

delete-stmt-limited:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name WHERE expr returning-clause ORDER BY ordering-term , LIMIT expr OFFSET expr , expr

If a DELETE statement has a LIMIT clause, the maximum number of rows that will be deleted is found by evaluating the accompanying expression and casting it to an integer value. If the result of the evaluating the LIMIT clause cannot be losslessly converted to an integer value, it is an error. A negative LIMIT value is interpreted as "no limit". If the DELETE statement also has an OFFSET clause, then it is similarly evaluated and cast to an integer value. Again, it is an error if the value cannot be losslessly converted to an integer. If there is no OFFSET clause, or the calculated integer value is negative, the effective OFFSET value is zero.

If the DELETE statement has an ORDER BY clause, then all rows that would be deleted in the absence of the LIMIT clause are sorted according to the ORDER BY. The first M rows, where M is the value found by evaluating the OFFSET clause expression, are skipped, and the following N, where N is the value of the LIMIT expression, are deleted. If there are less than N rows remaining after taking the OFFSET clause into account, or if the LIMIT clause evaluated to a negative value, then all remaining rows are deleted.

If the DELETE statement has no ORDER BY clause, then all rows that would be deleted in the absence of the LIMIT clause are assembled in an arbitrary order before applying the LIMIT and OFFSET clauses to determine the subset that are actually deleted.

The ORDER BY clause on a DELETE statement is used only to determine which rows fall within the LIMIT. The order in which rows are deleted is arbitrary and is not influenced by the ORDER BY clause. This means that if there is a RETURNING clause, the rows returned by the statement probably will not be in the order specified by the ORDER BY clause.

4. The Truncate Optimization

When the WHERE clause and RETURNING clause are both omitted from a DELETE statement and the table being deleted has no triggers, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individually. This "truncate" optimization makes the delete run much faster. Prior to SQLite version 3.6.5 (2008-11-12), the truncate optimization also meant that the sqlite3_changes() and sqlite3_total_changes() interfaces and the count_changes pragma will not actually return the number of deleted rows. That problem has been fixed as of version 3.6.5 (2008-11-12).

The truncate optimization can be permanently disabled for all queries by recompiling SQLite with the SQLITE_OMIT_TRUNCATE_OPTIMIZATION compile-time switch.

The truncate optimization can also be disabled at runtime using the sqlite3_set_authorizer() interface. If an authorizer callback returns SQLITE_IGNORE for an SQLITE_DELETE action code, then the DELETE operation will proceed but the truncate optimization will be bypassed and rows will be deleted one by one.

This page last modified on 2022-01-08 05:02:57 UTC


DETACH

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
DETACH

detach-stmt:

DETACH DATABASE schema-name

This statement detaches an additional database connection previously attached using the ATTACH statement. When not in shared cache mode, it is possible to have the same database file attached multiple times using different names, and detaching one connection to a file will leave the others intact.

In shared cache mode, attempting to attach the same database file more than once results in an error.

This page last modified on 2022-01-08 05:02:57 UTC


DROP INDEX

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
DROP INDEX

drop-index-stmt:

DROP INDEX IF EXISTS schema-name . index-name

The DROP INDEX statement removes an index added with the CREATE INDEX statement. The index is completely removed from the disk. The only way to recover the index is to reenter the appropriate CREATE INDEX command.

This page last modified on 2022-01-08 05:02:57 UTC


DROP TABLE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
DROP TABLE

drop-table-stmt:

DROP TABLE IF EXISTS schema-name . table-name

The DROP TABLE statement removes a table added with the CREATE TABLE statement. The name specified is the table name. The dropped table is completely removed from the database schema and the disk file. The table can not be recovered. All indices and triggers associated with the table are also deleted.

The optional IF EXISTS clause suppresses the error that would normally result if the table does not exist.

If foreign key constraints are enabled, a DROP TABLE command performs an implicit DELETE FROM command before removing the table from the database schema. Any triggers attached to the table are dropped from the database schema before the implicit DELETE FROM is executed, so this cannot cause any triggers to fire. By contrast, an implicit DELETE FROM does cause any configured foreign key actions to take place. If the implicit DELETE FROM executed as part of a DROP TABLE command violates any immediate foreign key constraints, an error is returned and the table is not dropped. If the implicit DELETE FROM causes any deferred foreign key constraints to be violated, and the violations still exist when the transaction is committed, an error is returned at the time of commit.

This page last modified on 2022-01-08 05:02:57 UTC


DROP TRIGGER

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

drop-trigger-stmt:

DROP TRIGGER IF EXISTS schema-name . trigger-name

The DROP TRIGGER statement removes a trigger created by the CREATE TRIGGER statement. Once removed, the trigger definition is no longer present in the sqlite_schema (or sqlite_temp_schema) table and is not fired by any subsequent INSERT, UPDATE or DELETE statements.

Note that triggers are automatically dropped when the associated table is dropped.

This page last modified on 2022-01-08 05:02:57 UTC


DROP VIEW

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
DROP VIEW

drop-view-stmt:

DROP VIEW IF EXISTS schema-name . view-name

The DROP VIEW statement removes a view created by the CREATE VIEW statement. The view definition is removed from the database schema, but no actual data in the underlying base tables is modified.

The view to drop is identified by the view-name and optional schema-name specified as part of the DROP VIEW statement. This reference is resolved using the standard procedure for object resolution.

If the specified view cannot be found and the IF EXISTS clause is not present, it is an error. If the specified view cannot be found and an IF EXISTS clause is present in the DROP VIEW statement, then the statement is a no-op.

This page last modified on 2022-01-08 05:02:57 UTC


EXPLAIN

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
EXPLAIN

1. Syntax

sql-stmt:

EXPLAIN QUERY PLAN alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt

2. Description

An SQL statement can be preceded by the keyword "EXPLAIN" or by the phrase "EXPLAIN QUERY PLAN". Either modification causes the SQL statement to behave as a query and to return information about how the SQL statement would have operated if the EXPLAIN keyword or phrase had been omitted.

The output from EXPLAIN and EXPLAIN QUERY PLAN is intended for interactive analysis and troubleshooting only. The details of the output format are subject to change from one release of SQLite to the next. Applications should not use EXPLAIN or EXPLAIN QUERY PLAN since their exact behavior is variable and only partially documented.

When the EXPLAIN keyword appears by itself it causes the statement to behave as a query that returns the sequence of virtual machine instructions it would have used to execute the command had the EXPLAIN keyword not been present. When the EXPLAIN QUERY PLAN phrase appears, the statement returns high-level information regarding the query plan that would have been used.

The EXPLAIN QUERY PLAN command is described in more detail here.

2.1. EXPLAIN operates at run-time, not at prepare-time

The EXPLAIN and EXPLAIN QUERY PLAN prefixes affect the behavior of running a prepared statement using sqlite3_step(). The process of generating a new prepared statement using sqlite3_prepare() or similar is (mostly) unaffected by EXPLAIN. (The exception to the previous sentence is that some special opcodes used by EXPLAIN QUERY PLAN are omitted when building an EXPLAIN QUERY PLAN prepared statement, as a performance optimization.)

This means that actions that occur during sqlite3_prepare() are unaffected by EXPLAIN.

  • Some PRAGMA statements do their work during sqlite3_prepare() rather than during sqlite3_step(). Those PRAGMA statements are unaffected by EXPLAIN. They operate the same with or without the EXPLAIN prefix. The set of PRAGMA statements that are unaffected by EXPLAIN can vary from one release to the next. Some PRAGMA statements operate during sqlite3_prepare() depending on their arguments. For consistent results, avoid using EXPLAIN on PRAGMA statements.

  • The authorizer callback is invoked regardless of the presence of EXPLAIN or EXPLAIN QUERY PLAN.

This page last modified on 2022-01-08 05:02:57 UTC


SQL Language Expressions

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
SQL Language Expressions
► Table Of Contents
1. Syntax
2. Operators, and Parse-Affecting Attributes
3. Literal Values (Constants)
4. Parameters
5. The LIKE, GLOB, REGEXP, MATCH, and extract operators
6. The BETWEEN operator
7. The CASE expression
8. The IN and NOT IN operators
9. Table Column Names
10. The EXISTS operator
11. Subquery Expressions
12. Correlated Subqueries
13. CAST expressions
14. Boolean Expressions
15. Functions

1. Syntax

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

2. Operators, and Parse-Affecting Attributes

SQLite understands these operators, listed in precedence1 order
(top to bottom / highest to lowest):

Operators 2
~ [expr] + [expr] - [expr]
[expr] COLLATE (collation-name) 3
|| -> ->>
* / %
+ -
&  | <<  >>
[expr] ESCAPE [escape-character-expr] 4
< > <= >=
= == <> != IS IS NOT
IS DISTINCT FROM IS NOT DISTINCT FROM
[expr] BETWEEN5 [expr] AND [expr]
IN5 MATCH5 LIKE5 REGEXP5 GLOB5
[expr] ISNULL [expr] NOTNULL [expr] NOT NULL
NOT [expr]
AND
OR

  1. Operators shown within the same table cell share precedence.
  2. "[expr]" denotes operand locations for non-binary operators.
    Operators with no "[expr]" adjunct are binary and left-associative.
  3. The COLLATE clause (with its collation-name) acts as a single postfix operator.
  4. The ESCAPE clause (with its escape character) acts as a single postfix operator.
    It can only bind to a preceding [expr] LIKE [expr] expression.
  5. Each keyword in (BETWEEN IN GLOB LIKE MATCH REGEXP) may be prefixed
    by NOT, retaining the bare operator's precedence and associativity.

The COLLATE operator is a unary postfix operator that assigns a collating sequence to an expression. The collating sequence set by the COLLATE operator overrides the collating sequence determined by the COLLATE clause in a table column definition. See the detailed discussion on collating sequences in the Datatype In SQLite3 document for additional information.

The unary operator + is a no-op. It can be applied to strings, numbers, blobs or NULL and it always returns a result with the same value as the operand.

Note that there are two variations of the equals and not equals operators. Equals can be either = or ==. The not-equal operator can be either != or <>. The || operator is "concatenate" - it joins together the two strings of its operands. The -> and ->> operators are "extract"; they extract the RHS component from the LHS. For an example, see JSON subcomponent extraction.

The % operator casts both of its operands to type INTEGER and then computes the remainder after dividing the left integer by the right integer. The other arithmetic operators perform integer arithmetic if both operands are integers and no overflow would result, or floating point arithmetic, per IEEE Standard 754, if either operand is a real value or integer arithmetic would produce an overflow. Integer divide yields an integer result, truncated toward zero.

The result of any binary operator is either a numeric value or NULL, except for the || concatenation operator, and the -> and ->> extract operators which evaluate to either NULL or a text value.

All operators generally evaluate to NULL when any operand is NULL, with specific exceptions as stated below. This is in accordance with the SQL92 standard.

When paired with NULL:
AND evaluates to 0 (false) when the other operand is false; and
OR evaluates to 1 (true) when the other operand is true.

The IS and IS NOT operators work like = and != except when one or both of the operands are NULL. In this case, if both operands are NULL, then the IS operator evaluates to 1 (true) and the IS NOT operator evaluates to 0 (false). If one operand is NULL and the other is not, then the IS operator evaluates to 0 (false) and the IS NOT operator is 1 (true). It is not possible for an IS or IS NOT expression to evaluate to NULL.

The IS NOT DISTINCT FROM operator is an alternative spelling for the IS operator. Likewise, the IS DISTINCT FROM operator means the same thing as IS NOT. Standard SQL does not support the compact IS and IS NOT notation. Those compact forms are an SQLite extension. You have to use the prolix and much less readable IS NOT DISTINCT FROM and IS DISTINCT FROM operators on other SQL database engines.

3. Literal Values (Constants)

A literal value represents a constant. Literal values may be integers, floating point numbers, strings, BLOBs, or NULLs.

The syntax for integer and floating point literals (collectively "numeric literals") is shown by the following diagram:

numeric-literal:

digit . E e digit . digit - digit + 0x hexdigit

If a numeric literal has a decimal point or an exponentiation clause or if it is less than -9223372036854775808 or greater than 9223372036854775807, then it is a floating point literal. Otherwise is it is an integer literal. The "E" character that begins the exponentiation clause of a floating point literal can be either upper or lower case. The "." character is always used as the decimal point even if the locale setting specifies "," for this role - the use of "," for the decimal point would result in syntactic ambiguity.

Hexadecimal integer literals follow the C-language notation of "0x" or "0X" followed by hexadecimal digits. For example, 0x1234 means the same as 4660 and 0x8000000000000000 means the same as -9223372036854775808. Hexadecimal integer literals are interpreted as 64-bit two's-complement integers and are thus limited to sixteen significant digits of precision. Support for hexadecimal integers was added to SQLite version 3.8.6 (2014-08-15). For backwards compatibility, the "0x" hexadecimal integer notation is only understood by the SQL language parser, not by the type conversions routines. String variables that contain text formatted like hexadecimal integers are not interpreted as hexadecimal integers when coercing the string value into an integer due to a CAST expression or for a column affinity transformation or prior to performing a numeric operation or for any other run-time conversions. When coercing a string value in the format of a hexadecimal integer into an integer value, the conversion process stops when the 'x' character is seen so the resulting integer value is always zero. SQLite only understands the hexadecimal integer notation when it appears in the SQL statement text, not when it appears as part of the content of the database.

A string constant is formed by enclosing the string in single quotes ('). A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal. C-style escapes using the backslash character are not supported because they are not standard SQL.

BLOB literals are string literals containing hexadecimal data and preceded by a single "x" or "X" character. Example: X'53514C697465'

A literal value can also be the token "NULL".

4. Parameters

A "variable" or "parameter" token specifies a placeholder in the expression for a value that is filled in at runtime using the sqlite3_bind() family of C/C++ interfaces. Parameters can take several forms:

?NNN | A question mark followed by a number NNN holds a spot for the NNN-th parameter. NNN must be between 1 and SQLITE_MAX_VARIABLE_NUMBER.
? A question mark that is not followed by a number creates a parameter with a number one greater than the largest parameter number already assigned. If this means the parameter number is greater than SQLITE_MAX_VARIABLE_NUMBER, it is an error. This parameter format is provided for compatibility with other database engines. But because it is easy to miscount the question marks, the use of this parameter format is discouraged. Programmers are encouraged to use one of the symbolic formats below or the ?NNN format above instead.
:AAAA | A colon followed by an identifier name holds a spot for a named parameter with the name :AAAA. Named parameters are also numbered. The number assigned is one greater than the largest parameter number already assigned. If this means the parameter would be assigned a number greater than SQLITE_MAX_VARIABLE_NUMBER, it is an error. To avoid confusion, it is best to avoid mixing named and numbered parameters.
@AAAA | An "at" sign works exactly like a colon, except that the name of the parameter created is @AAAA.
$AAAA | A dollar-sign followed by an identifier name also holds a spot for a named parameter with the name $AAAA. The identifier name in this case can include one or more occurrences of "::" and a suffix enclosed in "(...)" containing any text at all. This syntax is the form of a variable name in the Tcl programming language. The presence of this syntax results from the fact that SQLite is really a Tcl extension that has escaped into the wild.

Parameters that are not assigned values using sqlite3_bind() are treated as NULL. The sqlite3_bind_parameter_index() interface can be used to translate a symbolic parameter name into its equivalent numeric index.

The maximum parameter number is set at compile-time by the SQLITE_MAX_VARIABLE_NUMBER macro. An individual database connection D can reduce its maximum parameter number below the compile-time maximum using the sqlite3_limit(D, SQLITE_LIMIT_VARIABLE_NUMBER,...) interface.

5. The LIKE, GLOB, REGEXP, MATCH, and extract operators

The LIKE operator does a pattern matching comparison. The operand to the right of the LIKE operator contains the pattern and the left hand operand contains the string to match against the pattern. A percent symbol ("%") in the LIKE pattern matches any sequence of zero or more characters in the string. An underscore ("_") in the LIKE pattern matches any single character in the string. Any other character matches itself or its lower/upper case equivalent (i.e. case-insensitive matching). Important Note: SQLite only understands upper/lower case for ASCII characters by default. The LIKE operator is case sensitive by default for unicode characters that are beyond the ASCII range. For example, the expression 'a' LIKE 'A' is TRUE but 'æ' LIKE 'Æ' is FALSE. The ICU extension to SQLite includes an enhanced version of the LIKE operator that does case folding across all unicode characters.

If the optional ESCAPE clause is present, then the expression following the ESCAPE keyword must evaluate to a string consisting of a single character. This character may be used in the LIKE pattern to include literal percent or underscore characters. The escape character followed by a percent symbol (%), underscore (_), or a second instance of the escape character itself matches a literal percent symbol, underscore, or a single escape character, respectively.

The infix LIKE operator is implemented by calling the application-defined SQL functions like(Y,X) or like(Y,X,Z).

The LIKE operator can be made case sensitive using the case_sensitive_like pragma.

The GLOB operator is similar to LIKE but uses the Unix file globbing syntax for its wildcards. Also, GLOB is case sensitive, unlike LIKE. Both GLOB and LIKE may be preceded by the NOT keyword to invert the sense of the test. The infix GLOB operator is implemented by calling the function glob(Y,X) and can be modified by overriding that function.

The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If an application-defined SQL function named "regexp" is added at run-time, then the "X REGEXP Y" operator will be implemented as a call to "regexp(Y,X)".

The MATCH operator is a special syntax for the match() application-defined function. The default match() function implementation raises an exception and is not really useful for anything. But extensions can override the match() function with more helpful logic.

The extract operators act as a special syntax for functions "->"() and "->>"(). Default implementations for these functions perform JSON subcomponent extraction, but extensions can override them for other purposes.

6. The BETWEEN operator

The BETWEEN operator is logically equivalent to a pair of comparisons. "x BETWEEN y AND z" is equivalent to "x>=y AND x<=z" except that with BETWEEN, the x expression is only evaluated once.

7. The CASE expression

A CASE expression serves a role similar to IF-THEN-ELSE in other programming languages.

The optional expression that occurs in between the CASE keyword and the first WHEN keyword is called the "base" expression. There are two fundamental forms of the CASE expression: those with a base expression and those without.

In a CASE without a base expression, each WHEN expression is evaluated and the result treated as a boolean, starting with the leftmost and continuing to the right. The result of the CASE expression is the evaluation of the THEN expression that corresponds to the first WHEN expression that evaluates to true. Or, if none of the WHEN expressions evaluate to true, the result of evaluating the ELSE expression, if any. If there is no ELSE expression and none of the WHEN expressions are true, then the overall result is NULL.

A NULL result is considered untrue when evaluating WHEN terms.

In a CASE with a base expression, the base expression is evaluated just once and the result is compared against the evaluation of each WHEN expression from left to right. The result of the CASE expression is the evaluation of the THEN expression that corresponds to the first WHEN expression for which the comparison is true. Or, if none of the WHEN expressions evaluate to a value equal to the base expression, the result of evaluating the ELSE expression, if any. If there is no ELSE expression and none of the WHEN expressions produce a result equal to the base expression, the overall result is NULL.

When comparing a base expression against a WHEN expression, the same collating sequence, affinity, and NULL-handling rules apply as if the base expression and WHEN expression are respectively the left- and right-hand operands of an = operator.

If the base expression is NULL then the result of the CASE is always the result of evaluating the ELSE expression if it exists, or NULL if it does not.

Both forms of the CASE expression use lazy, or short-circuit, evaluation.

The only difference between the following two CASE expressions is that the x expression is evaluated exactly once in the first example but might be evaluated multiple times in the second:

  • CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END

  • CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END

The built-in iif(x,y,z) SQL function is logically equivalent to "CASE WHEN x THEN y ELSE z END". The iif() function is found in SQL Server and is included in SQLite for compatibility. Some developers prefer the iif() function because it is more concise.

8. The IN and NOT IN operators

The IN and NOT IN operators take an expression on the left and a list of values or a subquery on the right. When the right operand of an IN or NOT IN operator is a subquery, the subquery must have the same number of columns as there are columns in the row value of the left operand. The subquery on the right of an IN or NOT IN operator must be a scalar subquery if the left expression is not a row value expression. If the right operand of an IN or NOT IN operator is a list of values, each of those values must be scalars and the left expression must also be a scalar. The right-hand side of an IN or NOT IN operator can be a table name or table-valued function name in which case the right-hand side is understood to be subquery of the form "(SELECT * FROM name)". When the right operand is an empty set, the result of IN is false and the result of NOT IN is true, regardless of the left operand and even if the left operand is NULL.

The result of an IN or NOT IN operator is determined by the following matrix:

Left operand
is NULL 		Right operand
contains NULL 		Right operand
is an empty set 		Left operand found
within right operand 		Result of
IN operator 		Result of
NOT IN operator
no | no | no | no | false | true
does not matter | no | yes | no | false | true
no | does not matter | no | yes | true | false
no | yes | no | no | NULL | NULL
yes | does not matter | no | does not matter | NULL | NULL

Note that SQLite allows the parenthesized list of scalar values on the right-hand side of an IN or NOT IN operator to be an empty list but most other SQL database engines and the SQL92 standard require the list to contain at least one element.

9. Table Column Names

A column name can be any of the names defined in the CREATE TABLE statement or one of the following special identifiers: "ROWID", "OID", or "_ROWID_". The three special identifiers describe the unique integer key (the rowid) associated with every row of every table and so are not available on WITHOUT ROWID tables. The special identifiers only refer to the row key if the CREATE TABLE statement does not define a real column with the same name. The rowid can be used anywhere a regular column can be used.

10. The EXISTS operator

The EXISTS operator always evaluates to one of the integer values 0 and 1. If executing the SELECT statement specified as the right-hand operand of the EXISTS operator would return one or more rows, then the EXISTS operator evaluates to 1. If executing the SELECT would return no rows at all, then the EXISTS operator evaluates to 0.

The number of columns in each row returned by the SELECT statement (if any) and the specific values returned have no effect on the results of the EXISTS operator. In particular, rows containing NULL values are not handled any differently from rows without NULL values.

11. Subquery Expressions

A SELECT statement enclosed in parentheses is a subquery. All types of SELECT statement, including aggregate and compound SELECT queries (queries with keywords like UNION or EXCEPT) are allowed as scalar subqueries. The value of a subquery expression is the first row of the result from the enclosed SELECT statement. The value of a subquery expression is NULL if the enclosed SELECT statement returns no rows.

A subquery that returns a single column is a scalar subquery and can be used most anywhere. A subquery that returns two or more columns is a row value subquery and can only be used as an operand of a comparison operator or as the value in an UPDATE SET clause whose column name list has the same size.

12. Correlated Subqueries

A SELECT statement used as either a scalar subquery or as the right-hand operand of an IN, NOT IN or EXISTS expression may contain references to columns in the outer query. Such a subquery is known as a correlated subquery. A correlated subquery is reevaluated each time its result is required. An uncorrelated subquery is evaluated only once and the result reused as necessary.

13. CAST expressions

A CAST expression of the form "CAST(expr AS type-name)" is used to convert the value of expr to a different storage class specified by type-name. A CAST conversion is similar to the conversion that takes place when a column affinity is applied to a value except that with the CAST operator the conversion always takes place even if the conversion lossy and irreversible, whereas column affinity only changes the data type of a value if the change is lossless and reversible.

If the value of expr is NULL, then the result of the CAST expression is also NULL. Otherwise, the storage class of the result is determined by applying the rules for determining column affinity to the type-name.

Affinity of type-name | Conversion Processing
NONE | Casting a value to a type-name with no affinity causes the value to be converted into a BLOB. Casting to a BLOB consists of first casting the value to TEXT in the encoding of the database connection, then interpreting the resulting byte sequence as a BLOB instead of as TEXT.
TEXT To cast a BLOB value to TEXT, the sequence of bytes that make up the BLOB is interpreted as text encoded using the database encoding.

Casting an INTEGER or REAL value into TEXT renders the value as if via sqlite3_snprintf() except that the resulting TEXT uses the encoding of the database connection.

REAL When casting a BLOB value to a REAL, the value is first converted to TEXT.

When casting a TEXT value to REAL, the longest possible prefix of the value that can be interpreted as a real number is extracted from the TEXT value and the remainder ignored. Any leading spaces in the TEXT value are ignored when converging from TEXT to REAL. If there is no prefix that can be interpreted as a real number, the result of the conversion is 0.0.

INTEGER When casting a BLOB value to INTEGER, the value is first converted to TEXT.

When casting a TEXT value to INTEGER, the longest possible prefix of the value that can be interpreted as an integer number is extracted from the TEXT value and the remainder ignored. Any leading spaces in the TEXT value when converting from TEXT to INTEGER are ignored. If there is no prefix that can be interpreted as an integer number, the result of the conversion is 0. If the prefix integer is greater than +9223372036854775807 then the result of the cast is exactly +9223372036854775807. Similarly, if the prefix integer is less than -9223372036854775808 then the result of the cast is exactly -9223372036854775808.

When casting to INTEGER, if the text looks like a floating point value with an exponent, the exponent will be ignored because it is no part of the integer prefix. For example, "CAST('123e+5' AS INTEGER)" results in 123, not in 12300000.

The CAST operator understands decimal integers only — conversion of hexadecimal integers stops at the "x" in the "0x" prefix of the hexadecimal integer string and thus result of the CAST is always zero.

A cast of a REAL value into an INTEGER results in the integer between the REAL value and zero that is closest to the REAL value. If a REAL is greater than the greatest possible signed integer (+9223372036854775807) then the result is the greatest possible signed integer and if the REAL is less than the least possible signed integer (-9223372036854775808) then the result is the least possible signed integer.

Prior to SQLite version 3.8.2 (2013-12-06), casting a REAL value greater than +9223372036854775807.0 into an integer resulted in the most negative integer, -9223372036854775808. This behavior was meant to emulate the behavior of x86/x64 hardware when doing the equivalent cast.

NUMERIC Casting a TEXT or BLOB value into NUMERIC yields either an INTEGER or a REAL result. If the input text looks like an integer (there is no decimal point nor exponent) and the value is small enough to fit in a 64-bit signed integer, then the result will be INTEGER. Input text that looks like floating point (there is a decimal point and/or an exponent) and the text describes a value that can be losslessly converted back and forth between IEEE 754 64-bit float and a 51-bit signed integer, then the result is INTEGER. (In the previous sentence, a 51-bit integer is specified since that is one bit less than the length of the mantissa of an IEEE 754 64-bit float and thus provides a 1-bit of margin for the text-to-float conversion operation.) Any text input that describes a value outside the range of a 64-bit signed integer yields a REAL result.

Casting a REAL or INTEGER value to NUMERIC is a no-op, even if a real value could be losslessly converted to an integer.

Note that the result from casting any non-BLOB value into a BLOB and the result from casting any BLOB value into a non-BLOB value may be different depending on whether the database encoding is UTF-8, UTF-16be, or UTF-16le.

14. Boolean Expressions

The SQL language features several contexts where an expression is evaluated and the result converted to a boolean (true or false) value. These contexts are:

  • the WHERE clause of a SELECT, UPDATE or DELETE statement,
  • the ON or USING clause of a join in a SELECT statement,
  • the HAVING clause of a SELECT statement,
  • the WHEN clause of an SQL trigger, and
  • the WHEN clause or clauses of some CASE expressions.

To convert the results of an SQL expression to a boolean value, SQLite first casts the result to a NUMERIC value in the same way as a CAST expression. A numeric zero value (integer value 0 or real value 0.0) is considered to be false. A NULL value is still NULL. All other values are considered true.

For example, the values NULL, 0.0, 0, 'english' and '0' are all considered to be false. Values 1, 1.0, 0.1, -0.1 and '1english' are considered to be true.

Beginning with SQLite 3.23.0 (2018-04-02), SQLite recognizes the identifiers "TRUE" and "FALSE" as boolean literals, if and only if those identifiers are not already used for some other meaning. If there already exists columns or tables or other objects named TRUE or FALSE, then for the sake of backwards compatibility, the TRUE and FALSE identifiers refer to those other objects, not to the boolean values.

The boolean identifiers TRUE and FALSE are usually just aliases for the integer values 1 and 0, respectively. However, if TRUE or FALSE occur on the right-hand side of an IS operator, then the IS operator evaluates the left-hand operand as a boolean value and returns an appropriate answer.

15. Functions

SQLite supports many simple, aggregate, and window SQL functions. For presentation purposes, simple functions are further subdivided into core functions, date-time functions, and JSON functions. Applications can add new functions, written in C/C++, using the sqlite3_create_function() interface.

The main expression bubble diagram above shows a single syntax for all function invocations. But this is merely to simplify the expression bubble diagram. In reality, each type of function has a slightly different syntax, shown below. The function invocation syntax shown in the main expression bubble diagram is the union of the three syntaxes shown here:

simple-function-invocation:

simple-func ( expr ) , *

aggregate-function-invocation:

aggregate-func ( DISTINCT expr ) filter-clause , *

window-function-invocation:

window-func ( expr ) filter-clause OVER window-name window-defn , *

The OVER clause is required for window functions and is prohibited otherwise. The DISTINCT keyword is only allowed in aggregate functions. The FILTER clause may not appear on a simple function.

It is possible to have an aggregate function with the same name as a simple function, as long as the number of arguments for the two forms of the function are different. For example, the max() function with a single argument is an aggregate and the max() function with two or more arguments is a simple function. Aggregate functions can usually also be used as window functions.

This page last modified on 2023-03-20 10:33:41 UTC


The INDEXED BY Clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
The INDEXED BY Clause

1. How INDEXED BY Works

The INDEXED BY phrase forces the SQLite query planner to use a particular named index on a DELETE, SELECT, or UPDATE statement. The INDEXED BY phrase is an SQLite extension and is not portable to other SQL database engines.

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED

The "INDEXED BY index-name" phrase specifies that the named index must be used in order to look up values on the preceding table. If index-name does not exist or cannot be used for the query, then the preparation of the SQL statement fails. The "NOT INDEXED" clause specifies that no index shall be used when accessing the preceding table, including implied indices create by UNIQUE and PRIMARY KEY constraints. However, the rowid can still be used to look up entries even when "NOT INDEXED" is specified.

Some SQL database engines provide non-standard "hint" mechanisms which can be used to give the query optimizer clues about what indices it should use for a particular statement. The INDEXED BY clause of SQLite is not a hinting mechanism and it should not be used as such. The INDEXED BY clause does not give the optimizer hints about which index to use; it gives the optimizer a requirement of which index to use. If the query optimizer is unable to use the index specified by the INDEXED BY clause, then the query will fail with an error.

The INDEXED BY clause is not intended for use in tuning the performance of a query. The intent of the INDEXED BY clause is to raise a run-time error if a schema change, such as dropping or creating an index, causes the query plan for a time-sensitive query to change. The INDEXED BY clause is designed to help detect undesirable query plan changes during regression testing. Application developers are admonished to omit all use of INDEXED BY during application design, implementation, testing, and tuning. If INDEXED BY is to be used at all, it should be inserted at the very end of the development process when "locking down" a design.

2. See Also

  1. The query planner checklist describes steps that application developers should following to help resolve query planner problems. Notice the that the use of INDEXED BY is a last resort, to be used only when all other measures fail.

  2. The unary "+" operator can be used to disqualify terms in the WHERE clause from use by indices. Careful use of unary + can sometimes help prevent the query planner from choosing a poor index without restricting it to using one specific index. Careful placement of unary + operators is a better method for controlling which indices are used by a query.

  3. The sqlite3_stmt_status() C/C++ interface together with the SQLITE_STMTSTATUS_FULLSCAN_STEP and SQLITE_STMTSTATUS_SORT verbs can be used to detect at run-time when an SQL statement is not making effective use of indices. Many applications may prefer to use the sqlite3_stmt_status() interface to detect index misuse rather than the INDEXED BY phrase described here.

This page last modified on 2022-01-08 05:02:57 UTC


INSERT

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
INSERT

1. Overview

insert-stmt:

WITH RECURSIVE common-table-expression , REPLACE INSERT OR ROLLBACK INTO ABORT FAIL IGNORE REPLACE schema-name . table-name AS alias ( column-name ) , VALUES ( expr ) , , upsert-clause select-stmt upsert-clause DEFAULT VALUES returning-clause

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

returning-clause:

RETURNING expr AS column-alias * ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

upsert-clause:

ON CONFLICT ( indexed-column ) WHERE expr DO , conflict target UPDATE SET column-name-list = expr WHERE expr NOTHING , column-name

column-name-list:

( column-name ) ,

indexed-column:

column-name COLLATE collation-name DESC expr ASC

The INSERT statement comes in three basic forms.

  1. INSERT INTO table VALUES(...);

    The first form (with the "VALUES" keyword) creates one or more new rows in an existing table. If the column-name list after table-name is omitted then the number of values inserted into each row must be the same as the number of columns in the table. In this case the result of evaluating the left-most expression from each term of the VALUES list is inserted into the left-most column of each new row, and so forth for each subsequent expression. If a column-name list is specified, then the number of values in each term of the VALUE list must match the number of specified columns. Each of the named columns of the new row is populated with the results of evaluating the corresponding VALUES expression. Table columns that do not appear in the column list are populated with the default column value (specified as part of the CREATE TABLE statement), or with NULL if no default value is specified.

  2. INSERT INTO table SELECT ...;

    The second form of the INSERT statement contains a SELECT statement instead of a VALUES clause. A new entry is inserted into the table for each row of data returned by executing the SELECT statement. If a column-list is specified, the number of columns in the result of the SELECT must be the same as the number of items in the column-list. Otherwise, if no column-list is specified, the number of columns in the result of the SELECT must be the same as the number of columns in the table. Any SELECT statement, including compound SELECTs and SELECT statements with ORDER BY and/or LIMIT clauses, may be used in an INSERT statement of this form.

    To avoid a parsing ambiguity, the SELECT statement should always contain a WHERE clause, even if that clause is simply "WHERE true", if the upsert-clause is present. Without the WHERE clause, the parser does not know if the token "ON" is part of a join constraint on the SELECT, or the beginning of the upsert-clause.

  3. INSERT INTO table DEFAULT VALUES;

    The third form of an INSERT statement is with DEFAULT VALUES. The INSERT ... DEFAULT VALUES statement inserts a single new row into the named table. Each column of the new row is populated with its default value, or with a NULL if no default value is specified as part of the column definition in the CREATE TABLE statement. The upsert-clause is not supported after DEFAULT VALUES.

The initial "INSERT" keyword can be replaced by "REPLACE" or "INSERT OR action" to specify an alternative constraint conflict resolution algorithm to use during that one INSERT command. For compatibility with MySQL, the parser allows the use of the single keyword REPLACE as an alias for "INSERT OR REPLACE".

The optional "schema-name." prefix on the table-name is supported for top-level INSERT statements only. The table name must be unqualified for INSERT statements that occur within CREATE TRIGGER statements. Similarly, the "DEFAULT VALUES" form of the INSERT statement is supported for top-level INSERT statements only and not for INSERT statements within triggers.

The optional "AS alias" phrase provides an alternative name for the table into which content is being inserted. The alias name can be used within WHERE and SET clauses of the UPSERT. If there is no upsert-clause, then the alias is pointless, but also harmless.

See the separate UPSERT documentation for the additional trailing syntax that can cause an INSERT to behave as an UPDATE if the INSERT would otherwise violate a uniqueness constraint. The upsert clause is not allowed on an "INSERT ... DEFAULT VALUES".

This page last modified on 2022-01-08 05:02:57 UTC


SQLite Keywords

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
SQLite Keywords

The SQL standard specifies a large number of keywords which may not be used as the names of tables, indices, columns, databases, user-defined functions, collations, virtual table modules, or any other named object. The list of keywords is so long that few people can remember them all. For most SQL code, your safest bet is to never use any English language word as the name of a user-defined object.

If you want to use a keyword as a name, you need to quote it. There are four ways of quoting keywords in SQLite:

'keyword' | A keyword in single quotes is a string literal.
"keyword" | A keyword in double-quotes is an identifier.
[keyword] | A keyword enclosed in square brackets is an identifier. This is not standard SQL. This quoting mechanism is used by MS Access and SQL Server and is included in SQLite for compatibility.
`keyword` | A keyword enclosed in grave accents (ASCII code 96) is an identifier. This is not standard SQL. This quoting mechanism is used by MySQL and is included in SQLite for compatibility.

For resilience when confronted with historical SQL statements, SQLite will sometimes bend the quoting rules above:

  • If a keyword in single quotes (ex: 'key' or 'glob') is used in a context where an identifier is allowed but where a string literal is not allowed, then the token is understood to be an identifier instead of a string literal.

  • If a keyword in double quotes (ex: "key" or "glob") is used in a context where it cannot be resolved to an identifier but where a string literal is allowed, then the token is understood to be a string literal instead of an identifier.

Programmers are cautioned not to use the two exceptions described in the previous bullets. We emphasize that they exist only so that old and ill-formed SQL statements will run correctly. Future versions of SQLite might raise errors instead of accepting the malformed statements covered by the exceptions above.

SQLite adds new keywords from time to time when it takes on new features. So to prevent your code from being broken by future enhancements, you should normally quote any identifier that is an English language word, even if you do not have to.

The list below shows all possible keywords used by any build of SQLite regardless of compile-time options. Most reasonable configurations use most or all of these keywords, but some keywords may be omitted when SQL language features are disabled. Applications can use the sqlite3_keyword_count(), sqlite3_keyword_name(), and sqlite3_keyword_check() interfaces to determine the keywords recognized by SQLite at run-time. Regardless of the compile-time configuration, any identifier that is not on the following 147-element list is not a keyword to the SQL parser in SQLite:

  • ABORT
  • ACTION
  • ADD
  • AFTER
  • ALL
  • ALTER
  • ALWAYS
  • ANALYZE
  • AND
  • AS
  • ASC
  • ATTACH
  • AUTOINCREMENT
  • BEFORE
  • BEGIN
  • BETWEEN
  • BY
  • CASCADE
  • CASE
  • CAST
  • CHECK
  • COLLATE
  • COLUMN
  • COMMIT
  • CONFLICT
  • CONSTRAINT
  • CREATE
  • CROSS
  • CURRENT
  • CURRENT_DATE
  • CURRENT_TIME
  • CURRENT_TIMESTAMP
  • DATABASE
  • DEFAULT
  • DEFERRABLE
  • DEFERRED
  • DELETE
  • DESC
  • DETACH
  • DISTINCT
  • DO
  • DROP
  • EACH
  • ELSE
  • END
  • ESCAPE
  • EXCEPT
  • EXCLUDE
  • EXCLUSIVE
  • EXISTS
  • EXPLAIN
  • FAIL
  • FILTER
  • FIRST
  • FOLLOWING
  • FOR
  • FOREIGN
  • FROM
  • FULL
  • GENERATED
  • GLOB
  • GROUP
  • GROUPS
  • HAVING
  • IF
  • IGNORE
  • IMMEDIATE
  • IN
  • INDEX
  • INDEXED
  • INITIALLY
  • INNER
  • INSERT
  • INSTEAD
  • INTERSECT
  • INTO
  • IS
  • ISNULL
  • JOIN
  • KEY
  • LAST
  • LEFT
  • LIKE
  • LIMIT
  • MATCH
  • MATERIALIZED
  • NATURAL
  • NO
  • NOT
  • NOTHING
  • NOTNULL
  • NULL
  • NULLS
  • OF
  • OFFSET
  • ON
  • OR
  • ORDER
  • OTHERS
  • OUTER
  • OVER
  • PARTITION
  • PLAN
  • PRAGMA
  • PRECEDING
  • PRIMARY
  • QUERY
  • RAISE
  • RANGE
  • RECURSIVE
  • REFERENCES
  • REGEXP
  • REINDEX
  • RELEASE
  • RENAME
  • REPLACE
  • RESTRICT
  • RETURNING
  • RIGHT
  • ROLLBACK
  • ROW
  • ROWS
  • SAVEPOINT
  • SELECT
  • SET
  • TABLE
  • TEMP
  • TEMPORARY
  • THEN
  • TIES
  • TO
  • TRANSACTION
  • TRIGGER
  • UNBOUNDED
  • UNION
  • UNIQUE
  • UPDATE
  • USING
  • VACUUM
  • VALUES
  • VIEW
  • VIRTUAL
  • WHEN
  • WHERE
  • WINDOW
  • WITH
  • WITHOUT

This page last modified on 2022-11-26 14:56:19 UTC


Built-In Mathematical SQL Functions

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
Built-In Mathematical SQL Functions

1. Overview

The math functions shown below are part of the SQLite amalgamation source file but are only active if the amalgamation is compiled using the -DSQLITE_ENABLE_MATH_FUNCTIONS compile-time option.

The arguments to math functions can be integers, floating-point numbers, or strings or blobs that look like integers or real numbers. If any argument is NULL or is a string or blob that is not readily converted into a number, then the function will return NULL. These functions also return NULL for domain errors, such as trying to take the square root of a negative number, or compute the arccosine of a value greater than 1.0 or less than -1.0.

The values returned by these functions are often approximations. For example, the pi() function returns 3.141592653589793115997963468544185161590576171875 which is about 1.22465e-16 too small, but it is the closest approximation available for IEEE754 doubles.

  • acos(X)
  • acosh(X)
  • asin(X)
  • asinh(X)
  • atan(X)
  • atan2(Y,X)
  • atanh(X)
  • ceil(X)
  • ceiling(X)
  • cos(X)
  • cosh(X)
  • degrees(X)
  • exp(X)
  • floor(X)
  • ln(X)
  • log(B,X)
  • log(X)
  • log10(X)
  • log2(X)
  • mod(X,Y)
  • pi()
  • pow(X,Y)
  • power(X,Y)
  • radians(X)
  • sin(X)
  • sinh(X)
  • sqrt(X)
  • tan(X)
  • tanh(X)
  • trunc(X)

2. Descriptions of built-in scalar SQL math functions

acos(X)

Return the arccosine of X. The result is in radians.

acosh(X)

Return the hyperbolic arccosine of X.

asin(X)

Return the arcsine of X. The result is in radians.

asinh(X)

Return the hyperbolic arcsine of X.

atan(X)

Return the arctangent of X. The result is in radians.

atan2(Y,X)

Return the arctangent of Y/X. The result is in radians. The result is placed into correct quadrant depending on the signs of X and Y.

atanh(X)

Return the hyperbolic arctangent of X.

ceil(X)
ceiling(X)

Return the first representable integer value greater than or equal to X. For positive values of X, this routine rounds away from zero. For negative values of X, this routine rounds toward zero.

cos(X)

Return the cosine of X. X is in radians.

cosh(X)

Return the hyperbolic cosine of X.

degrees(X)

Convert value X from radians into degrees.

exp(X)

Compute e (Euler's number, approximately 2.71828182845905) raised to the power X.

floor(X)

Return the first representable integer value less than or equal to X. For positive numbers, this function rounds toward zero. For negative numbers, this function rounds away from zero.

ln(X)

Return the natural logarithm of X.

log(X)
log10(X)
log(B,X)

Return the base-10 logarithm for X. Or, for the two-argument version, return the base-B logarithm of X.

Compatibility note: SQLite works like PostgreSQL in that the log() function computes a base-10 logarithm. Most other SQL database engines compute a natural logarithm for log(). In the two-argument version of log(B,X), the first argument is the base and the second argument is the operand. This is the same as in PostgreSQL and MySQL, but is reversed from SQL Server which uses the second argument as the base and the first argument as the operand.

log2(X)

Return the logarithm base-2 for the number X.

mod(X,Y)

Return the remainder after dividing X by Y. This is similar to the '%' operator, except that it works for non-integer arguments.

pi()

Return an approximation for π.

pow(X,Y)
power(X,Y)

Compute X raised to the power Y.

radians(X)

Convert X from degrees into radians.

sin(X)

Return the sine of X. X is in radians.

sinh(X)

Return the hyperbolic sine of X.

sqrt(X)

Return the square root of X. NULL is returned if X is negative.

tan(X)

Return the tangent of X. X is in radians.

tanh(X)

Return the hyperbolic tangent of X.

trunc(X)

Return the representable integer in between X and 0 (inclusive) that is furthest away from zero. Or, in other words, return the integer part of X, rounding toward zero. The trunc() function is similar to ceiling(X) and floor(X) except that it always rounds toward zero whereas ceiling(X) and floor(X) round up and down, respectively.


Database Object Name Resolution

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

In SQLite, a database object (a table, index, trigger or view) is identified by the name of the object and the name of the database that it resides in. Database objects may reside in the main database, the temp database, or in an attached database.

The syntax of the DROP TABLE, DROP INDEX, DROP VIEW, DROP TRIGGER, REINDEX, ALTER TABLE and many other commands all permit the user to specify a database object either by its name alone, or by a combination of its name and the name of its database. If no database is specified as part of the object reference, then SQLite searches the main, temp and all attached databases for an object with a matching name. The temp database is searched first, followed by the main database, followed all attached databases in the order that they were attached. The reference resolves to the first match found. For example:

      /* Add a table named 't1' to the temp, main and an attached database */
      ATTACH 'file.db' AS aux;
      CREATE TABLE t1(x, y);
      CREATE TEMP TABLE t1(x, y);
      CREATE TABLE aux.t1(x, y);

      DROP TABLE t1;         /* Drop table in temp database */
      DROP TABLE t1;         /* Drop table in main database */
      DROP TABLE t1;         /* Drop table in aux database */

If a schema name is specified as part of an object reference, it must be either "main", or "temp" or the schema-name of an attached database. Like other SQL identifiers, schema names are case-insensitive. If a schema name is specified, then only that one schema is searched for the named object.

Most object references may only resolve to a specific type of object (for example a reference that is part of a DROP TABLE statement may only resolve to a table object, not an index, trigger or view). However in some contexts (e.g. REINDEX) an object reference may be resolve to more than one type of object. When searching database schemas for a named object, objects of types that cannot be used in the context of the reference are always ignored.

This page last modified on 2022-01-08 05:02:57 UTC


REINDEX

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
REINDEX

reindex-stmt:

REINDEX schema-name . index-name table-name collation-name

The REINDEX command is used to delete and recreate indices from scratch. This is useful when the definition of a collation sequence has changed, or when there are indexes on expressions involving a function whose definition has changed.

If the REINDEX keyword is not followed by a collation-sequence or database object identifier, then all indices in all attached databases are rebuilt.

If the REINDEX keyword is followed by a collation-sequence name, then all indices in all attached databases that use the named collation sequences are recreated.

Or, if the argument attached to the REINDEX identifies a specific database table, then all indices attached to the database table are rebuilt. If it identifies a specific database index, then just that index is recreated.

For a command of the form "REINDEX name", a match against collation-name takes precedence over a match against index-name or table-name. This ambiguity in the syntax may be avoided by always specifying a schema-name when reindexing a specific table or index.

This page last modified on 2022-01-08 05:02:57 UTC


REPLACE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
REPLACE

The REPLACE command is an alias for the "INSERT OR REPLACE" variant of the INSERT command. This alias is provided for compatibility other SQL database engines. See the INSERT command documentation for additional information.

This page last modified on 2022-01-08 05:02:57 UTC


RETURNING

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
RETURNING
► Table Of Contents
1. Overview
1.1. Typical Use
2. Details
2.1. Processing Order
2.2. ACID Changes
3. Limitations And Caveats

1. Overview

returning-clause:

RETURNING expr AS column-alias * ,

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

The RETURNING clause is not a statement itself, but a clause that can optionally appear near the end of top-level DELETE, INSERT, and UPDATE statements. The effect of the RETURNING clause is to cause the statement to return one result row for each database row that is deleted, inserted, or updated. RETURNING is not standard SQL. It is an extension. SQLite's syntax for RETURNING is modelled after PostgreSQL.

The RETURNING syntax has been supported by SQLite since version 3.35.0 (2021-03-12).

1.1. Typical Use

The RETURNING clause is designed to provide the application with the values of columns that are filled in automatically by SQLite. For example:

CREATE TABLE t0(
  a INTEGER PRIMARY KEY,
  b DATE DEFAULT CURRENT_TIMESTAMP,
  c INTEGER
);
INSERT INTO t0(c) VALUES(random()) RETURNING *;

In the INSERT statement above, SQLite computes the values for all three columns. The RETURNING clause causes SQLite to report the chosen values back to the application. This saves the application from having to issue a separate query to figure out exactly what values were inserted.

2. Details

The RETURNING clause is followed by a comma-separated list of expressions. These expressions are similar to the expressions following the SELECT keyword in a SELECT statement in that they define the values of the columns in the result set. Each expression defines the value for a single column. Each expression may be optionally followed by an AS clause that determines the name of the result column. The special "*" expression expands into a list of all non-hidden columns of the table being deleted, inserted, or updated.

For INSERT and UPDATE statements, references to columns in the table being modified refer to the value of that column after the change has been applied. For DELETE statements, references to columns mean the value before the delete occurs.

The RETURNING clause only returns rows that are directly modified by the DELETE, INSERT, or UPDATE statement. The RETURNING clause does not report any additional database changes caused by foreign key constraints or triggers.

A RETURNING clause for an UPSERT reports both inserted and updated rows.

2.1. Processing Order

When a DELETE, INSERT, or UPDATE statement with a RETURNING clause is run, all of the database changes occur during the first invocation of sqlite3_step(). The RETURNING clause output is accumulated in memory. The first sqlite3_step() call returns one row of RETURNING output and subsequent rows of RETURNING output are returned by subsequent calls to sqlite3_step(). To put this another way, all RETURNING clause output is embargoed until after all database modification actions are completed.

This means that if a statement has a RETURNING clause that generates a large amount of output, either many rows or large string or BLOB values, then the statement might use a lot of temporary memory to hold those values while it is running.

The first prototype of the RETURNING clause returned values as they were generated. That approach used less memory, but it had other problems:

  1. If the calls sqlite3_step() for two or more DML statements where interleaved and if one of the statements hit a constraint failure and aborted, reverting its changes, then that could disrupt the operation of the other DML statement. This could not corrupt the database file, but it could yield surprising and difficult-to-explain results in the database.

  2. If an application failed to call sqlite3_step() repeatedly until it received SQLITE_DONE, then some of the database changes might never occur.

  3. The order of operations was different from client/server database engines like PostgreSQL, which might cause portability issues for some applications.

For these reasons, the current implementation was modified so that all database changes happen before any RETURNING output is emitted.

While SQLite does guarantee that all database changes will occur before any RETURNING output is emitted, it does not guarantee that the order of individual RETURNING rows will match the order in which those rows were changed in the database. The output order for the RETURNING rows is arbitrary and is not necessarily related to the order in which the rows were processed internally.

2.2. ACID Changes

When the previous "Processing Order" section says that "database changes occur during the first invocation of sqlite3_step()", that means that the changes are stored in the private page cache of the database connection that is running the statement. It does not mean that the changes are actually committed. The commit does not occur until the statement finishes, and maybe not even then if the statement is part of a larger transaction. Changes to the database are still atomic, consistent, isolated, and durable (ACID). When the previous section says "changes occur", this means that internal data structure are adjusted pending a transaction commit. Some of those changes may or may not spill into the write-ahead log, depending on how much pressure there is on the page cache. If the page cache is not under memory pressure, then probably nothing will be written to disk until after the transaction completes, which is after sqlite3_step() returns SQLITE_DONE.

In other words, when the previous section says "database changes occur", that means that the changes occur in the memory of the specific database connection that is running the statement, not that the changes are written to disk.

3. Limitations And Caveats

  1. The RETURNING clause is not available on DELETE and UPDATE statements against virtual tables. This limitation might be removed in future versions of SQLite.

  2. The RETURNING clause is only available in top-level DELETE, INSERT, and UPDATE statements. The RETURNING clause cannot be used by statements within triggers.

  3. Even though a DML statement with a RETURNING clause returns table content, it cannot be used as a subquery. The RETURNING clause can only return data to the application. It is not currently possible to divert the RETURNING output into another table or query. PostgreSQL has the ability to use a DML statement with a RETURNING clause like a view in a common table expressions. SQLite does not currently have that ability, though that is something that might be added in a future release.

  4. The rows emitted by the RETURNING clause appear in an arbitrary order. That order might change depending on the database schema, upon the specific release of SQLite used, or even from one execution of the same statement to the next. There is no way to cause the output rows to appear in a particular order. Even if SQLite is compiled with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT option such that ORDER BY clauses are allowed on DELETE and UPDATE statements, those ORDER BY clauses do not constrain the output order of RETURNING.

  5. The values emitted by the RETURNING clause are the values as seen by the top-level DELETE, INSERT, or UPDATE statement and do not reflect any subsequent value changes made by triggers. Thus, if the database includes AFTER triggers that modifies some of the values of each row inserted or updated, the RETURNING clause emits the original values that are computed before those triggers run.

  6. The RETURNING clause may not contain top-level aggregate functions or window functions. If there are subqueries in the RETURNING clause, those subqueries may contain aggregates and window functions, but aggregates cannot occur at the top level.

  7. The RETURNING clause may only reference the table being modified. In an UPDATE FROM statement, the auxiliary tables named in the FROM clause may not participate in the RETURNING clause.

This page last modified on 2023-02-14 21:05:59 UTC


Savepoints

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
Savepoints

1. Syntax

savepoint-stmt:

SAVEPOINT savepoint-name

release-stmt:

RELEASE SAVEPOINT savepoint-name

rollback-stmt:

ROLLBACK TRANSACTION TO SAVEPOINT savepoint-name

2. Savepoints

SAVEPOINTs are a method of creating transactions, similar to BEGIN and COMMIT, except that the SAVEPOINT and RELEASE commands are named and may be nested.

The SAVEPOINT command starts a new transaction with a name. The transaction names need not be unique. A SAVEPOINT can be started either within or outside of a BEGIN...COMMIT. When a SAVEPOINT is the outer-most savepoint and it is not within a BEGIN...COMMIT then the behavior is the same as BEGIN DEFERRED TRANSACTION.

The ROLLBACK TO command reverts the state of the database back to what it was just after the corresponding SAVEPOINT. Note that unlike that plain ROLLBACK command (without the TO keyword) the ROLLBACK TO command does not cancel the transaction. Instead of cancelling the transaction, the ROLLBACK TO command restarts the transaction again at the beginning. All intervening SAVEPOINTs are canceled, however.

The RELEASE command is like a COMMIT for a SAVEPOINT. The RELEASE command causes all savepoints back to and including the most recent savepoint with a matching name to be removed from the transaction stack. The RELEASE of an inner transaction does not cause any changes to be written to the database file; it merely removes savepoints from the transaction stack such that it is no longer possible to ROLLBACK TO those savepoints. If a RELEASE command releases the outermost savepoint, so that the transaction stack becomes empty, then RELEASE is the same as COMMIT. The COMMIT command may be used to release all savepoints and commit the transaction even if the transaction was originally started by a SAVEPOINT command instead of a BEGIN command.

If the savepoint-name in a RELEASE command does not match any savepoint currently in the transaction stack, then no savepoints are released, the database is unchanged, and the RELEASE command returns an error.

Note that an inner transaction might commit (using the RELEASE command) but then later have its work undone by a ROLLBACK in an outer transaction. A power failure or program crash or OS crash will cause the outer-most transaction to rollback, undoing all changes that have occurred within that outer transaction, even changes that have supposedly been "committed" by the RELEASE command. Content is not actually committed on the disk until the outermost transaction commits.

There are several ways of thinking about the RELEASE command:

  • Some people view RELEASE as the equivalent of COMMIT for a SAVEPOINT. This is an acceptable point of view as long as one remembers that the changes committed by an inner transaction might later be undone by a rollback in an outer transaction.

  • Another view of RELEASE is that it merges a named transaction into its parent transaction, so that the named transaction and its parent become the same transaction. After RELEASE, the named transaction and its parent will commit or rollback together, whatever their fate may be.

  • One can also think of savepoints as "marks" in the transaction timeline. In this view, the SAVEPOINT command creates a new mark, the ROLLBACK TO command rewinds the timeline back to a point just after the named mark, and the RELEASE command erases marks from the timeline without actually making any changes to the database.

3. Transaction Nesting Rules

The last transaction started will be the first transaction committed or rolled back.

The BEGIN command only works if the transaction stack is empty, or in other words if there are no pending transactions. If the transaction stack is not empty when the BEGIN command is invoked, then the command fails with an error.

The COMMIT command commits all outstanding transactions and leaves the transaction stack empty.

The RELEASE command starts with the most recent addition to the transaction stack and releases savepoints backwards in time until it releases a savepoint with a matching savepoint-name. Prior savepoints, even savepoints with matching savepoint-names, are unchanged. If the RELEASE command causes the transaction stack to become empty (if the RELEASE command releases the outermost transaction from the stack) then the transaction commits.

The ROLLBACK command without a TO clause rolls backs all transactions and leaves the transaction stack empty.

The ROLLBACK command with a TO clause rolls back transactions going backwards in time back to the most recent SAVEPOINT with a matching name. The SAVEPOINT with the matching name remains on the transaction stack, but all database changes that occurred after that SAVEPOINT was created are rolled back. If the savepoint-name in a ROLLBACK TO command does not match any SAVEPOINT on the stack, then the ROLLBACK command fails with an error and leaves the state of the database unchanged.

This page last modified on 2022-01-08 05:02:57 UTC


SELECT

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
SELECT
► Table Of Contents
1. Overview
2. Simple Select Processing
2.1. Determination of input data (FROM clause processing)
2.2. Special handling of CROSS JOIN.
2.3. WHERE clause filtering.
2.4. Generation of the set of result rows
2.5. Bare columns in an aggregate query
2.6. Removal of duplicate rows (DISTINCT processing)
3. Compound Select Statements
4. The ORDER BY clause
5. The LIMIT clause
6. The VALUES clause
7. The WITH Clause
8. Table-valued Functions In The FROM Clause
9. Deviations From Standard SQL
9.1. Strange JOIN names
9.2. Precedence of comma-joins and CROSS JOIN

1. Overview

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

The SELECT statement is used to query the database. The result of a SELECT is zero or more rows of data where each row has a fixed number of columns. A SELECT statement does not make any changes to the database.

The "select-stmt" syntax diagram above attempts to show as much of the SELECT statement syntax as possible in a single diagram, because some readers find that helpful. The following "factored-select-stmt" is an alternative syntax diagrams that expresses the same syntax but tries to break the syntax down into smaller chunks.

factored-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr compound-operator ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

select-core:

SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , ,

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

Note that there are paths through the syntax diagrams that are not allowed in practice. Some examples:

  • A VALUES clause can be the first element in a compound SELECT that uses a WITH clause, but a simple SELECT that consists of just a VALUES clause cannot be preceded by a WITH clause.
  • The WITH clause must occur on the first SELECT of a compound SELECT. It cannot follow a compound-operator.

These and other similar syntax restrictions are described in the text.

The SELECT statement is the most complicated command in the SQL language. To make the description easier to follow, some of the passages below describe the way the data returned by a SELECT statement is determined as a series of steps. It is important to keep in mind that this is purely illustrative - in practice neither SQLite nor any other SQL engine is required to follow this or any other specific process.

2. Simple Select Processing

The core of a SELECT statement is a "simple SELECT" shown by the select-core and simple-select-stmt syntax diagrams below. In practice, most SELECT statements are simple SELECT statements.

simple-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

select-core:

SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , ,

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

Generating the results of a simple SELECT statement is presented as a four step process in the description below:

  1. FROM clause processing: The input data for the simple SELECT is determined. The input data is either implicitly a single row with 0 columns (if there is no FROM clause) or is determined by the FROM clause.

  2. WHERE clause processing: The input data is filtered using the WHERE clause expression.

  3. GROUP BY, HAVING and result-column expression processing: The set of result rows is computed by aggregating the data according to any GROUP BY clause and calculating the result-set expressions for the rows of the filtered input dataset.

  4. DISTINCT/ALL keyword processing: If the query is a "SELECT DISTINCT" query, duplicate rows are removed from the set of result rows.

There are two types of simple SELECT statement - aggregate and non-aggregate queries. A simple SELECT statement is an aggregate query if it contains either a GROUP BY clause or one or more aggregate functions in the result-set. Otherwise, if a simple SELECT contains no aggregate functions or a GROUP BY clause, it is a non-aggregate query.

2.1. Determination of input data (FROM clause processing)

The input data used by a simple SELECT query is a set of N rows each M columns wide.

If the FROM clause is omitted from a simple SELECT statement, then the input data is implicitly a single row zero columns wide (i.e. N=1 and M=0).

If a FROM clause is specified, the data on which a simple SELECT query operates comes from the one or more tables or subqueries (SELECT statements in parentheses) specified following the FROM keyword. A subquery specified in the table-or-subquery following the FROM clause in a simple SELECT statement is handled as if it was a table containing the data returned by executing the subquery statement. Each column of the subquery has the collation sequence and affinity of the corresponding expression in the subquery statement.

If there is only a single table or subquery in the FROM clause, then the input data used by the SELECT statement is the contents of the named table. If there is more than one table or subquery in FROM clause then the contents of all tables and/or subqueries are joined into a single dataset for the simple SELECT statement to operate on. Exactly how the data is combined depends on the specific join-operator and join-constraint used to connect the tables or subqueries together.

All joins in SQLite are based on the cartesian product of the left and right-hand datasets. The columns of the cartesian product dataset are, in order, all the columns of the left-hand dataset followed by all the columns of the right-hand dataset. There is a row in the cartesian product dataset formed by combining each unique combination of a row from the left-hand and right-hand datasets. In other words, if the left-hand dataset consists of Nleft rows of Mleft columns, and the right-hand dataset of Nright rows of Mright columns, then the cartesian product is a dataset of Nleft×Nright rows, each containing Mleft+Mright columns.

If the join-operator is "CROSS JOIN", "INNER JOIN", "JOIN" or a comma (",") and there is no ON or USING clause, then the result of the join is simply the cartesian product of the left and right-hand datasets. If join-operator does have ON or USING clauses, those are handled according to the following bullet points:

  • If there is an ON clause then the ON expression is evaluated for each row of the cartesian product as a boolean expression. Only rows for which the expression evaluates to true are included from the dataset.

  • If there is a USING clause then each of the column names specified must exist in the datasets to both the left and right of the join-operator. For each pair of named columns, the expression "lhs.X = rhs.X" is evaluated for each row of the cartesian product as a boolean expression. Only rows for which all such expressions evaluates to true are included from the result set. When comparing values as a result of a USING clause, the normal rules for handling affinities, collation sequences and NULL values in comparisons apply. The column from the dataset on the left-hand side of the join-operator is considered to be on the left-hand side of the comparison operator (=) for the purposes of collation sequence and affinity precedence.

    For each pair of columns identified by a USING clause, the column from the right-hand dataset is omitted from the joined dataset. This is the only difference between a USING clause and its equivalent ON constraint.

  • If the NATURAL keyword is in the join-operator then an implicit USING clause is added to the join-constraints. The implicit USING clause contains each of the column names that appear in both the left and right-hand input datasets. If the left and right-hand input datasets feature no common column names, then the NATURAL keyword has no effect on the results of the join. A USING or ON clause may not be added to a join that specifies the NATURAL keyword.

  • If the join-operator is a "LEFT JOIN" or "LEFT OUTER JOIN", then after the ON or USING filtering clauses have been applied, an extra row is added to the output for each row in the original left-hand input dataset that does not match any row in the right-hand dataset. The added rows contain NULL values in the columns that would normally contain values copied from the right-hand input dataset.

  • If the join-operator is a "RIGHT JOIN" or "RIGHT OUTER JOIN", then after the ON or USING filtering clauses have been applied, an extra row is added to the output for each row in the original right-hand input dataset that does not match any row in the left-hand dataset. The added rows contain NULL values in the columns that would normally contain values copied from the left-hand input dataset.

  • A "FULL JOIN" or "FULL OUTER JOIN" is a combination of a "LEFT JOIN" and a "RIGHT JOIN". Extra rows of output are added for each row in left dataset that matches no rows in the right, and for each row in the right dataset that matches no rows in the left. Unmatched columns are filled in with NULL.

When more than two tables are joined together as part of a FROM clause, the join operations are processed in order from left to right. In other words, the FROM clause (A join-op-1 B join-op-2 C) is computed as ((A join-op-1 B) join-op-2 C).

2.2. Special handling of CROSS JOIN.

There is no difference between the "INNER JOIN", "JOIN" and "," join operators. They are completely interchangeable in SQLite. The "CROSS JOIN" join operator produces the same result as the "INNER JOIN", "JOIN" and "," operators, but is handled differently by the query optimizer in that it prevents the query optimizer from reordering the tables in the join. An application programmer can use the CROSS JOIN operator to directly influence the algorithm that is chosen to implement the SELECT statement. Avoid using CROSS JOIN except in specific situations where manual control of the query optimizer is desired. Avoid using CROSS JOIN early in the development of an application as doing so is a premature optimization. The special handling of CROSS JOIN is an SQLite-specific feature and is not a part of standard SQL.

2.3. WHERE clause filtering.

If a WHERE clause is specified, the WHERE expression is evaluated for each row in the input data as a boolean expression. Only rows for which the WHERE clause expression evaluates to true are included from the dataset before continuing. Rows are excluded from the result if the WHERE clause evaluates to either false or NULL.

For a JOIN or INNER JOIN or CROSS JOIN, there is no difference between a constraint expression in the WHERE clause and one in the ON clause. However, for a LEFT JOIN or LEFT OUTER JOIN, the difference is very important. In a LEFT JOIN, the extra NULL row for the right-hand table is added after ON clause processing but before WHERE clause processing. A constraint of the form "left.x=right.y" in an ON clause will therefore allow through the added all-NULL rows of the right table. But if that same constraint is in the WHERE clause a NULL in "right.y" will prevent the expression "left.x=right.y" from being true, and thus exclude that row from the output.

2.4. Generation of the set of result rows

Once the input data from the FROM clause has been filtered by the WHERE clause expression (if any), the set of result rows for the simple SELECT are calculated. Exactly how this is done depends on whether the simple SELECT is an aggregate or non-aggregate query, and whether or not a GROUP BY clause was specified.

The list of expressions between the SELECT and FROM keywords is known as the result expression list. If a result expression is the special expression "*" then all columns in the input data are substituted for that one expression. If the expression is the alias of a table or subquery in the FROM clause followed by ".*" then all columns from the named table or subquery are substituted for the single expression. It is an error to use a "*" or "alias.*" expression in any context other than a result expression list. It is also an error to use a "*" or "alias.*" expression in a simple SELECT query that does not have a FROM clause.

The number of columns in the rows returned by a simple SELECT statement is equal to the number of expressions in the result expression list after substitution of * and alias.* expressions. Each result row is calculated by evaluating the expressions in the result expression list with respect to a single row of input data or, for aggregate queries, with respect to a group of rows.

  • If the SELECT statement is a non-aggregate query, then each expression in the result expression list is evaluated for each row in the dataset filtered by the WHERE clause.

  • If the SELECT statement is an aggregate query without a GROUP BY clause, then each aggregate expression in the result-set is evaluated once across the entire dataset. Each non-aggregate expression in the result-set is evaluated once for an arbitrarily selected row of the dataset. The same arbitrarily selected row is used for each non-aggregate expression. Or, if the dataset contains zero rows, then each non-aggregate expression is evaluated against a row consisting entirely of NULL values.

    The single row of result-set data created by evaluating the aggregate and non-aggregate expressions in the result-set forms the result of an aggregate query without a GROUP BY clause. An aggregate query without a GROUP BY clause always returns exactly one row of data, even if there are zero rows of input data.

  • If the SELECT statement is an aggregate query with a GROUP BY clause, then each of the expressions specified as part of the GROUP BY clause is evaluated for each row of the dataset according to the processing rules stated below for ORDER BY expressions. Each row is then assigned to a "group" based on the results; rows for which the results of evaluating the GROUP BY expressions are the same get assigned to the same group. For the purposes of grouping rows, NULL values are considered equal. The usual rules for selecting a collation sequence with which to compare text values apply when evaluating expressions in a GROUP BY clause. The expressions in the GROUP BY clause do not have to be expressions that appear in the result. The expressions in a GROUP BY clause may not be aggregate expressions.

    If a HAVING clause is specified, it is evaluated once for each group of rows as a boolean expression. If the result of evaluating the HAVING clause is false, the group is discarded. If the HAVING clause is an aggregate expression, it is evaluated across all rows in the group. If a HAVING clause is a non-aggregate expression, it is evaluated with respect to an arbitrarily selected row from the group. The HAVING expression may refer to values, even aggregate functions, that are not in the result.

    Each expression in the result-set is then evaluated once for each group of rows. If the expression is an aggregate expression, it is evaluated across all rows in the group. Otherwise, it is evaluated against a single arbitrarily chosen row from within the group. If there is more than one non-aggregate expression in the result-set, then all such expressions are evaluated for the same row.

    Each group of input dataset rows contributes a single row to the set of result rows. Subject to filtering associated with the DISTINCT keyword, the number of rows returned by an aggregate query with a GROUP BY clause is the same as the number of groups of rows produced by applying the GROUP BY and HAVING clauses to the filtered input dataset.

2.5. Bare columns in an aggregate query

The usual case is that all column names in an aggregate query are either arguments to aggregate functions or else appear in the GROUP BY clause. A result column which contains a column name that is not within an aggregate function and that does not appear in the GROUP BY clause (if one exists) is called a "bare" column. Example:

SELECT a, b, sum(c) FROM tab1 GROUP BY a;

In the query above, the "a" column is part of the GROUP BY clause and so each row of the output contains one of the distinct values for "a". The "c" column is contained within the sum() aggregate function and so that output column is the sum of all "c" values in rows that have the same value for "a". But what is the result of the bare column "b"? The answer is that the "b" result will be the value for "b" in one of the input rows that form the aggregate. The problem is that you usually do not know which input row is used to compute "b", and so in many cases the value for "b" is undefined.

Special processing occurs when the aggregate function is either min() or max(). Example:

SELECT a, b, max(c) FROM tab1 GROUP BY a;

If there is exactly one min() or max() aggregate in the query, then all bare columns in the result set take values from an input row which also contains the minimum or maximum. So in the query above, the value of the "b" column in the output will be the value of the "b" column in the input row that has the largest "c" value. There are limitations on this special behavior of min() and max():

  1. If the same minimum or maximum value occurs on two or more rows, then bare values might be selected from any of those rows. The choice is arbitrary. There is no way to predict from which row the bare values will be choosen. The choice might be different for different bare columns within the same query.

  2. If there are two or more min() or max() aggregates in the query, then bare column values will be taken from one of the rows on which one of the aggregates has their minimum or maximum value. The choice of which min() or max() aggregate determines the selection of bare column values is arbitrary. The choice might be different for different bare columns within the same query.

  3. This special processing for min() or max() aggregates only works for the built-in implementation of those aggregates. If an application overrides the built-in min() or max() aggregates with application-defined alternatives, then the values selected for bare columns will be taken from an arbitrary row.

Most other SQL database engines disallow bare columns. If you include a bare column in a query, other database engines will usually raise an error. The ability to include bare columns in a query is an SQLite-specific extension.

2.6. Removal of duplicate rows (DISTINCT processing)

One of the ALL or DISTINCT keywords may follow the SELECT keyword in a simple SELECT statement. If the simple SELECT is a SELECT ALL, then the entire set of result rows are returned by the SELECT. If neither ALL or DISTINCT are present, then the behavior is as if ALL were specified. If the simple SELECT is a SELECT DISTINCT, then duplicate rows are removed from the set of result rows before it is returned. For the purposes of detecting duplicate rows, two NULL values are considered to be equal. The usual rules apply for selecting a collation sequence to compare text values.

3. Compound Select Statements

Two or more simple SELECT statements may be connected together to form a compound SELECT using the UNION, UNION ALL, INTERSECT or EXCEPT operator, as shown by the following diagram:

compound-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr UNION UNION ALL select-core INTERSECT EXCEPT ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

select-core:

SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , ,

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

In a compound SELECT, all the constituent SELECTs must return the same number of result columns. As the components of a compound SELECT must be simple SELECT statements, they may not contain ORDER BY or LIMIT clauses. ORDER BY and LIMIT clauses may only occur at the end of the entire compound SELECT, and then only if the final element of the compound is not a VALUES clause.

A compound SELECT created using UNION ALL operator returns all the rows from the SELECT to the left of the UNION ALL operator, and all the rows from the SELECT to the right of it. The UNION operator works the same way as UNION ALL, except that duplicate rows are removed from the final result set. The INTERSECT operator returns the intersection of the results of the left and right SELECTs. The EXCEPT operator returns the subset of rows returned by the left SELECT that are not also returned by the right-hand SELECT. Duplicate rows are removed from the results of INTERSECT and EXCEPT operators before the result set is returned.

For the purposes of determining duplicate rows for the results of compound SELECT operators, NULL values are considered equal to other NULL values and distinct from all non-NULL values. The collation sequence used to compare two text values is determined as if the columns of the left and right-hand SELECT statements were the left and right-hand operands of the equals (=) operator, except that greater precedence is not assigned to a collation sequence specified with the postfix COLLATE operator. No affinity transformations are applied to any values when comparing rows as part of a compound SELECT.

When three or more simple SELECTs are connected into a compound SELECT, they group from left to right. In other words, if "A", "B" and "C" are all simple SELECT statements, (A op B op C) is processed as ((A op B) op C).

4. The ORDER BY clause

If a SELECT statement that returns more than one row does not have an ORDER BY clause, the order in which the rows are returned is undefined. Or, if a SELECT statement does have an ORDER BY clause, then the list of expressions attached to the ORDER BY determine the order in which rows are returned to the user.

In a compound SELECT statement, only the last or right-most simple SELECT may have an ORDER BY clause. That ORDER BY clause will apply across all elements of the compound. If the right-most element of a compound SELECT is a VALUES clause, then no ORDER BY clause is allowed on that statement.

Rows are first sorted based on the results of evaluating the left-most expression in the ORDER BY list, then ties are broken by evaluating the second left-most expression and so on. The order in which two rows for which all ORDER BY expressions evaluate to equal values are returned is undefined. Each ORDER BY expression may be optionally followed by one of the keywords ASC (smaller values are returned first) or DESC (larger values are returned first). If neither ASC or DESC are specified, rows are sorted in ascending (smaller values first) order by default.

SQLite considers NULL values to be smaller than any other values for sorting purposes. Hence, NULLs naturally appear at the beginning of an ASC order-by and at the end of a DESC order-by. This can be changed using the "ASC NULLS LAST" or "DESC NULLS FIRST" syntax.

Each ORDER BY expression is processed as follows:

  1. If the ORDER BY expression is a constant integer K then the expression is considered an alias for the K-th column of the result set (columns are numbered from left to right starting with 1).

  2. If the ORDER BY expression is an identifier that corresponds to the alias of one of the output columns, then the expression is considered an alias for that column.

  3. Otherwise, if the ORDER BY expression is any other expression, it is evaluated and the returned value used to order the output rows. If the SELECT statement is a simple SELECT, then an ORDER BY may contain any arbitrary expressions. However, if the SELECT is a compound SELECT, then ORDER BY expressions that are not aliases to output columns must be exactly the same as an expression used as an output column.

For the purposes of sorting rows, values are compared in the same way as for comparison expressions. The collation sequence used to compare two text values is determined as follows:

  1. If the ORDER BY expression is assigned a collation sequence using the postfix COLLATE operator, then the specified collation sequence is used.

  2. Otherwise, if the ORDER BY expression is an alias to an expression that has been assigned a collation sequence using the postfix COLLATE operator, then the collation sequence assigned to the aliased expression is used.

  3. Otherwise, if the ORDER BY expression is a column or an alias of an expression that is a column, then the default collation sequence for the column is used.

  4. Otherwise, the BINARY collation sequence is used.

In a compound SELECT statement, all ORDER BY expressions are handled as aliases for one of the result columns of the compound. If an ORDER BY expression is not an integer alias, then SQLite searches the left-most SELECT in the compound for a result column that matches either the second or third rules above. If a match is found, the search stops and the expression is handled as an alias for the result column that it has been matched against. Otherwise, the next SELECT to the right is tried, and so on. If no matching expression can be found in the result columns of any constituent SELECT, it is an error. Each term of the ORDER BY clause is processed separately and may be matched against result columns from different SELECT statements in the compound.

5. The LIMIT clause

The LIMIT clause is used to place an upper bound on the number of rows returned by the entire SELECT statement.

In a compound SELECT, only the last or right-most simple SELECT may contain a LIMIT clause. In a compound SELECT, the LIMIT clause applies to the entire compound, not just the final SELECT. If the right-most simple SELECT is a VALUES clause then no LIMIT clause is allowed.

Any scalar expression may be used in the LIMIT clause, so long as it evaluates to an integer or a value that can be losslessly converted to an integer. If the expression evaluates to a NULL value or any other value that cannot be losslessly converted to an integer, an error is returned. If the LIMIT expression evaluates to a negative value, then there is no upper bound on the number of rows returned. Otherwise, the SELECT returns the first N rows of its result set only, where N is the value that the LIMIT expression evaluates to. Or, if the SELECT statement would return less than N rows without a LIMIT clause, then the entire result set is returned.

The expression attached to the optional OFFSET clause that may follow a LIMIT clause must also evaluate to an integer, or a value that can be losslessly converted to an integer. If an expression has an OFFSET clause, then the first M rows are omitted from the result set returned by the SELECT statement and the next N rows are returned, where M and N are the values that the OFFSET and LIMIT clauses evaluate to, respectively. Or, if the SELECT would return less than M+N rows if it did not have a LIMIT clause, then the first M rows are skipped and the remaining rows (if any) are returned. If the OFFSET clause evaluates to a negative value, the results are the same as if it had evaluated to zero.

Instead of a separate OFFSET clause, the LIMIT clause may specify two scalar expressions separated by a comma. In this case, the first expression is used as the OFFSET expression and the second as the LIMIT expression. This is counter-intuitive, as when using the OFFSET clause the second of the two expressions is the OFFSET and the first the LIMIT. This reversal of the offset and limit is intentional - it maximizes compatibility with other SQL database systems. However, to avoid confusion, programmers are strongly encouraged to use the form of the LIMIT clause that uses the "OFFSET" keyword and avoid using a LIMIT clause with a comma-separated offset.

6. The VALUES clause

The phrase "VALUES(expr-list)" means the same thing as "SELECT expr-list". The phrase "VALUES(expr-list-1),...,(expr-list-N)" means the same thing as "SELECT expr-list-1 UNION ALL ... UNION ALL SELECT expr-list-N". Both forms are the same, except that the number of SELECT statements in a compound is limited by SQLITE_LIMIT_COMPOUND_SELECT whereas the number of rows in a VALUES clause has no arbitrary limit.

There are some restrictions on the use of a VALUES clause that are not shown on the syntax diagrams:

  • A VALUES clause cannot be followed by ORDER BY.

  • A VALUES clause cannot be followed by LIMIT.

7. The WITH Clause

SELECT statements may be optionally preceded by a single WITH clause that defines one or more common table expressions for use within the SELECT statement.

8. Table-valued Functions In The FROM Clause

A virtual table that contains hidden columns can be used like a table-valued function in the FROM clause. The arguments to the table-valued function become constraints on the HIDDEN columns of the virtual table. Additional information can be found in the virtual table documentation.

9. Deviations From Standard SQL

The SELECT syntax of SQLite differs slightly from standard SQL. These differences are due to several reasons:

  • In the mid-2000s, there was a lot of emphasis on keeping the library footprint as small as possible, so as not to use too much space on memory-limited flip-phones and similar.

  • During the early years of SQLite, the lead developer sought to follow Postel's Law and to be forgiving and flexible in what input was accepted.

  • There were bugs in early SQLite parsers that accepts some strange inputs.

  • The lead developer's knowledge of SQL was imperfect.

Whatever the origin of the input quirks, we generally avoid trying to "fix" them, as any new restrictions on the input syntax would likely cause at least some of the millions of applications that use SQLite to break. We do not want that. The goal of the SQLite development team is to preserve backwards compability to the fullest extent possible. Hence, if a syntax quirk is harmless, we leave it alone and document it here, rather than try to fix it.

9.1. Strange JOIN names

SQLite accepts all of the usual syntax for JOIN operators:

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

But it does not stop there. SQLite is actually very flexible in how you specify a join operator. The general syntax is:

blah blah blah JOIN

Where there are between 1 and 3 instances of "blah", each of which can be any of "CROSS", "FULL", "INNER", "LEFT", "NATURAL", "OUTER", or "RIGHT". The SQLite parser treats each of these keywords as an attribute of the join, which can be combined in any order. This creates the possibility of many new and creative join types beyond what is specified by the syntax diagram. Some of these non-standard join types are specifically disallowed. For example, you cannot say "INNER OUTER JOIN", because that would be contradictory. But you can say things like "OUTER LEFT NATURAL JOIN" which means the same as "NATURAL LEFT OUTER JOIN". Or you can say "LEFT RIGHT JOIN" which is the same as "FULL JOIN".

Remember: you can use these non-standard join types but you ought not. Stick to using standard JOIN syntax for portability with other SQL database engines.

9.2. Precedence of comma-joins and CROSS JOIN

In standard SQL, joins that use the JOIN keyword take higher precedence than comma-joins. That is to say, JOIN operators happen before comma operators. This is not the case in SQLite, where all joins have the same precedence.

Consider this example:

... FROM t1, t2 NATURAL FULL JOIN t3 ...

In standard SQL, the FULL JOIN between t2 and t3 would occur first, and then the result of the left join would be cross-joined against t1. But SQLite always handles all joins from left to right. Thus, SQLite will do a cross join on t1 and t2 first, then the result of that cross join will feed into the FULL JOIN with t3. Inner joins are inherently associative, so the difference is only evident if your FROM clause contains one or more outer joins.

You can work around this, and make your SQL statements portable across all systems, by observing the following stylistic rules:

  • Do not mix comma-joins with the JOIN keyword. It is fine to use comma-joins, but if you do, the you should use only comma-joins for the entire FROM clause.

  • Prefer LEFT JOIN over other outer join operators.

  • When in doubt, use parentheses to specify the exact join order that you intend.

Any one of these suggestions is sufficient to avoid problems, and most programmers instinctively follow all of these suggestions without having to be told, and so the lack of precedence difference between comma-joins and the JOIN keyword in SQLite rarely comes up in practice. But you should be aware of the problem, in case it ever does appear.

This page last modified on 2022-11-09 20:11:26 UTC


Transaction

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
Transaction

1. Transaction Control Syntax

begin-stmt:

BEGIN EXCLUSIVE TRANSACTION DEFERRED IMMEDIATE

commit-stmt:

COMMIT TRANSACTION END

rollback-stmt:

ROLLBACK TRANSACTION TO SAVEPOINT savepoint-name

2. Transactions

No reads or writes occur except within a transaction. Any command that accesses the database (basically, any SQL command, except a few PRAGMA statements) will automatically start a transaction if one is not already in effect. Automatically started transactions are committed when the last SQL statement finishes.

Transactions can be started manually using the BEGIN command. Such transactions usually persist until the next COMMIT or ROLLBACK command. But a transaction will also ROLLBACK if the database is closed or if an error occurs and the ROLLBACK conflict resolution algorithm is specified. See the documentation on the ON CONFLICT clause for additional information about the ROLLBACK conflict resolution algorithm.

END TRANSACTION is an alias for COMMIT.

Transactions created using BEGIN...COMMIT do not nest. For nested transactions, use the SAVEPOINT and RELEASE commands. The "TO SAVEPOINT name" clause of the ROLLBACK command shown in the syntax diagram above is only applicable to SAVEPOINT transactions. An attempt to invoke the BEGIN command within a transaction will fail with an error, regardless of whether the transaction was started by SAVEPOINT or a prior BEGIN. The COMMIT command and the ROLLBACK command without the TO clause work the same on SAVEPOINT transactions as they do with transactions started by BEGIN.

2.1. Read transactions versus write transactions

SQLite supports multiple simultaneous read transactions coming from separate database connections, possibly in separate threads or processes, but only one simultaneous write transaction.

A read transaction is used for reading only. A write transaction allows both reading and writing. A read transaction is started by a SELECT statement, and a write transaction is started by statements like CREATE, DELETE, DROP, INSERT, or UPDATE (collectively "write statements"). If a write statement occurs while a read transaction is active, then the read transaction is upgraded to a write transaction if possible. If some other database connection has already modified the database or is already in the process of modifying the database, then upgrading to a write transaction is not possible and the write statement will fail with SQLITE_BUSY.

While a read transaction is active, any changes to the database that are implemented by separate database connections will not be seen by the database connection that started the read transaction. If database connection X is holding a read transaction, it is possible that some other database connection Y might change the content of the database while X's transaction is still open, however X will not be able to see those changes until after the transaction ends. While its read transaction is active, X will continue to see an historic snapshot of the database prior to the changes implemented by Y.

2.2. DEFERRED, IMMEDIATE, and EXCLUSIVE transactions

Transactions can be DEFERRED, IMMEDIATE, or EXCLUSIVE. The default transaction behavior is DEFERRED.

DEFERRED means that the transaction does not actually start until the database is first accessed. Internally, the BEGIN DEFERRED statement merely sets a flag on the database connection that turns off the automatic commit that would normally occur when the last statement finishes. This causes the transaction that is automatically started to persist until an explicit COMMIT or ROLLBACK or until a rollback is provoked by an error or an ON CONFLICT ROLLBACK clause. If the first statement after BEGIN DEFERRED is a SELECT, then a read transaction is started. Subsequent write statements will upgrade the transaction to a write transaction if possible, or return SQLITE_BUSY. If the first statement after BEGIN DEFERRED is a write statement, then a write transaction is started.

IMMEDIATE causes the database connection to start a new write immediately, without waiting for a write statement. The BEGIN IMMEDIATE might fail with SQLITE_BUSY if another write transaction is already active on another database connection.

EXCLUSIVE is similar to IMMEDIATE in that a write transaction is started immediately. EXCLUSIVE and IMMEDIATE are the same in WAL mode, but in other journaling modes, EXCLUSIVE prevents other database connections from reading the database while the transaction is underway.

2.3. Implicit versus explicit transactions

An implicit transaction (a transaction that is started automatically, not a transaction started by BEGIN) is committed automatically when the last active statement finishes. A statement finishes when its last cursor closes, which is guaranteed to happen when the prepared statement is reset or finalized. Some statements might "finish" for the purpose of transaction control prior to being reset or finalized, but there is no guarantee of this. The only way to ensure that a statement has "finished" is to invoke sqlite3_reset() or sqlite3_finalize() on that statement. An open sqlite3_blob used for incremental BLOB I/O also counts as an unfinished statement. The sqlite3_blob finishes when it is closed.

The explicit COMMIT command runs immediately, even if there are pending SELECT statements. However, if there are pending write operations, the COMMIT command will fail with an error code SQLITE_BUSY.

An attempt to execute COMMIT might also result in an SQLITE_BUSY return code if an another thread or process has an open read connection. When COMMIT fails in this way, the transaction remains active and the COMMIT can be retried later after the reader has had a chance to clear.

In very old versions of SQLite (before version 3.7.11 - 2012-03-20) the ROLLBACK will fail with an error code SQLITE_BUSY if there are any pending queries. In more recent versions of SQLite, the ROLLBACK will proceed and pending statements will often be aborted, causing them to return an SQLITE_ABORT or SQLITE_ABORT_ROLLBACK error. In SQLite version 3.8.8 (2015-01-16) and later, a pending read will continue functioning after the ROLLBACK as long as the ROLLBACK does not modify the database schema.

If PRAGMA journal_mode is set to OFF (thus disabling the rollback journal file) then the behavior of the ROLLBACK command is undefined.

3. Response To Errors Within A Transaction

If certain kinds of errors occur within a transaction, the transaction may or may not be rolled back automatically. The errors that can cause an automatic rollback include:

  • SQLITE_FULL: database or disk full
  • SQLITE_IOERR: disk I/O error
  • SQLITE_BUSY: database in use by another process
  • SQLITE_NOMEM: out of memory

For all of these errors, SQLite attempts to undo just the one statement it was working on and leave changes from prior statements within the same transaction intact and continue with the transaction. However, depending on the statement being evaluated and the point at which the error occurs, it might be necessary for SQLite to rollback and cancel the entire transaction. An application can tell which course of action SQLite took by using the sqlite3_get_autocommit() C-language interface.

It is recommended that applications respond to the errors listed above by explicitly issuing a ROLLBACK command. If the transaction has already been rolled back automatically by the error response, then the ROLLBACK command will fail with an error, but no harm is caused by this.

Future versions of SQLite may extend the list of errors which might cause automatic transaction rollback. Future versions of SQLite might change the error response. In particular, we may choose to simplify the interface in future versions of SQLite by causing the errors above to force an unconditional rollback.

This page last modified on 2023-03-14 14:31:07 UTC


UPDATE

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
UPDATE
► Table Of Contents
1. Overview
2. Details
2.1. Restrictions on UPDATE Statements Within CREATE TRIGGER
2.2. UPDATE FROM
2.2.1. UPDATE FROM in other SQL database engines
2.3. Optional LIMIT and ORDER BY Clauses

1. Overview

update-stmt:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause

column-name-list:

( column-name ) ,

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED

returning-clause:

RETURNING expr AS column-alias * ,

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

An UPDATE statement is used to modify a subset of the values stored in zero or more rows of the database table identified by the qualified-table-name specified as part of the UPDATE statement.

2. Details

If the UPDATE statement does not have a WHERE clause, all rows in the table are modified by the UPDATE. Otherwise, the UPDATE affects only those rows for which the WHERE clause boolean expression is true. It is not an error if the WHERE clause does not evaluate to true for any row in the table - this just means that the UPDATE statement affects zero rows.

The modifications made to each row affected by an UPDATE statement are determined by the list of assignments following the SET keyword. Each assignment specifies a column-name to the left of the equals sign and a scalar expression to the right. For each affected row, the named columns are set to the values found by evaluating the corresponding scalar expressions. If a single column-name appears more than once in the list of assignment expressions, all but the rightmost occurrence is ignored. Columns that do not appear in the list of assignments are left unmodified. The scalar expressions may refer to columns of the row being updated. In this case all scalar expressions are evaluated before any assignments are made.

Beginning in SQLite version 3.15.0 (2016-10-14), an assignment in the SET clause can be a parenthesized list of column names on the left and a row value of the same size on the right.

The optional "OR action" conflict clause that follows the UPDATE keyword allows the user to nominate a specific constraint conflict resolution algorithm to use during this one UPDATE command. Refer to the section entitled ON CONFLICT for additional information.

2.1. Restrictions on UPDATE Statements Within CREATE TRIGGER

The following additional syntax restrictions apply to UPDATE statements that occur within the body of a CREATE TRIGGER statement.

  • The table-name specified as part of an UPDATE statement within a trigger body must be unqualified. In other words, the schema-name. prefix on the table name of the UPDATE is not allowed within triggers. Unless the table to which the trigger is attached is in the TEMP database, the table being updated by the trigger program must reside in the same database as it. If the table to which the trigger is attached is in the TEMP database, then the unqualified name of the table being updated is resolved in the same way as it is for a top-level statement (by searching first the TEMP database, then the main database, then any other databases in the order they were attached).

  • The INDEXED BY and NOT INDEXED clauses are not allowed on UPDATE statements within triggers.

  • The LIMIT and ORDER BY clauses for UPDATE are unsupported within triggers, regardless of the compilation options used to build SQLite.

2.2. UPDATE FROM

The UPDATE-FROM idea is an extension to SQL that allows an UPDATE statement to be driven by other tables in the database. The "target" table is the specific table that is being updated. With UPDATE-FROM you can join the target table against other tables in the database in order to help compute which rows need updating and what the new values should be on those rows. UPDATE-FROM is supported beginning in SQLite version 3.33.0 (2020-08-14).

Other relation database engines also implement UPDATE-FROM, but because the construct is not part of the SQL standards, each product implements UPDATE-FROM differently. The SQLite implementation strives to be compatible with PostgreSQL. The SQL Server and MySQL implementations of the same idea work a little differently.

As an example of how UPDATE-FROM can be useful, suppose you have a point-of-sale application that accumulates purchases in the SALES table. At the end of the day, you want to adjust the INVENTORY table according to the daily sales. To do this, you can run an UPDATE against the INVENTORY table that adjusts the quantity by the aggregated sales for the day. The statement would look like this:

UPDATE inventory
   SET quantity = quantity - daily.amt
  FROM (SELECT sum(quantity) AS amt, itemId FROM sales GROUP BY 2) AS daily
 WHERE inventory.itemId = daily.itemId;

The subquery in the FROM clause computes the amount by which the inventory should be reduced for each itemId. That subquery is joined against the inventory table and the quantity of each affected inventory row is reduced by the appropriate amount.

The target table is not included in the FROM clause, unless the intent is to do a self-join against the target table. In the event of a self-join, the table in the FROM clause must be aliased to a different name than the target table.

If the join between the target table and the FROM clause results in multiple output rows for the same target table row, then only one of those output rows is used for updating the target table. The output row selected is arbitrary and might change from one release of SQLite to the next, or from one run to the next.

2.2.1. UPDATE FROM in other SQL database engines

SQL Server also supports UPDATE FROM, but in SQL Server the target table must be included in the FROM clause. In other words, the target table is named twice in the statement. With SQL Server, the inventory adjustment statement demonstrated above would be written like this:

UPDATE inventory
   SET quantity = quantity - daily.amt
  FROM inventory,
       (SELECT sum(quantity) AS amt, itemId FROM sales GROUP BY 2) AS daily
 WHERE inventory.itemId = daily.itemId;

MySQL supports the UPDATE FROM idea, but it does so without using a FROM clause. Instead, the complete join specification is given in between the UPDATE and SET keywords. The equivalent MySQL statement would be like this:

UPDATE inventory JOIN
       (SELECT sum(quantity) AS amt, itemId FROM sales GROUP BY 2) AS daily
       USING( itemId )
   SET inventory.quantity = inventory.quantity - daily.amt;

The MySQL UPDATE statement does not have just one target table like other systems. Any of the tables that participate in the join can be modified in the SET clause. The MySQL UPDATE syntax allows you to update multiple tables at once!

2.3. Optional LIMIT and ORDER BY Clauses

If SQLite is built with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option then the syntax of the UPDATE statement is extended with optional ORDER BY and LIMIT clauses as follows:

update-stmt-limited:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause ORDER BY ordering-term , LIMIT expr OFFSET expr , expr

If an UPDATE statement has a LIMIT clause, the maximum number of rows that will be updated is found by evaluating the accompanying expression and casting it to an integer value. A negative value is interpreted as "no limit".

If the LIMIT expression evaluates to non-negative value N and the UPDATE statement has an ORDER BY clause, then all rows that would be updated in the absence of the LIMIT clause are sorted according to the ORDER BY and the first N updated. If the UPDATE statement also has an OFFSET clause, then it is similarly evaluated and cast to an integer value. If the OFFSET expression evaluates to a non-negative value M, then the first M rows are skipped and the following N rows updated instead.

If the UPDATE statement has no ORDER BY clause, then all rows that would be updated in the absence of the LIMIT clause are assembled in an arbitrary order before applying the LIMIT and OFFSET clauses to determine which are actually updated.

The ORDER BY clause on an UPDATE statement is used only to determine which rows fall within the LIMIT. The order in which rows are modified is arbitrary and is not influenced by the ORDER BY clause.

This page last modified on 2022-01-08 05:02:57 UTC


UPSERT

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
UPSERT

1. Syntax

upsert-clause:

ON CONFLICT ( indexed-column ) WHERE expr DO , conflict target UPDATE SET column-name-list = expr WHERE expr NOTHING , column-name

column-name-list:

( column-name ) ,

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

indexed-column:

column-name COLLATE collation-name DESC expr ASC

2. Description

UPSERT is a clause added to INSERT that causes the INSERT to behave as an UPDATE or a no-op if the INSERT would violate a uniqueness constraint. UPSERT is not standard SQL. UPSERT in SQLite follows the syntax established by PostgreSQL, with generalizations.

An UPSERT is an ordinary INSERT statement that is followed by one or more ON CONFLICT clauses, as shown in the syntax diagram above.

The syntax in between the "ON CONFLICT" and "DO" keywords is called the "conflict target". The conflict target specifies a uniqueness constraint that will trigger the upsert. The conflict target may be omitted on the last ON CONFLICT clause in the INSERT statement, but is required for all other ON CONFLICT clauses.

If the insert operation would cause the conflict target uniqueness constraint to fail, then the insert is omitted and the corresponding DO NOTHING or DO UPDATE operation is performed instead. The ON CONFLICT clauses are checked in the order specified. If the last ON CONFLICT clause omits the conflict target, then it will fire if any uniqueness constraint fails which is not captured by prior ON CONFLICT clauses.

Only a single ON CONFLICT clause, specifically the first ON CONFLICT clause with a matching conflict target, may run for each row of the INSERT. When an ON CONFLICT clause fires, all subsequent ON CONFLICT clauses are bypassed for that one row.

In the case of a multi-row insert, the upsert decision is made separately for each row of the insert.

The UPSERT processing happens only for uniqueness constraints. A "uniqueness constraint" is an explicit UNIQUE or PRIMARY KEY constraint within the CREATE TABLE statement, or a unique index. UPSERT does not intervene for failed NOT NULL, CHECK, or foreign key constraints or for constraints that are implemented using triggers.

Column names in the expressions of a DO UPDATE refer to the original unchanged value of the column, before the attempted INSERT. To use the value that would have been inserted had the constraint not failed, add the special "excluded." table qualifier to the column name.

2.1. Examples

Some examples will help illustrate how UPSERT works:

CREATE TABLE vocabulary(word TEXT PRIMARY KEY, count INT DEFAULT 1);
INSERT INTO vocabulary(word) VALUES('jovial')
  ON CONFLICT(word) DO UPDATE SET count=count+1;

The upsert above inserts the new vocabulary word "jovial" if that word is not already in the dictionary, or if it is already in the dictionary, it increments the counter. The "count+1" expression could also be written as "vocabulary.count". PostgreSQL requires the second form, but SQLite accepts either.

CREATE TABLE phonebook(name TEXT PRIMARY KEY, phonenumber TEXT);
INSERT INTO phonebook(name,phonenumber) VALUES('Alice','704-555-1212')
  ON CONFLICT(name) DO UPDATE SET phonenumber=excluded.phonenumber;

In the second example, the expression in the DO UPDATE clause is of the form "excluded.phonenumber". The "excluded." prefix causes the "phonenumber" to refer to the value for phonenumber that would have been inserted had there been no conflict. Hence, the effect of the upsert is to insert a phonenumber of Alice if none exists, or to overwrite any prior phonenumber for Alice with the new one.

Note that the DO UPDATE clause acts only on the single row that experienced the constraint error during INSERT. It is not necessary to include a WHERE clause that restricts the action to that one row. The only use for the WHERE clause at the end of the DO UPDATE is to optionally change the DO UPDATE into a no-op depending on the original and/or new values. For example:

CREATE TABLE phonebook2(
  name TEXT PRIMARY KEY,
  phonenumber TEXT,
  validDate DATE
);
INSERT INTO phonebook2(name,phonenumber,validDate)
  VALUES('Alice','704-555-1212','2018-05-08')
  ON CONFLICT(name) DO UPDATE SET
    phonenumber=excluded.phonenumber,
    validDate=excluded.validDate
  WHERE excluded.validDate>phonebook2.validDate;

In this last example, the phonebook2 entry is only updated if the validDate for the newly inserted value is newer than the entry already in the table. If the table already contains an entry with the same name and a current validDate, then the WHERE clause causes the DO UPDATE to become a no-op.

2.2. Parsing Ambiguity

When the INSERT statement to which the UPSERT is attached takes its values from a SELECT statement, there is a potential parsing ambiguity. The parser might not be able to tell if the "ON" keyword is introducing the UPSERT or if it is the ON clause of a join. To work around this, the SELECT statement should always include a WHERE clause, even if that WHERE clause is just "WHERE true".

Ambiguous use of ON:

INSERT INTO t1 SELECT * FROM t2
ON CONFLICT(x) DO UPDATE SET y=excluded.y;

Ambiguity resolved using a WHERE clause:

INSERT INTO t1 SELECT * FROM t2 WHERE true
ON CONFLICT(x) DO UPDATE SET y=excluded.y;

3. Limitations

UPSERT does not currently work for virtual tables.

The conflict resolution algorithm for the update operation of the DO UPDATE clause is always ABORT. In other words, the behavior is as if the DO UPDATE clause were actually written as "DO UPDATE OR ABORT". If the DO UPDATE clause encounters any constraint violation, the entire INSERT statement rolls back and halts. This is true even if the DO UPDATE clause is contained within an INSERT statement or a trigger that specifies some other conflict resolution algorithm.

4. History

UPSERT syntax was added to SQLite with version 3.24.0 (2018-06-04). The original implementation closely followed the PostgreSQL syntax in that it only permitted a single ON CONFLICT clause and it required a conflict target for on DO UPDATE. The syntax was generalized to permit multiple ON CONFLICT clauses and to allow DO UPDATE resolution without a conflict target in SQLite version 3.35.0 (2021-03-12).

This page last modified on 2022-01-08 05:02:57 UTC


VACUUM

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
VACUUM

1. Syntax

vacuum-stmt:

VACUUM schema-name INTO filename

2. Description

The VACUUM command rebuilds the database file, repacking it into a minimal amount of disk space. There are several reasons an application might do this:

  • Unless SQLite is running in "auto_vacuum=FULL" mode, when a large amount of data is deleted from the database file it leaves behind empty space, or "free" database pages. This means the database file might be larger than strictly necessary. Running VACUUM to rebuild the database reclaims this space and reduces the size of the database file.

  • Frequent inserts, updates, and deletes can cause the database file to become fragmented - where data for a single table or index is scattered around the database file. Running VACUUM ensures that each table and index is largely stored contiguously within the database file. In some cases, VACUUM may also reduce the number of partially filled pages in the database, reducing the size of the database file further.

  • When content is deleted from an SQLite database, the content is not usually erased but rather the space used to hold the content is marked as being available for reuse. This can allow deleted content to be recovered by a hacker or by forensic analysis. Running VACUUM will clean the database of all traces of deleted content, thus preventing an adversary from recovering deleted content. Using VACUUM in this way is an alternative to setting PRAGMA secure_delete=ON.

  • Normally, the database page_size and whether or not the database supports auto_vacuum must be configured before the database file is actually created. However, when not in write-ahead log mode, the page_size and/or auto_vacuum properties of an existing database may be changed by using the page_size and/or pragma auto_vacuum pragmas and then immediately VACUUMing the database. When in write-ahead log mode, only the auto_vacuum support property can be changed using VACUUM.

By default, VACUUM operates on the main database. Attached databases can be vacuumed by appending the appropriate schema-name to the VACUUM statement.

Compatibility Warning: The ability to vacuum attached databases was added in version 3.15.0 (2016-10-14). Prior to that, a schema-name added to the VACUUM statement would be silently ignored and the "main" schema would be vacuumed.

2.1. VACUUM with an INTO clause

If the INTO clause is included, then the original database file is unchanged and a new database is created in a file named by the argument to the INTO clause. The argument is a scalar expression, such as a text literal. The new database will contain the same logical content as the original database, fully vacuumed.

The VACUUM command with an INTO clause is an alternative to the backup API for generating backup copies of a live database. The advantage of using VACUUM INTO is that the resulting backup database is minimal in size and hence the amount of filesystem I/O may be reduced. Also, all deleted content is purged from the backup, leaving behind no forensic traces. On the other hand, the backup API uses fewer CPU cycles and can be executed incrementally.

The filename in the INTO clause can be an arbitrary SQL expression that evaluates to a string. The file named by the INTO clause must not previously exist, or else it must be an empty file, or the VACUUM INTO command will fail with an error.

The argument to INTO can be a URI filename if URI filenames are enabled. URL filenames are enabled if any of the following are true:

  • The SQLite library was compiled with -DSQLITE_USE_URI=1.
  • The sqlite3_config(SQLITE_CONFIG_URI,1) interfaces was invoked at start-time.
  • The database connection that is running the VACUUM INTO statement was originally opened using the SQLITE_OPEN_URI flag.

The VACUUM INTO command is transactional in the sense that the generated output database is a consistent snapshot of the original database. However, if the VACUUM INTO command is interrupted by an unplanned shutdown or power lose, then the generated output database might be incomplete and corrupt. Also, SQLite does not invoke fsync() or FlushFileBuffers() on the generated database to ensure that it has reached non-volatile storage before completing.

3. How VACUUM works

The VACUUM command works by copying the contents of the database into a temporary database file and then overwriting the original with the contents of the temporary file. When overwriting the original, a rollback journal or write-ahead log WAL file is used just as it would be for any other database transaction. This means that when VACUUMing a database, as much as twice the size of the original database file is required in free disk space.

The VACUUM INTO command works the same way except that it uses the file named on the INTO clause in place of the temporary database and omits the step of copying the vacuumed database back over top of the original database.

The VACUUM command may change the ROWIDs of entries in any tables that do not have an explicit INTEGER PRIMARY KEY.

A VACUUM will fail if there is an open transaction on the database connection that is attempting to run the VACUUM. Unfinalized SQL statements typically hold a read transaction open, so the VACUUM might fail if there are unfinalized SQL statements on the same connection. VACUUM (but not VACUUM INTO) is a write operation and so if another database connection is holding a lock that prevents writes, then the VACUUM will fail.

An alternative to using the VACUUM command to reclaim space after data has been deleted is auto-vacuum mode, enabled using the auto_vacuum pragma. When auto_vacuum is enabled for a database free pages may be reclaimed after deleting data, causing the file to shrink, without rebuilding the entire database using VACUUM. However, using auto_vacuum can lead to extra database file fragmentation. And auto_vacuum does not compact partially filled pages of the database as VACUUM does.

This page last modified on 2023-03-17 22:28:45 UTC


The WITH Clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase
The WITH Clause
► Table Of Contents
1. Overview
2. Ordinary Common Table Expressions
3. Recursive Common Table Expressions
3.1. Recursive Query Examples
3.2. Hierarchical Query Examples
3.3. Queries Against A Graph
3.4. Controlling Depth-First Versus Breadth-First Search Of a Tree Using ORDER BY
3.5. Outlandish Recursive Query Examples
4. Materialization Hints
5. Limitations And Caveats

1. Overview

with-clause:

WITH RECURSIVE cte-table-name AS NOT MATERIALIZED ( select-stmt ) MATERIALIZED ,

cte-table-name:

table-name ( column-name ) ,

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

compound-operator:

UNION UNION INTERSECT EXCEPT ALL

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

filter-clause:

FILTER ( WHERE expr )

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

type-name:

name ( signed-number , signed-number ) ( signed-number )

signed-number:

+ numeric-literal -

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint

join-constraint:

USING ( column-name ) , ON expr

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

result-column:

expr AS column-alias * table-name . *

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

Common Table Expressions or CTEs act like temporary views that exist only for the duration of a single SQL statement. There are two kinds of common table expressions: "ordinary" and "recursive". Ordinary common table expressions are helpful for making queries easier to understand by factoring subqueries out of the main SQL statement. Recursive common table expressions provide the ability to do hierarchical or recursive queries of trees and graphs, a capability that is not otherwise available in the SQL language.

All common table expressions (ordinary and recursive) are created by prepending a WITH clause in front of a SELECT, INSERT, DELETE, or UPDATE statement. A single WITH clause can specify one or more common table expressions, some of which are ordinary and some of which are recursive.

2. Ordinary Common Table Expressions

An ordinary common table expression works as if it were a view that exists for the duration of a single statement. Ordinary common table expressions are useful for factoring out subqueries and making the overall SQL statement easier to read and understand.

A WITH clause can contain ordinary common table expressions even if it includes the RECURSIVE keyword. The use of RECURSIVE does not force common table expressions to be recursive.

3. Recursive Common Table Expressions

A recursive common table expression can be used to write a query that walks a tree or graph. A recursive common table expression has the same basic syntax as an ordinary common table expression, but with the following additional attributes:

  1. The "select-stmt" must be a compound select. That is to say, the CTE body must be two or more individual SELECT statements separated by compound operators like UNION, UNION ALL, INTERSECT, or EXCEPT.
  2. One or more of the individual SELECT statements that make up the compound must be "recursive". A SELECT statement is a recursive if its FROM clause contains exactly one reference to the the CTE table (the table named on the left-hand side of the AS clause).
  3. One or more of the SELECT statements in the compound must be non-recursive.
  4. All non-recursive SELECT statements must occur before any recursive SELECT statements.
  5. The recursive SELECT statements must be separated from the non-recursive SELECT statements and from each other by the UNION or UNION ALL operators. If there are two or more recursive SELECT statements, they all must be separated from each other using the same operator that separates the first recursive SELECT from the last non-recursive SELECT statement.
  6. Recursive SELECT statements may not use aggregate functions or window functions.

To put it another way, a recursive common table expression must look something like the following:

recursive-cte:

cte-table-name AS ( initial-select UNION ALL recursive-select ) UNION

cte-table-name:

table-name ( column-name ) ,

In the diagram above, initial-select means one or more non-recursive SELECT statements and recursive-select means one or more recursive SELECT statements. The most common case is for there to be exactly one initial-select and exactly one recursive-select but more than one of each is allowed.

Call the table named by the cte-table-name in a recursive common table expression the "recursive table". In the recursive-cte bubble diagram above, the recursive table must appear exactly once in the FROM clause of each top-level SELECT statement in the recursive-select and must not appear anywhere else in either the initial-select or the recursive-select, including subqueries. The initial-select may be a compound select, but it may not include an ORDER BY, LIMIT, or OFFSET. The recursive-select may also be a compound select with the restriction that all elements of that compound must be separated by the same UNION or UNION ALL operator that separates initial-select from recursive-select. The recursive-select is allowed to include an ORDER BY, LIMIT, and/or OFFSET but may not use aggregate functions or window functions.

The ability for the recursive-select to be a compound was added in version 3.34.0 (2020-12-01). In earlier versions of SQLite, the recursive-select could only be a single simple SELECT statement.

The basic algorithm for computing the content of the recursive table is as follows:

  1. Run the initial-select and add the results to a queue.
  2. While the queue is not empty:
    1. Extract a single row from the queue.
    2. Insert that single row into the recursive table
    3. Pretend that the single row just extracted is the only row in the recursive table and run the recursive-select, adding all results to the queue.

The basic procedure above may modified by the following additional rules:

  • If a UNION operator connects the initial-select with the recursive-select, then only add rows to the queue if no identical row has been previously added to the queue. Repeated rows are discarded before being added to the queue even if the repeated rows have already been extracted from the queue by the recursion step. If the operator is UNION ALL, then all rows generated by both the initial-select and the recursive-select are always added to the queue even if they are repeats. When determining if a row is repeated, NULL values compare equal to one another and not equal to any other value.

  • The LIMIT clause, if present, determines the maximum number of rows that will ever be added to the recursive table in step 2b. Once the limit is reached, the recursion stops. A limit of zero means that no rows are ever added to the recursive table, and a negative limit means an unlimited number of rows may be added to the recursive table.

  • The OFFSET clause, if it is present and has a positive value N, prevents the first N rows from being added to the recursive table. The first N rows are still processed by the recursive-select — they just are not added to the recursive table. Rows are not counted toward fulfilling the LIMIT until all OFFSET rows have been skipped.

  • If an ORDER BY clause is present, it determines the order in which rows are extracted from the queue in step 2a. If there is no ORDER BY clause, then the order in which rows are extracted is undefined. (In the current implementation, the queue becomes a FIFO if the ORDER BY clause is omitted, but applications should not depend on that fact since it might change.)

3.1. Recursive Query Examples

The following query returns all integers between 1 and 1000000:

WITH RECURSIVE
  cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000000)
SELECT x FROM cnt;

Consider how this query works. The initial-select runs first and returns a single row with a single column "1". This one row is added to the queue. In step 2a, that one row is extracted from the queue and added to "cnt". Then the recursive-select is run in accordance with step 2c generating a single new row with value "2" to add to the queue. The queue still has one row, so step 2 repeats. The "2" row is extracted and added to the recursive table by steps 2a and 2b. Then the row containing 2 is used as if it were the complete content of the recursive table and the recursive-select is run again, resulting in a row with value "3" being added to the queue. This repeats 999999 times until finally at step 2a the only value on the queue is a row containing 1000000. That row is extracted and added to the recursive table. But this time, the WHERE clause causes the recursive-select to return no rows, so the queue remains empty and the recursion stops.

Optimization note: In the discussion above, statements like "insert the row into the recursive table" should be understood conceptually, not literally. It sounds as if SQLite is accumulating a huge table containing one million rows, then going back and scanning that table from top to bottom to generate the result. What really happens is that the query optimizer sees that values in the "cnt" recursive table are only used once. So as each row is added to the recursive table, that row is immediately returned as a result of the main SELECT statement and then discarded. SQLite does not accumulate a temporary table containing a million rows. Very little memory is needed to run the above example. However, if the example had used UNION instead of UNION ALL, then SQLite would have had to keep around all previously generated content in order to check for duplicates. For this reason, programmers should strive to use UNION ALL instead of UNION when feasible.

Here is a variation on the previous example:

WITH RECURSIVE
  cnt(x) AS (
     SELECT 1
     UNION ALL
     SELECT x+1 FROM cnt
      LIMIT 1000000
  )
SELECT x FROM cnt;

There are two differences in this variation. The initial-select is "SELECT 1" instead of "VALUES(1)". But those are just different syntaxes for saying exactly the same thing. The other change is that the recursion is stopped by a LIMIT rather than a WHERE clause. The use of LIMIT means that when the one-millionth row is added to the "cnt" table (and returned by the main SELECT, thanks to the query optimizer) then the recursion stops immediately regardless of how many rows might be left in the queue. On more complex queries, it can sometimes be difficult to ensure that the WHERE clause will eventually cause the queue to drain and the recursion to terminate. But the LIMIT clause will always stop the recursion. So it is good practice to always include a LIMIT clause as a safety if an upper bound on the size of the recursion is known.

3.2. Hierarchical Query Examples

Consider a table that describes the members of an organization as well as the chain-of-command within that organization:

CREATE TABLE org(
  name TEXT PRIMARY KEY,
  boss TEXT REFERENCES org,
  height INT,
  -- other content omitted
);

Every member in the organization has a name, and most members have a single boss. (The head of the whole organization has a NULL "boss" field.) The rows of the "org" table form a tree.

Here is a query that computes the average height over everyone in Alice's organization, including Alice:

WITH RECURSIVE
  works_for_alice(n) AS (
    VALUES('Alice')
    UNION
    SELECT name FROM org, works_for_alice
     WHERE org.boss=works_for_alice.n
  )
SELECT avg(height) FROM org
 WHERE org.name IN works_for_alice;

The next example uses two common table expressions in a single WITH clause. The following table records a family tree:

CREATE TABLE family(
  name TEXT PRIMARY KEY,
  mom TEXT REFERENCES family,
  dad TEXT REFERENCES family,
  born DATETIME,
  died DATETIME -- NULL if still alive
  -- other content
);

The "family" table is similar to the earlier "org" table except that now there are two parents to each member. We want to know all living ancestors of Alice, from oldest to youngest. An ordinary common table expression, "parent_of", is defined first. That ordinary CTE is a view that can be used to find all parents of any individual. That ordinary CTE is then used in the "ancestor_of_alice" recursive CTE. The recursive CTE is then used in the final query:

WITH RECURSIVE
  parent_of(name, parent) AS
    (SELECT name, mom FROM family UNION SELECT name, dad FROM family),
  ancestor_of_alice(name) AS
    (SELECT parent FROM parent_of WHERE name='Alice'
     UNION ALL
     SELECT parent FROM parent_of JOIN ancestor_of_alice USING(name))
SELECT family.name FROM ancestor_of_alice, family
 WHERE ancestor_of_alice.name=family.name
   AND died IS NULL
 ORDER BY born;

3.3. Queries Against A Graph

Suppose you have an undirected graph where each node is identified by an integer and edges are defined by a table like this:

CREATE TABLE edge(aa INT, bb INT);
CREATE INDEX edge_aa ON edge(aa);
CREATE INDEX edge_bb ON edge(bb);

The indexes are not required, but they do help performance for large graphs. To find all nodes of the graph that are connected to node 59, use a query similar to the following:

WITH RECURSIVE nodes(x) AS (
   SELECT 59
   UNION
   SELECT aa FROM edge JOIN nodes ON bb=x
   UNION
   SELECT bb FROM edge JOIN nodes ON aa=x
)
SELECT x FROM nodes;

The initial-select in this case is the simple query "SELECT 59". This establishes the base case. The recursive-select consists of the other two SELECT statements. The first recursive SELECT follows edges in the bb-to-aa direction and the second recursive SELECT follows edges in the aa-to-bb direction. UNION is used instead of UNION ALL to prevent the recursion from entering an infinite loop if the graph contains cycles.

Here is a real-world example of using a graph query against a directed graph: A version control system (VCS) will typically store the evolving versions of a project as a directed acyclic graph (DAG). Call each version of the project a "checkin". A single checkin can have zero or more parents. Most checkins (except the first) have a single parent, but in the case of a merge, a checkin might have two or three or more parents. A schema to keep track of checkins and the order in which they occur might look something like this:

CREATE TABLE checkin(
  id INTEGER PRIMARY KEY,
  mtime INTEGER -- timestamp when this checkin occurred
);
CREATE TABLE derivedfrom(
  xfrom INTEGER NOT NULL REFERENCES checkin, -- parent checkin
  xto INTEGER NOT NULL REFERENCES checkin,   -- derived checkin
  PRIMARY KEY(xfrom,xto)
);
CREATE INDEX derivedfrom_back ON derivedfrom(xto,xfrom);

This graph is acyclic. And we assume that the mtime of every child checkin is no less than the mtime of all its parents. But unlike the earlier examples, this graph might have multiple paths of differing lengths between any two checkins.

We want to know the twenty most recent ancestors in time (out of the thousands and thousands of ancestors in the whole DAG) for checkin "@BASELINE". (A query similar to this is used by the Fossil VCS to show the N most recent ancestors of a checkin. For example: http://www.sqlite.org/src/timeline?p=trunk&n=30.)

WITH RECURSIVE
  ancestor(id,mtime) AS (
    SELECT id, mtime FROM checkin WHERE id=@BASELINE
    UNION
    SELECT derivedfrom.xfrom, checkin.mtime
      FROM ancestor, derivedfrom, checkin
     WHERE ancestor.id=derivedfrom.xto
       AND checkin.id=derivedfrom.xfrom
     ORDER BY checkin.mtime DESC
     LIMIT 20
  )
SELECT * FROM checkin JOIN ancestor USING(id);

The "ORDER BY checkin.mtime DESC" term in the recursive-select makes the query run much faster by preventing it from following branches that merge checkins from long ago. The ORDER BY forces the recursive-select to focus on the most recent checkins, the ones we want. Without the ORDER BY on the recursive-select, one would be forced to compute the complete set of thousands of ancestors, sort them all by mtime, then take the top twenty. The ORDER BY essentially sets up a priority queue that forces the recursive query to look at the most recent ancestors first, allowing the use of a LIMIT clause to restrict the scope of the query to just the checkins of interest.

3.4. Controlling Depth-First Versus Breadth-First Search Of a Tree Using ORDER BY

An ORDER BY clause on the recursive-select can be used to control whether the search of a tree is depth-first or breadth-first. To illustrate, we will use a variation on the "org" table from an example above, without the "height" column, and with some real data inserted:

CREATE TABLE org(
  name TEXT PRIMARY KEY,
  boss TEXT REFERENCES org
) WITHOUT ROWID;
INSERT INTO org VALUES('Alice',NULL);
INSERT INTO org VALUES('Bob','Alice');
INSERT INTO org VALUES('Cindy','Alice');
INSERT INTO org VALUES('Dave','Bob');
INSERT INTO org VALUES('Emma','Bob');
INSERT INTO org VALUES('Fred','Cindy');
INSERT INTO org VALUES('Gail','Cindy');

Here is a query to show the tree structure in a breadth-first pattern:

WITH RECURSIVE
  under_alice(name,level) AS (
    VALUES('Alice',0)
    UNION ALL
    SELECT org.name, under_alice.level+1
      FROM org JOIN under_alice ON org.boss=under_alice.name
     ORDER BY 2
  )
SELECT substr('..........',1,level*3) || name FROM under_alice;

The "ORDER BY 2" (which means the same as "ORDER BY under_alice.level+1") causes higher levels in the organization chart (with smaller "level" values) to be processed first, resulting in a breadth-first search. The output is:

Alice
...Bob
...Cindy
......Dave
......Emma
......Fred
......Gail

But if we change the ORDER BY clause to add the "DESC" modifier, that will cause lower levels in the organization (with larger "level" values) to be processed first by the recursive-select, resulting in a depth-first search:

WITH RECURSIVE
  under_alice(name,level) AS (
    VALUES('Alice',0)
    UNION ALL
    SELECT org.name, under_alice.level+1
      FROM org JOIN under_alice ON org.boss=under_alice.name
     ORDER BY 2 DESC
  )
SELECT substr('..........',1,level*3) || name FROM under_alice;

The output of this revised query is:

Alice
...Bob
......Dave
......Emma
...Cindy
......Fred
......Gail

When the ORDER BY clause is omitted from the recursive-select, the queue behaves as a FIFO, which results in a breadth-first search.

3.5. Outlandish Recursive Query Examples

The following query computes an approximation of the Mandelbrot Set and outputs the result as ASCII-art:

WITH RECURSIVE
  xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),
  yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0),
  m(iter, cx, cy, x, y) AS (
    SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis
    UNION ALL
    SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m
     WHERE (x*x + y*y) < 4.0 AND iter<28
  ),
  m2(iter, cx, cy) AS (
    SELECT max(iter), cx, cy FROM m GROUP BY cx, cy
  ),
  a(t) AS (
    SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '')
    FROM m2 GROUP BY cy
  )
SELECT group_concat(rtrim(t),x'0a') FROM a;

In this query, the "xaxis" and "yaxis" CTEs define the grid of points for which the Mandelbrot Set will be approximated. Each row in the "m(iter,cx,cy,x,y)" CTE means that after "iter" iterations, the Mandelbrot iteration starting at cx,cy has reached point x,y. The number of iterations in this example is limited to 28 (which severely limits the resolution of the computation, but is sufficient for low-resolution ASCII-art output). The "m2(iter,cx,cy)" CTE holds the maximum number of iterations reached when starting at point cx,cy. Finally, each row in the "a(t)" CTE holds a string which is a single line of the output ASCII-art. The SELECT statement at the end just queries the "a" CTE to retrieve all lines of ASCII-art, one by one.

Running the query above in an SQLite command-line shell results in the following output:

                                    ....#
                                   ..#*..
                                 ..+####+.
                            .......+####....   +
                           ..##+*##########+.++++
                          .+.##################+.
              .............+###################+.+
              ..++..#.....*#####################+.
             ...+#######++#######################.
          ....+*################################.
 #############################################...
          ....+*################################.
             ...+#######++#######################.
              ..++..#.....*#####################+.
              .............+###################+.+
                          .+.##################+.
                           ..##+*##########+.++++
                            .......+####....   +
                                 ..+####+.
                                   ..#*..
                                    ....#
                                    +.

This next query solves a Sudoku puzzle. The state of the puzzle is defined by an 81-character string formed by reading entries from the puzzle box row by row from left to right and then from top to bottom. Blank squares in the puzzle are denoted by a "." character. Thus the input string:

53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79

Corresponds to a puzzle like this:

5 | 3 | 7
6 | 1 | 9 | 5
9 | 8 | 6
8 | 6 | 3
4 | 8 | 3 | 1
7 | 2 | 6
6 | 2 | 8
4 | 1 | 9 | 5
8 | 7 | 9

This is the query that solves the puzzle:

WITH RECURSIVE
  input(sud) AS (
    VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')
  ),
  digits(z, lp) AS (
    VALUES('1', 1)
    UNION ALL SELECT
    CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9
  ),
  x(s, ind) AS (
    SELECT sud, instr(sud, '.') FROM input
    UNION ALL
    SELECT
      substr(s, 1, ind-1) || z || substr(s, ind+1),
      instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )
     FROM x, digits AS z
    WHERE ind>0
      AND NOT EXISTS (
            SELECT 1
              FROM digits AS lp
             WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)
                OR z.z = substr(s, ((ind-1)%9) + (lp-1)*9 + 1, 1)
                OR z.z = substr(s, (((ind-1)/3) % 3) * 3
                        + ((ind-1)/27) * 27 + lp
                        + ((lp-1) / 3) * 6, 1)
         )
  )
SELECT s FROM x WHERE ind=0;

The "input" CTE defines the input puzzle. The "digits" CTE defines a table that holds all digits between 1 and 9. The work of solving the puzzle is undertaken by the "x" CTE. An entry in x(s,ind) means that the 81-character string "s" is a valid sudoku puzzle (it has no conflicts) and that the first unknown character is at position "ind", or ind==0 if all character positions are filled in. The goal, then, is to compute entries for "x" with an "ind" of 0.

The solver works by adding new entries to the "x" recursive table. Given prior entries, the recursive-select tries to fill in a single new position with all values between 1 and 9 that actually work in that position. The complicated "NOT EXISTS" subquery is the magic that figures out whether or not each candidate "s" string is a valid sudoku puzzle or not.

The final answer is found by looking for a string with ind==0. If the original sudoku problem did not have a unique solution, then the query will return all possible solutions. If the original problem was unsolvable, then no rows will be returned. In this case, the unique answer is:

534678912672195348198342567859761423426853791713924856961537284287419635345286179

The solution was computed in less than 300 milliseconds on a modern workstation.

4. Materialization Hints

The "AS MATERIALIZED" and "AS NOT MATERIALIZED" forms of a common table expression are non-standard SQL syntax copied from PostgreSQL. Using MATERIALIZED or NOT MATERIALIZED after the AS keyword provides non-binding hints to the query planner about how the CTE should be implemented.

If the MATERIALIZED phrase is used, then select-stmt is likely evaluated to generate an ephemeral table that is held in memory or a temporary disk file, to be used in place of the CTE table name whenever that table name appears in the subsequent SQL. Because the select-stmt is evaluated immediately, the opportunity to apply optimizations such as query flattening or the push-down optimization, is lost. (The CTE then acts as an "optimization fence".)

If the NOT MATERIALIZED phrase is used, then select-stmt is substituted as a subquery in place of every occurrence of the CTE table name. Optimizations such as flattening and push-down are then applied to the subquery as if the subquery had by used in directly. In spite of its name, the NOT MATERIALIZED phrase does not prohibit the use of materialization. The query planner is still free to implement the subquery using materialization if it feels that is the best solution. The true meaning of NOT MATERIALIZED is closer to "TREAT LIKE ANY ORDINARY VIEW OR SUBQUERY".

If neither hint is present, then SQLite 3.35.0 (2021-03-12) and later process the CTE as if the MATERIALIZED phrase were present if the CTE is used more than once, or as if the NOT MATERIALIZED phrase were present if the CTE is used only once. Prior to SQLite 3.35.0, all CTEs where treated as if the NOT MATERIALIZED phrase was present. The decision of whether to treat a specific CTE as MATERIALIZED or as NOT MATERIALIZED based on the number of uses is a heuristic that is subject to change in future releases, if we come up with a better query planning strategy. The difference is purely a matter of performance. Equivalent answers should be computed either way.

Applications should not depend upon the semantic effects of this hint with respect to when or how often user-defined functions are called. Future versions of the query planner may disregard this hint.

The MATERIALIZED and NOT MATERIALIZED hints are only available in SQLite version 3.35.0 (2021-03-12) and later.

5. Limitations And Caveats

  • The WITH clause cannot be used within a CREATE TRIGGER.

  • The WITH clause must appear at the beginning of a top-level SELECT statement or at the beginning of a subquery. The WITH clause cannot be prepended to the second or subsequent SELECT statement of a compound select.

  • The SQL:1999 spec requires that the RECURSIVE keyword follow WITH in any WITH clause that includes a recursive common table expression. However, for compatibility with SqlServer and Oracle, SQLite does not enforce this rule.

This page last modified on 2023-01-31 06:09:11 UTC


Pragma statements supported by SQLite

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

PRAGMA Statements

The 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. The PRAGMA statement is issued using the same interface as other SQLite commands (e.g. SELECT, INSERT) but is different in the following important respects:

  • The pragma command is specific to SQLite and is not compatible with any other SQL database engine.
  • Specific pragma statements may be removed and others added in future releases of SQLite. There is no guarantee of backwards compatibility.
  • 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.
  • Some pragmas take effect during the SQL compilation stage, not the execution stage. This means if using the C-language sqlite3_prepare(), sqlite3_step(), sqlite3_finalize() API (or similar in a wrapper interface), the pragma may run during the sqlite3_prepare() call, not during the sqlite3_step() call as normal SQL statements do. Or the pragma might run during sqlite3_step() just like normal SQL statements. Whether or not the pragma runs during sqlite3_prepare() or sqlite3_step() depends on the pragma and on the specific release of SQLite.
  • The EXPLAIN and EXPLAIN QUERY PLAN prefixes to SQL statements only affect the behavior of the statement during sqlite3_step(). That means that PRAGMA statements that take effect during sqlite3_prepare() will behave the same way regardless of whether or not they are prefaced by "EXPLAIN".

The C-language API for SQLite provides the SQLITE_FCNTL_PRAGMA file control which gives VFS implementations the opportunity to add new PRAGMA statements or to override the meaning of built-in PRAGMA statements.

PRAGMA command syntax

pragma-stmt:

PRAGMA schema-name . pragma-name ( pragma-value ) = pragma-value

pragma-value:

signed-number name signed-literal

signed-number:

+ numeric-literal -

A pragma can take either zero or one argument. The argument is may be either in parentheses or it may be separated from the pragma name by an equal sign. The two syntaxes yield identical results. In many pragmas, the argument is a boolean. The boolean can be one of:

1 yes true on
0 no false off

Keyword arguments can optionally appear in quotes. (Example: 'yes' [FALSE].) Some pragmas takes a string literal as their argument. When pragma takes a keyword argument, it will usually also take a numeric equivalent as well. For example, "0" and "no" mean the same thing, as does "1" and "yes". When querying the value of a setting, many pragmas return the number rather than the keyword.

A pragma may have an optional schema-name before the pragma name. The schema-name is the name of an ATTACH-ed database or "main" or "temp" for the main and the TEMP databases. If the optional schema name is omitted, "main" is assumed. In some pragmas, the schema name is meaningless and is simply ignored. In the documentation below, pragmas for which the schema name is meaningful are shown with a "schema." prefix.

PRAGMA functions

PRAGMAs that return results and that have no side-effects can be accessed from ordinary SELECT statements as table-valued functions. For each participating PRAGMA, the corresponding table-valued function has the same name as the PRAGMA with a 7-character "pragma_" prefix. The PRAGMA argument and schema, if any, are passed as arguments to the table-valued function, with the schema as an optional, last argument.

For example, information about the columns in an index can be read using the index_info pragma as follows:

PRAGMA index_info('idx52');

Or, the same content can be read using:

SELECT * FROM pragma_index_info('idx52');

The advantage of the table-valued function format is that the query can return just a subset of the PRAGMA columns, can include a WHERE clause, can use aggregate functions, and the table-valued function can be just one of several data sources in a join. For example, to get a list of all indexed columns in a schema, one could query:

SELECT DISTINCT m.name || '.' || ii.name AS 'indexed-columns'
  FROM sqlite_schema AS m,
       pragma_index_list(m.name) AS il,
       pragma_index_info(il.name) AS ii
 WHERE m.type='table'
 ORDER BY 1;

Additional notes:

  • Table-valued functions exist only for built-in PRAGMAs, not for PRAGMAs defined using the SQLITE_FCNTL_PRAGMA file control.

  • Table-valued functions exist only for PRAGMAs that return results and that have no side-effects.

  • This feature could be used to implement information schema by first creating a separate schema using

    ATTACH ':memory:' AS 'information_schema';
    Then creating VIEWs in that schema that implement the official information schema tables using table-valued PRAGMA functions.

  • The table-valued functions for PRAGMA feature was added in SQLite version 3.16.0 (2017-01-02). Prior versions of SQLite cannot use this feature.

List Of PRAGMAs

  • analysis_limit
  • application_id
  • auto_vacuum
  • automatic_index
  • busy_timeout
  • cache_size
  • cache_spill
  • case_sensitive_like
  • cell_size_check
  • checkpoint_fullfsync
  • collation_list
  • compile_options
  • count_changes¹
  • data_store_directory¹
  • data_version
  • database_list
  • default_cache_size¹
  • defer_foreign_keys
  • empty_result_callbacks¹
  • encoding
  • foreign_key_check
  • foreign_key_list
  • foreign_keys
  • freelist_count
  • full_column_names¹
  • fullfsync
  • function_list
  • hard_heap_limit
  • ignore_check_constraints
  • incremental_vacuum
  • index_info
  • index_list
  • index_xinfo
  • integrity_check
  • journal_mode
  • journal_size_limit
  • legacy_alter_table
  • legacy_file_format
  • locking_mode
  • max_page_count
  • mmap_size
  • module_list
  • optimize
  • page_count
  • page_size
  • parser_trace²
  • pragma_list
  • query_only
  • quick_check
  • read_uncommitted
  • recursive_triggers
  • reverse_unordered_selects
  • schema_version³
  • secure_delete
  • short_column_names¹
  • shrink_memory
  • soft_heap_limit
  • stats³
  • synchronous
  • table_info
  • table_list
  • table_xinfo
  • temp_store
  • temp_store_directory¹
  • threads
  • trusted_schema
  • user_version
  • vdbe_addoptrace²
  • vdbe_debug²
  • vdbe_listing²
  • vdbe_trace²
  • wal_autocheckpoint
  • wal_checkpoint
  • writable_schema³

Notes:

  1. Pragmas whose names are struck through are deprecated. Do not use them. They exist for historical compatibility.
  2. These pragmas are only available in builds using non-standard compile-time options.
  3. These pragmas are used for testing SQLite and are not recommended for use in application programs.

PRAGMA analysis_limit

PRAGMA analysis_limit;
PRAGMA analysis_limit = N;

Query or change a limit on the approximate ANALYZE setting. This is the approximate number of rows examined in each index by the ANALYZE command. If the argument N is omitted, then the analysis limit is unchanged. If the limit is zero, then the analysis limit is disabled and the ANALYZE command will examine all rows of each index. If N is greater than zero, then the analysis limit is set to N and subsequent ANALYZE commands will stop analyzing each index after it has examined approximately N rows. If N is a negative number or something other than an integer value, then the pragma behaves as if the N argument was omitted. In all cases, the value returned is the new analysis limit used for subsequent ANALYZE commands.

This pragma can be used to help the ANALYZE command run faster on large databases. The results of analysis are not as good when only part of each index is examined, but the results are usually good enough. Setting N to 100 or 1000 allows the ANALYZE command to run very quickly, even on multi-gigabyte database files. This pragma is particularly useful in combination with PRAGMA optimize.

This pragma was added in SQLite version 3.32.0 (2020-05-22). The current implementation only uses the lower 31 bits of the N value - higher order bits are silently ignored. Future versions of SQLite might begin using higher order bits. PRAGMA application_id

PRAGMA schema.application_id;
PRAGMA schema.application_id = integer ;

The application_id PRAGMA is used to query or set the 32-bit signed big-endian "Application ID" integer located at offset 68 into the database header. Applications that use SQLite as their application file-format should set the Application ID integer to a unique integer so that utilities such as file(1) can determine the specific file type rather than just reporting "SQLite3 Database". A list of assigned application IDs can be seen by consulting the magic.txt file in the SQLite source repository.

See also the user_version pragma. PRAGMA auto_vacuum

PRAGMA schema.auto_vacuum;
PRAGMA schema.auto_vacuum = 0 | NONE | 1 | FULL | 2 | INCREMENTAL;

Query or set the auto-vacuum status in the database.

The default setting for auto-vacuum is 0 or "none", unless the SQLITE_DEFAULT_AUTOVACUUM compile-time option is used. The "none" setting means that auto-vacuum is disabled. When auto-vacuum is disabled and data is deleted data from a database, the database file remains the same size. Unused database file pages are added to a "freelist" and reused for subsequent inserts. So no database file space is lost. However, the database file does not shrink. In this mode the VACUUM command can be used to rebuild the entire database file and thus reclaim unused disk space.

When the auto-vacuum mode is 1 or "full", the freelist pages are moved to the end of the database file and the database file is truncated to remove the freelist pages at every transaction commit. Note, however, that auto-vacuum only truncates the freelist pages from the file. Auto-vacuum does not defragment the database nor repack individual database pages the way that the VACUUM command does. In fact, because it moves pages around within the file, auto-vacuum can actually make fragmentation worse.

Auto-vacuuming is only possible if the database stores some additional information that allows each database page to be traced backwards to its referrer. Therefore, auto-vacuuming must be turned on before any tables are created. It is not possible to enable or disable auto-vacuum after a table has been created.

When the value of auto-vacuum is 2 or "incremental" then the additional information needed to do auto-vacuuming is stored in the database file but auto-vacuuming does not occur automatically at each commit as it does with auto_vacuum=full. In incremental mode, the separate incremental_vacuum pragma must be invoked to cause the auto-vacuum to occur.

The database connection can be changed between full and incremental autovacuum mode at any time. However, changing from "none" to "full" or "incremental" can only occur when the database is new (no tables have yet been created) or by running the VACUUM command. To change auto-vacuum modes, first use the auto_vacuum pragma to set the new desired mode, then invoke the VACUUM command to reorganize the entire database file. To change from "full" or "incremental" back to "none" always requires running VACUUM even on an empty database.

When the auto_vacuum pragma is invoked with no arguments, it returns the current auto_vacuum mode.

PRAGMA automatic_index

PRAGMA automatic_index;
PRAGMA automatic_index = boolean;

Query, set, or clear the automatic indexing capability.

Automatic indexing is enabled by default as of version 3.7.17 (2013-05-20), but this might change in future releases of SQLite. PRAGMA busy_timeout

PRAGMA busy_timeout;
PRAGMA busy_timeout = milliseconds;

Query or change the setting of the busy timeout. This pragma is an alternative to the sqlite3_busy_timeout() C-language interface which is made available as a pragma for use with language bindings that do not provide direct access to sqlite3_busy_timeout().

Each database connection can only have a single busy handler. This PRAGMA sets the busy handler for the process, possibly overwriting any previously set busy handler. PRAGMA cache_size

PRAGMA schema.cache_size;
PRAGMA schema.cache_size = pages;
PRAGMA schema.cache_size = -kibibytes;

Query or change the suggested maximum number of database disk pages that SQLite will hold in memory at once per open database file. Whether or not this suggestion is honored is at the discretion of the Application Defined Page Cache. The default page cache that is built into SQLite honors the request, however alternative application-defined page cache implementations may choose to interpret the suggested cache size in different ways or to ignore it all together. The default suggested cache size is -2000, which means the cache size is limited to 2048000 bytes of memory. The default suggested cache size can be altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. The TEMP database has a default suggested cache size of 0 pages.

If the argument N is positive then the suggested cache size is set to N. If the argument N is negative, then the number of cache pages is adjusted to be a number of pages that would use approximately abs(N*1024) bytes of memory based on the current page size. SQLite remembers the number of pages in the page cache, not the amount of memory used. So if you set the cache size using a negative number and subsequently change the page size (using the PRAGMA page_size command) then the maximum amount of cache memory will go up or down in proportion to the change in page size.

Backwards compatibility note: The behavior of cache_size with a negative N was different prior to version 3.7.10 (2012-01-16). In earlier versions, the number of pages in the cache was set to the absolute value of N.

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.

The default page cache implemention does not allocate the full amount of cache memory all at once. Cache memory is allocated in smaller chunks on an as-needed basis. The page_cache setting is a (suggested) upper bound on the amount of memory that the cache can use, not the amount of memory it will use all of the time. This is the behavior of the default page cache implementation, but an application defined page cache is free to behave differently if it wants. PRAGMA cache_spill

PRAGMA cache_spill;
PRAGMA cache_spill=boolean;
PRAGMA schema.cache_spill=N;

The cache_spill pragma enables or disables the ability of the pager to spill dirty cache pages to the database file in the middle of a transaction. Cache_spill is enabled by default and most applications should leave it that way as cache spilling is usually advantageous. However, a cache spill has the side-effect of acquiring an EXCLUSIVE lock on the database file. Hence, some applications that have large long-running transactions may want to disable cache spilling in order to prevent the application from acquiring an exclusive lock on the database until the moment that the transaction COMMITs.

The "PRAGMA cache_spill=N" form of this pragma sets a minimum cache size threshold required for spilling to occur. The number of pages in cache must exceed both the cache_spill threshold and the maximum cache size set by the PRAGMA cache_size statement in order for spilling to occur.

The "PRAGMA cache_spill=boolean" form of this pragma applies across all databases attached to the database connection. But the "PRAGMA cache_spill=N" form of this statement only applies to the "main" schema or whatever other schema is specified as part of the statement. PRAGMA case_sensitive_like

PRAGMA case_sensitive_like = boolean;

The default behavior of the LIKE operator is to ignore case for ASCII characters. Hence, by default 'a' LIKE 'A' is true. The case_sensitive_like pragma installs a new application-defined LIKE function that is either case sensitive or insensitive depending on the value of the case_sensitive_like pragma. When case_sensitive_like is disabled, the default LIKE behavior is expressed. When case_sensitive_like is enabled, case becomes significant. So, for example, 'a' LIKE 'A' is false but 'a' LIKE 'a' is still true.

This pragma uses sqlite3_create_function() to overload the LIKE and GLOB functions, which may override previous implementations of LIKE and GLOB registered by the application. This pragma only changes the behavior of the SQL LIKE operator. It does not change the behavior of the sqlite3_strlike() C-language interface, which is always case insensitive.

PRAGMA cell_size_check

PRAGMA cell_size_check
PRAGMA cell_size_check = boolean;

The cell_size_check pragma enables or disables additional sanity checking on database b-tree pages as they are initially read from disk. With cell size checking enabled, database corruption is detected earlier and is less likely to "spread". However, there is a small performance hit for doing the extra checks and so cell size checking is turned off by default. PRAGMA checkpoint_fullfsync

PRAGMA checkpoint_fullfsync
PRAGMA checkpoint_fullfsync = boolean;

Query or change the fullfsync flag for checkpoint operations. If this flag is set, then the F_FULLFSYNC syncing method is used during checkpoint operations on systems that support F_FULLFSYNC. The default value of the checkpoint_fullfsync flag is off. Only Mac OS-X supports F_FULLFSYNC.

If the fullfsync flag is set, then the F_FULLFSYNC syncing method is used for all sync operations and the checkpoint_fullfsync setting is irrelevant.

PRAGMA collation_list

PRAGMA collation_list;

Return a list of the collating sequences defined for the current database connection.

PRAGMA compile_options

PRAGMA compile_options;

This pragma returns the names of compile-time options used when building SQLite, one option per row. The "SQLITE_" prefix is omitted from the returned option names. See also the sqlite3_compileoption_get() C/C++ interface and the sqlite_compileoption_get() SQL functions.

PRAGMA count_changes

PRAGMA count_changes;
PRAGMA count_changes = boolean;

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, any changes made automatically by foreign key actions, or updates caused by an upsert.

Another way to get the row change counts is to use the sqlite3_changes() or sqlite3_total_changes() interfaces. There is a subtle different, though. When an INSERT, UPDATE, or DELETE is run against a view using an INSTEAD OF trigger, the count_changes pragma reports the number of rows in the view that fired the trigger, whereas sqlite3_changes() and sqlite3_total_changes() do not.

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA data_store_directory

PRAGMA data_store_directory;
PRAGMA data_store_directory = 'directory-name';

Query or change the value of the sqlite3_data_directory global variable, which windows operating-system interface backends use to determine where to store database files specified using a relative pathname.

Changing the data_store_directory setting is not threadsafe. Never change the data_store_directory setting if another thread within the application is running any SQLite interface at the same time. Doing so results in undefined behavior. Changing the data_store_directory setting writes to the sqlite3_data_directory global variable and that global variable is not protected by a mutex.

This facility is provided for WinRT which does not have an OS mechanism for reading or changing the current working directory. The use of this pragma in any other context is discouraged and may be disallowed in future releases.

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA data_version

PRAGMA schema.data_version;

The "PRAGMA data_version" command provides an indication that the database file has been modified. Interactive programs that hold database content in memory or that display database content on-screen can use the PRAGMA data_version command to determine if they need to flush and reload their memory or update the screen display.

The integer values returned by two invocations of "PRAGMA data_version" from the same connection will be different if changes were committed to the database by any other connection in the interim. The "PRAGMA data_version" value is unchanged for commits made on the same database connection. The behavior of "PRAGMA data_version" is the same for all database connections, including database connections in separate processes and shared cache database connections.

The "PRAGMA data_version" value is a local property of each database connection and so values returned by two concurrent invocations of "PRAGMA data_version" on separate database connections are often different even though the underlying database is identical. It is only meaningful to compare the "PRAGMA data_version" values returned by the same database connection at two different points in time. PRAGMA database_list

PRAGMA database_list;

This pragma works like a query to return one row for each database attached to the current database connection. The second column is "main" for the main database file, "temp" for the database file used to store TEMP objects, or the name of the ATTACHed database for other database files. The third column is the name of the database file itself, or an empty string if the database is not associated with a file.

PRAGMA default_cache_size
PRAGMA schema.default_cache_size;
PRAGMA schema.default_cache_size = Number-of-pages;

This pragma queries or sets the suggested maximum number of pages of disk cache that will be allocated per open database file. The difference between this pragma and cache_size is that the value set here persists across database connections. The value of the default cache size is stored in the 4-byte big-endian integer located at offset 48 in the header of the database file.

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA defer_foreign_keys

PRAGMA defer_foreign_keys
PRAGMA defer_foreign_keys = boolean;

When the defer_foreign_keys PRAGMA is on, enforcement of all foreign key constraints is delayed until the outermost transaction is committed. The defer_foreign_keys pragma defaults to OFF so that foreign key constraints are only deferred if they are created as "DEFERRABLE INITIALLY DEFERRED". The defer_foreign_keys pragma is automatically switched off at each COMMIT or ROLLBACK. Hence, the defer_foreign_keys pragma must be separately enabled for each transaction. This pragma is only meaningful if foreign key constraints are enabled, of course.

The sqlite3_db_status(db,SQLITE_DBSTATUS_DEFERRED_FKS,...) C-language interface can be used during a transaction to determine if there are deferred and unresolved foreign key constraints.

PRAGMA empty_result_callbacks

PRAGMA empty_result_callbacks;
PRAGMA empty_result_callbacks = boolean;

Query or change the empty-result-callbacks flag.

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() 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 sqlite3_exec() API to retrieve column-names even when a query returns no data.

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA encoding

PRAGMA encoding;
PRAGMA encoding = 'UTF-8';
PRAGMA encoding = 'UTF-16';
PRAGMA encoding = 'UTF-16le';
PRAGMA encoding = 'UTF-16be';

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.

The second through fifth forms of this pragma set 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". It is not possible to change the text encoding of a database after it has been created and any attempt to do so will be silently ignored.

If no encoding is first set with this pragma, then the encoding with which the main database will be created defaults to one determined by the API used to open the connection.

Once an encoding has been set for a database, it cannot be changed.

Databases created by the ATTACH command always use the same encoding as the main database. An attempt to ATTACH a database with a different text encoding from the "main" database will fail.

PRAGMA foreign_key_check

PRAGMA schema.foreign_key_check;
PRAGMA schema.foreign_key_check(table-name);

The foreign_key_check pragma checks the database, or the table called "table-name", for foreign key constraints that are violated. The foreign_key_check pragma returns one row output for each foreign key violation. There are four columns in each result row. The first column is the name of the table that contains the REFERENCES clause. The second column is the rowid of the row that contains the invalid REFERENCES clause, or NULL if the child table is a WITHOUT ROWID table. The third column is the name of the table that is referred to. The fourth column is the index of the specific foreign key constraint that failed. The fourth column in the output of the foreign_key_check pragma is the same integer as the first column in the output of the foreign_key_list pragma. When a "table-name" is specified, the only foreign key constraints checked are those created by REFERENCES clauses in the CREATE TABLE statement for table-name.

PRAGMA foreign_key_list

PRAGMA foreign_key_list(table-name);

This pragma returns one row for each foreign key constraint created by a REFERENCES clause in the CREATE TABLE statement of table "table-name". PRAGMA foreign_keys

PRAGMA foreign_keys;
PRAGMA foreign_keys = boolean;

Query, set, or clear the enforcement of foreign key constraints.

This pragma is a no-op within a transaction; foreign key constraint enforcement may only be enabled or disabled when there is no pending BEGIN or SAVEPOINT.

Changing the foreign_keys setting affects the execution of all statements prepared using the database connection, including those prepared before the setting was changed. Any existing statements prepared using the legacy sqlite3_prepare() interface may fail with an SQLITE_SCHEMA error after the foreign_keys setting is changed.

As of SQLite version 3.6.19, the default setting for foreign key enforcement is OFF. However, that might change in a future release of SQLite. The default setting for foreign key enforcement can be specified at compile-time using the SQLITE_DEFAULT_FOREIGN_KEYS preprocessor macro. To minimize future problems, applications should set the foreign key enforcement flag as required by the application and not depend on the default setting. PRAGMA freelist_count

PRAGMA schema.freelist_count;

Return the number of unused pages in the database file.

PRAGMA full_column_names

PRAGMA full_column_names;
PRAGMA full_column_names = boolean;

Query or change the full_column_names flag. This flag together with the short_column_names flag determine the way SQLite assigns names to result columns of SELECT statements. Result columns are named by applying the following rules in order:

  1. If there is an AS clause on the result, then the name of the column is the right-hand side of the AS clause.

  2. If the result is a general expression, not a just the name of a source table column, then the name of the result is a copy of the expression text.

  3. If the short_column_names pragma is ON, then the name of the result is the name of the source table column without the source table name prefix: COLUMN.

  4. If both pragmas short_column_names and full_column_names are OFF then case (2) applies.

  5. The name of the result column is a combination of the source table and source column name: TABLE.COLUMN

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA fullfsync

PRAGMA fullfsync
PRAGMA fullfsync = boolean;

Query or change the fullfsync flag. This flag determines whether or not the F_FULLFSYNC syncing method is used on systems that support it. The default value of the fullfsync flag is off. Only Mac OS X supports F_FULLFSYNC.

See also checkpoint_fullfsync.

PRAGMA function_list

PRAGMA function_list;

This pragma returns a list of SQL functions known to the database connection. Each row of the result describes a single calling signature for a single SQL function. Some SQL functions will have multiple rows in the result set if they can (for example) be invoked with a varying number of arguments or can accept text in various encodings. PRAGMA hard_heap_limit

PRAGMA hard_heap_limit
PRAGMA hard_heap_limit=N

This pragma invokes the sqlite3_hard_heap_limit64() interface with the argument N, if N is specified and N is a positive integer that is less than the current hard heap limit. The hard_heap_limit pragma always returns the same integer that would be returned by the sqlite3_hard_heap_limit64(-1) C-language function. That is to say, it always returns the value of the hard heap limit that is set after any changes imposed by this PRAGMA.

This pragma can only lower the heap limit, never raise it. The C-language interface sqlite3_hard_heap_limit64() must be used to raise the heap limit.

See also the soft_heap_limit pragma. PRAGMA ignore_check_constraints

PRAGMA ignore_check_constraints = boolean;

This pragma enables or disables the enforcement of CHECK constraints. The default setting is off, meaning that CHECK constraints are enforced by default.

PRAGMA incremental_vacuum

PRAGMA schema.incremental_vacuum(N);
PRAGMA schema.incremental_vacuum;

The incremental_vacuum pragma causes up to N 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 auto_vacuum=incremental mode or if there are no pages on the freelist. If there are fewer than N pages on the freelist, or if N is less than 1, or if the "(N)" argument is omitted, then the entire freelist is cleared.

PRAGMA index_info

PRAGMA schema.index_info(index-name);

This pragma returns one row for each key column in the named index. A key column is a column that is actually named in the CREATE INDEX index statement or UNIQUE constraint or PRIMARY KEY constraint that created the index. Index entries also usually contain auxiliary columns that point back to the table row being indexed. The auxiliary index-columns are not shown by the index_info pragma, but they are listed by the index_xinfo pragma.

Output columns from the index_info pragma are as follows:

  1. The rank of the column within the index. (0 means left-most.)
  2. The rank of the column within the table being indexed. A value of -1 means rowid and a value of -2 means that an expression is being used.
  3. The name of the column being indexed. This columns is NULL if the column is the rowid or an expression.

If there is no index named index-name but there is a WITHOUT ROWID table with that name, then (as of SQLite version 3.30.0 on 2019-10-04) this pragma returns the PRIMARY KEY columns of the WITHOUT ROWID table as they are used in the records of the underlying b-tree, which is to say with duplicate columns removed. PRAGMA index_list

PRAGMA schema.index_list(table-name);

This pragma returns one row for each index associated with the given table.

Output columns from the index_list pragma are as follows:

  1. A sequence number assigned to each index for internal tracking purposes.
  2. The name of the index.
  3. "1" if the index is UNIQUE and "0" if not.
  4. "c" if the index was created by a CREATE INDEX statement, "u" if the index was created by a UNIQUE constraint, or "pk" if the index was created by a PRIMARY KEY constraint.
  5. "1" if the index is a partial index and "0" if not.

PRAGMA index_xinfo

PRAGMA schema.index_xinfo(index-name);

This pragma returns information about every column in an index. Unlike this index_info pragma, this pragma returns information about every column in the index, not just the key columns. (A key column is a column that is actually named in the CREATE INDEX index statement or UNIQUE constraint or PRIMARY KEY constraint that created the index. Auxiliary columns are additional columns needed to locate the table entry that corresponds to each index entry.)

Output columns from the index_xinfo pragma are as follows:

  1. The rank of the column within the index. (0 means left-most. Key columns come before auxiliary columns.)
  2. The rank of the column within the table being indexed, or -1 if the index-column is the rowid of the table being indexed and -2 if the index is on an expression.
  3. The name of the column being indexed, or NULL if the index-column is the rowid of the table being indexed or an expression.
  4. 1 if the index-column is sorted in reverse (DESC) order by the index and 0 otherwise.
  5. The name for the collating sequence used to compare values in the index-column.
  6. 1 if the index-column is a key column and 0 if the index-column is an auxiliary column.

If there is no index named index-name but there is a WITHOUT ROWID table with that name, then (as of SQLite version 3.30.0 on 2019-10-04) this pragma returns the columns of the WITHOUT ROWID table as they are used in the records of the underlying b-tree, which is to say with de-duplicated PRIMARY KEY columns first followed by data columns. PRAGMA integrity_check

PRAGMA schema.integrity_check;
PRAGMA schema.integrity_check(N)
PRAGMA schema.integrity_check(TABLENAME)

This pragma does a low-level formatting and consistency check of the database. The integrity_check pragma look for:

  • Table or index entries that are out of sequence
  • Misformatted records
  • Missing pages
  • Missing or surplus index entries
  • UNIQUE, CHECK, and NOT NULL constraint errors
  • Integrity of the freelist
  • Sections of the database that are used more than once, or not at all

If the integrity_check pragma finds problems, strings are returned (as multiple rows with a single column per row) which describe the problems. Pragma integrity_check will return at most N errors before the analysis quits, with N defaulting to 100. If pragma integrity_check finds no errors, a single row with the value 'ok' is returned.

The usual case is that the entire database file is checked. However, if the argument is TABLENAME, then checking is only performed for the the table named and its associated indexes. This is called a "partial integrity check". Because only a subset of the database is checked, errors such as unused sections of the file or duplication use of the same section of the file by two or more tables cannot be detected. The freelist is only verified on a partial integrity check if TABLENAME is sqlite_schema or one of its aliases. Support for partial integrity checks was added with version 3.33.0 (2020-08-14).

PRAGMA integrity_check does not find FOREIGN KEY errors. Use the PRAGMA foreign_key_check command to find errors in FOREIGN KEY constraints.

See also the PRAGMA quick_check command which does most of the checking of PRAGMA integrity_check but runs much faster.

PRAGMA journal_mode

PRAGMA schema.journal_mode;
PRAGMA schema.journal_mode = DELETE | TRUNCATE | PERSIST | MEMORY | WAL | OFF

This pragma queries or sets the journal mode for databases associated with the current database connection.

The first form of this pragma queries the current journaling mode for database. When database is omitted, the "main" database is queried.

The second form changes the journaling mode for "database" or for all attached databases if "database" is omitted. The new journal mode is returned. If the journal mode could not be changed, the original journal mode is returned.

The DELETE journaling mode is the normal behavior. In the DELETE mode, the rollback journal is deleted at the conclusion of each transaction. Indeed, the delete operation is the action that causes the transaction to commit. (See the document titled Atomic Commit In SQLite for additional detail.)

The TRUNCATE journaling mode commits transactions by truncating the rollback journal to zero-length instead of deleting it. On many systems, truncating a file is much faster than deleting the file since the containing directory does not need to be changed.

The PERSIST journaling mode prevents the rollback journal from being deleted at the end of each transaction. Instead, the header of the journal is overwritten with zeros. This will prevent other database connections from rolling the journal back. The PERSIST journaling mode is useful as an optimization on platforms where deleting or truncating a file is much more expensive than overwriting the first block of a file with zeros. See also: PRAGMA journal_size_limit and SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT.

The MEMORY journaling mode stores the rollback journal in volatile RAM. This saves disk I/O but at the expense of database safety and integrity. If the application using SQLite crashes in the middle of a transaction when the MEMORY journaling mode is set, then the database file will very likely go corrupt.

The WAL journaling mode uses a write-ahead log instead of a rollback journal to implement transactions. The WAL journaling mode is persistent; after being set it stays in effect across multiple database connections and after closing and reopening the database. A database in WAL journaling mode can only be accessed by SQLite version 3.7.0 (2010-07-21) or later.

The OFF journaling mode disables the rollback journal completely. No rollback journal is ever created and hence there is never a rollback journal to delete. The OFF journaling mode disables the atomic commit and rollback capabilities of SQLite. The ROLLBACK command no longer works; it behaves in an undefined way. Applications must avoid using the ROLLBACK command when the journal mode is OFF. If the application crashes in the middle of a transaction when the OFF journaling mode is set, then the database file will very likely go corrupt. Without a journal, there is no way for a statement to unwind partially completed operations following a constraint error. This might also leave the database in a corrupted state. For example, if a duplicate entry causes a CREATE UNIQUE INDEX statement to fail half-way through, it will leave behind a partially created, and hence corrupt, index. Because OFF journaling mode allows the database file to be corrupted using ordinary SQL, it is disabled when SQLITE_DBCONFIG_DEFENSIVE is enabled.

Note that the journal_mode for an in-memory database is either MEMORY or OFF and can not be changed to a different value. An attempt to change the journal_mode of an in-memory database to any setting other than MEMORY or OFF is ignored. Note also that the journal_mode cannot be changed while a transaction is active.

PRAGMA journal_size_limit

PRAGMA schema.journal_size_limit
PRAGMA schema.journal_size_limit = N ;

If a database connection is operating in exclusive locking mode or in persistent journal mode (PRAGMA journal_mode=persist) then after committing a transaction the rollback journal file may remain in the file-system. This increases performance for subsequent transactions since overwriting an existing file is faster than append to a file, but it also consumes file-system space. After a large transaction (e.g. a VACUUM), the rollback journal file may consume a very large amount of space.

Similarly, in WAL mode, the write-ahead log file is not truncated following a checkpoint. Instead, SQLite reuses the existing file for subsequent WAL entries since overwriting is faster than appending.

The journal_size_limit pragma may be used to limit the size of rollback-journal and WAL files left in the file-system after transactions or checkpoints. Each time a transaction is committed or a WAL file resets, SQLite compares the size of the rollback journal file or WAL file left in the file-system to the size limit set by this pragma and if the journal or WAL file is larger it is truncated to the limit.

The second form of the pragma listed above is used to set a new limit in bytes for the specified database. A negative number implies no limit. To always truncate rollback journals and WAL files to their minimum size, set the journal_size_limit to zero. Both the first and second forms of the pragma listed above return a single result row containing a single integer column - the value of the journal size limit in bytes. The default journal size limit is -1 (no limit). The SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT preprocessor macro can be used to change the default journal size limit at compile-time.

This pragma only operates on the single database specified prior to the pragma name (or on the "main" database if no database is specified.) There is no way to change the journal size limit on all attached databases using a single PRAGMA statement. The size limit must be set separately for each attached database. PRAGMA legacy_alter_table

PRAGMA legacy_alter_table;
PRAGMA legacy_alter_table = boolean

This pragma sets or queries the value of the legacy_alter_table flag. When this flag is on, the ALTER TABLE RENAME command (for changing the name of a table) works as it did in SQLite 3.24.0 (2018-06-04) and earlier. More specifically, when this flag is on the ALTER TABLE RENAME command only rewrites the initial occurrence of the table name in its CREATE TABLE statement and in any associated CREATE INDEX and CREATE TRIGGER statements. Other references to the table are unmodified, including:

  • References to the table within the bodies of triggers and views.
  • References to the table within CHECK constraints in the original CREATE TABLE statement.
  • References to the table within the WHERE clauses of partial indexes.
The default setting for this pragma is OFF, which means that all references to the table anywhere in the schema are converted to the new name.

This pragma is provided as a work-around for older programs that contain code that expect the incomplete behavior of ALTER TABLE RENAME found in older versions of SQLite. New applications should leave this flag turned off.

For compatibility with older virtual table implementations, this flag is turned on temporarily while the sqlite3_module.xRename method is being run. The value of this flag is restored after the sqlite3_module.xRename method finishes.

The legacy alter table behavior can also be toggled on and off using the SQLITE_DBCONFIG_LEGACY_ALTER_TABLE option to the sqlite3_db_config() interface.

The legacy alter table behavior is a per-connection setting. Turning this features on or off affects all attached database files within the database connection. The setting does not persist. Changing this setting in one connection does not affect any other connections. PRAGMA legacy_file_format

PRAGMA legacy_file_format;

This pragma no longer functions. It has become a no-op. The capabilities formerly provided by PRAGMA legacy_file_format are now available using the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option to the sqlite3_db_config() C-language interface.

PRAGMA locking_mode

PRAGMA schema.locking_mode;
PRAGMA schema.locking_mode = NORMAL | EXCLUSIVE

This pragma sets or queries the database connection locking-mode. The locking-mode is either NORMAL or EXCLUSIVE.

In NORMAL locking-mode (the default unless overridden at compile-time using SQLITE_DEFAULT_LOCKING_MODE), 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.

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 released until the next time the database file is accessed.

There are three reasons to set the locking-mode to EXCLUSIVE.

  1. The application wants to prevent other processes from accessing the database file.
  2. The number of system calls for filesystem operations is reduced, possibly resulting in a small performance increase.
  3. WAL databases can be accessed in EXCLUSIVE mode without the use of shared memory. (Additional information)

When the locking_mode pragma specifies a particular database, for example:

PRAGMA main.locking_mode=EXCLUSIVE;

then the locking mode applies only to the named database. If no database name qualifier precedes the "locking_mode" keyword then the locking mode is applied to all databases, including any new databases added by subsequent ATTACH commands.

The "temp" database (in which TEMP tables and indices are stored) and in-memory databases always uses exclusive locking mode. The locking mode of temp and in-memory databases cannot be changed. All other databases use the normal locking mode by default and are affected by this pragma.

If the locking mode is EXCLUSIVE when first entering WAL journal mode, then the locking mode cannot be changed to NORMAL until after exiting WAL journal mode. If the locking mode is NORMAL when first entering WAL journal mode, then the locking mode can be changed between NORMAL and EXCLUSIVE and back again at any time and without needing to exit WAL journal mode.

PRAGMA max_page_count

PRAGMA schema.max_page_count;
PRAGMA schema.max_page_count = N;

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.

PRAGMA mmap_size

PRAGMA schema.mmap_size;
PRAGMA schema.mmap_size=N

Query or change the maximum number of bytes that are set aside for memory-mapped I/O on a single database. The first form (without an argument) queries the current limit. The second form (with a numeric argument) sets the limit for the specified database, or for all databases if the optional database name is omitted. In the second form, if the database name is omitted, the limit that is set becomes the default limit for all databases that are added to the database connection by subsequent ATTACH statements.

The argument N is the maximum number of bytes of the database file that will be accessed using memory-mapped I/O. If N is zero then memory mapped I/O is disabled. If N is negative, then the limit reverts to the default value determined by the most recent sqlite3_config(SQLITE_CONFIG_MMAP_SIZE), or to the compile time default determined by SQLITE_DEFAULT_MMAP_SIZE if not start-time limit has been set.

The PRAGMA mmap_size statement will never increase the amount of address space used for memory-mapped I/O above the hard limit set by the SQLITE_MAX_MMAP_SIZE compile-time option, nor the hard limit set at startup-time by the second argument to sqlite3_config(SQLITE_CONFIG_MMAP_SIZE)

The size of the memory-mapped I/O region cannot be changed while the memory-mapped I/O region is in active use, to avoid unmapping memory out from under running SQL statements. For this reason, the mmap_size pragma may be a no-op if the prior mmap_size is non-zero and there are other SQL statements running concurrently on the same database connection.

PRAGMA module_list

PRAGMA module_list;

This pragma returns a list of virtual table modules registered with the database connection. PRAGMA optimize

PRAGMA optimize;
PRAGMA optimize(MASK);
PRAGMA schema.optimize;
PRAGMA schema.optimize(MASK);

Attempt to optimize the database. All schemas are optimized in the first two forms, and only the specified schema is optimized in the latter two.

To achieve the best long-term query performance without the need to do a detailed engineering analysis of the application schema and SQL, it is recommended that applications run "PRAGMA optimize" (with no arguments) just before closing each database connection. Long-running applications might also benefit from setting a timer to run "PRAGMA optimize" every few hours.

This pragma is usually a no-op or nearly so and is very fast. However if SQLite feels that performing database optimizations (such as running ANALYZE or creating new indexes) will improve the performance of future queries, then some database I/O may be done. Applications that want to limit the amount of work performed can set a timer that will invoke sqlite3_interrupt() if the pragma goes on for too long. Or, since SQLite 3.32.0, the application can use PRAGMA analysis_limit=N for some small value of N (a few hundred or a few thousand) to limit the depth of analyze.

The details of optimizations performed by this pragma are expected to change and improve over time. Applications should anticipate that this pragma will perform new optimizations in future releases.

The optional MASK argument is a bitmask of optimizations to perform:

  1. Debugging mode. Do not actually perform any optimizations but instead return one line of text for each optimization that would have been done. Off by default.

  2. Run ANALYZE on tables that might benefit. On by default. See below for additional information.

  4. (Not yet implemented) Record usage and performance information from the current session in the database file so that it will be available to "optimize" pragmas run by future database connections.

  8. (Not yet implemented) Create indexes that might have been helpful to recent queries.

The default MASK is and always shall be 0xfffe. The 0xfffe mask means perform all of the optimizations listed above except Debug Mode. If new optimizations are added in the future that should be off by default, those new optimizations will be given a mask of 0x10000 or larger.

To see all optimizations that would have been done without actually doing them, run "PRAGMA optimize(-1)". To use only the ANALYZE optimization, run "PRAGMA optimize(0x02)".

Determination Of When To Run Analyze

In the current implementation, a table is analyzed if and only if all of the following are true:

  • MASK bit 0x02 is set.

  • The query planner used sqlite_stat1-style statistics for one or more indexes of the table at some point during the lifetime of the current connection.

  • One or more indexes of the table are currently unanalyzed or the number of rows in the table has increased by 25 times or more since the last time ANALYZE was run.

The rules for when tables are analyzed are likely to change in future releases. PRAGMA page_count

PRAGMA schema.page_count;

Return the total number of pages in the database file.

PRAGMA page_size

PRAGMA schema.page_size;
PRAGMA schema.page_size = bytes;

Query or set the page size of the database. The page size must be a power of two between 512 and 65536 inclusive.

When a new database is created, SQLite assigns a page size to the database based on platform and filesystem. For many years, the default page size was almost always 1024 bytes, but beginning with SQLite version 3.12.0 (2016-03-29), the default page size increased to 4096. The default page size is recommended for most applications.

Specifying a new page size does not change the page size immediately. Instead, the new page size is remembered and is used to set the page size when the database is first created, if it does not already exist when the page_size pragma is issued, or at the next VACUUM command that is run on the same database connection while not in WAL mode.

The SQLITE_DEFAULT_PAGE_SIZE compile-time option can be used to change the default page size assigned to new databases. PRAGMA parser_trace

PRAGMA parser_trace = boolean;

If SQLite has been compiled with the SQLITE_DEBUG compile-time option, then the parser_trace pragma can be used to turn on tracing for the SQL parser used internally by SQLite. This feature is used for debugging SQLite itself.

This pragma is intended for use when debugging SQLite itself. It is only available when the SQLITE_DEBUG compile-time option is used.

PRAGMA pragma_list

PRAGMA pragma_list;

This pragma returns a list of PRAGMA commands known to the database connection. PRAGMA query_only

PRAGMA query_only;
PRAGMA query_only = boolean;

The query_only pragma prevents data changes on database files when enabled. When this pragma is enabled, any attempt to CREATE, DELETE, DROP, INSERT, or UPDATE will result in an SQLITE_READONLY error. However, the database is not truly read-only. You can still run a checkpoint or a COMMIT and the return value of the sqlite3_db_readonly() routine is not affected.

PRAGMA quick_check

PRAGMA schema.quick_check;
PRAGMA schema.quick_check(N)
PRAGMA schema.quick_check(TABLENAME)

The pragma is like integrity_check except that it does not verify UNIQUE constraints and does not verify that index content matches table content. By skipping UNIQUE and index consistency checks, quick_check is able to run faster. PRAGMA quick_check runs in O(N) time whereas PRAGMA integrity_check requires O(NlogN) time where N is the total number of rows in the database. Otherwise the two pragmas are the same.

PRAGMA read_uncommitted

PRAGMA read_uncommitted;
PRAGMA read_uncommitted = boolean;

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 sqlite3_enable_shared_cache() API. Cache sharing is disabled by default.

See SQLite Shared-Cache Mode for additional information.

PRAGMA recursive_triggers

PRAGMA recursive_triggers;
PRAGMA recursive_triggers = boolean;

Query, set, or clear the recursive trigger capability.

Changing the recursive_triggers setting affects the execution of all statements prepared using the database connection, including those prepared before the setting was changed. Any existing statements prepared using the legacy sqlite3_prepare() interface may fail with an SQLITE_SCHEMA error after the recursive_triggers setting is changed.

Prior to SQLite version 3.6.18 (2009-09-11), recursive triggers were not supported. The behavior of SQLite was always as if this pragma was set to OFF. Support for recursive triggers was added in version 3.6.18 but was initially turned OFF by default, for compatibility. Recursive triggers may be turned on by default in future versions of SQLite.

The depth of recursion for triggers has a hard upper limit set by the SQLITE_MAX_TRIGGER_DEPTH compile-time option and a run-time limit set by sqlite3_limit(db,SQLITE_LIMIT_TRIGGER_DEPTH,...).

PRAGMA reverse_unordered_selects

PRAGMA reverse_unordered_selects;
PRAGMA reverse_unordered_selects = boolean;

When enabled, this PRAGMA causes many SELECT statements without an ORDER BY clause to emit their results in the reverse order from what they normally would. This can help debug applications that are making invalid assumptions about the result order. The reverse_unordered_selects pragma works for most SELECT statements, however the query planner may sometimes choose an algorithm that is not easily reversed, in which case the output will appear in the same order regardless of the reverse_unordered_selects setting.

SQLite makes no guarantees about the order of results if a SELECT omits the ORDER BY clause. Even so, the order of results does not change from one run to the next, and so many applications mistakenly come to depend on the arbitrary output order whatever that order happens to be. However, sometimes new versions of SQLite will contain optimizer enhancements that will cause the output order of queries without ORDER BY clauses to shift. When that happens, applications that depend on a certain output order might malfunction. By running the application multiple times with this pragma both disabled and enabled, cases where the application makes faulty assumptions about output order can be identified and fixed early, reducing problems that might be caused by linking against a different version of SQLite.

PRAGMA schema_version

PRAGMA schema.schema_version;
PRAGMA schema.schema_version = integer ;

The schema_version pragma will get or set the value of the schema-version integer at offset 40 in the database header.

SQLite automatically increments the schema-version whenever the schema changes. As each SQL statement runs, the schema version is checked to ensure that the schema has not changed since the SQL statement was prepared. Subverting this mechanism by using "PRAGMA schema_version=N" to change the value of the schema_version may cause SQL statement to run using an obsolete schema, which can lead to incorrect answers and/or database corruption. It is always safe to read the schema_version, but changing the schema_version can cause problems. For this reason, attempts to change the value of schema_version are a silent no-op when defensive mode is enabled for a database connection.

Warning: Misuse of this pragma can result in database corruption.

For the purposes of this pragma, the VACUUM command is considered a schema change, since VACUUM will usually alter the "rootpage" values for entries in the sqlite_schema table.

See also the application_id pragma and user_version pragma. PRAGMA secure_delete

PRAGMA schema.secure_delete;
PRAGMA schema.secure_delete = boolean|FAST

Query or change the secure-delete setting. When secure_delete is on, SQLite overwrites deleted content with zeros. The default setting for secure_delete is determined by the SQLITE_SECURE_DELETE compile-time option and is normally off. The off setting for secure_delete improves performance by reducing the number of CPU cycles and the amount of disk I/O. Applications that wish to avoid leaving forensic traces after content is deleted or updated should enable the secure_delete pragma prior to performing the delete or update, or else run VACUUM after the delete or update.

The "fast" setting for secure_delete (added circa 2017-08-01) is an intermediate setting in between "on" and "off". When secure_delete is set to "fast", SQLite will overwrite deleted content with zeros only if doing so does not increase the amount of I/O. In other words, the "fast" setting uses more CPU cycles but does not use more I/O. This has the effect of purging all old content from b-tree pages, but leaving forensic traces on freelist pages.

When there are attached databases and no database is specified in the pragma, all databases have their secure-delete setting altered. The secure-delete setting for newly attached databases is the setting of the main database at the time the ATTACH command is evaluated.

When multiple database connections share the same cache, changing the secure-delete flag on one database connection changes it for them all.

Limitation: The secure_delete pragma only causes deleted content to be scrubbed from ordinary tables. If virtual tables store content in shadow tables, then deleting content from the virtual table does not necessarily remove forensic traces from the shadow tables. In particular, the FTS3 and FTS5 virtual tables that come bundled with SQLite might leave forensic traces in their shadow tables even if the secure_delete pragma is enabled.

PRAGMA short_column_names

PRAGMA short_column_names;
PRAGMA short_column_names = boolean;

Query or change the short-column-names flag. This flag affects the way SQLite names columns of data returned by SELECT statements. See the full_column_names pragma for full details.

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA shrink_memory

PRAGMA shrink_memory

This pragma causes the database connection on which it is invoked to free up as much memory as it can, by calling sqlite3_db_release_memory().

PRAGMA soft_heap_limit

PRAGMA soft_heap_limit
PRAGMA soft_heap_limit=N

This pragma invokes the sqlite3_soft_heap_limit64() interface with the argument N, if N is specified and is a non-negative integer. The soft_heap_limit pragma always returns the same integer that would be returned by the sqlite3_soft_heap_limit64(-1) C-language function.

See also the hard_heap_limit pragma. PRAGMA stats

PRAGMA stats;

This pragma returns auxiliary information about tables and indices. The returned information is used during testing to help verify that the query planner is operating correctly. The format and meaning of this pragma will likely change from one release to the next. Because of its volatility, the behavior and output format of this pragma are deliberately undocumented.

The intended use of this pragma is only for testing and validation of SQLite. This pragma is subject to change without notice and is not recommended for use by application programs.

PRAGMA synchronous

PRAGMA schema.synchronous;
PRAGMA schema.synchronous = 0 | OFF | 1 | NORMAL | 2 | FULL | 3 | EXTRA;

Query or change the setting of the "synchronous" flag. The first (query) form will return the synchronous setting as an integer. The second form changes the synchronous setting. The meanings of the various synchronous settings are as follows:

EXTRA (3)
EXTRA synchronous is like FULL with the addition that the directory containing a rollback journal is synced after that journal is unlinked to commit a transaction in DELETE mode. EXTRA provides additional durability if the commit is followed closely by a power loss.
FULL (2)
When synchronous is FULL (2), the SQLite database engine will use the xSync method of the VFS to ensure that all content is safely written to the disk surface prior to continuing. This ensures that an operating system crash or power failure will not corrupt the database. FULL synchronous is very safe, but it is also slower. FULL is the most commonly used synchronous setting when not in WAL mode.
NORMAL (1)
When synchronous is NORMAL (1), the SQLite database engine will still sync 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 journal_mode=DELETE on an older filesystem. WAL mode is safe from corruption with synchronous=NORMAL, and probably DELETE mode is safe too on modern filesystems. WAL mode is always consistent with synchronous=NORMAL, but WAL mode does lose durability. A transaction committed in WAL mode with synchronous=NORMAL might roll back following a power loss or system crash. Transactions are durable across application crashes regardless of the synchronous setting or journal mode. The synchronous=NORMAL setting is a good choice for most applications running in WAL mode.
OFF (0)
With synchronous OFF (0), SQLite continues without syncing 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, commits can be orders of magnitude faster with synchronous OFF.

In WAL mode when synchronous is NORMAL (1), the WAL file is synchronized before each checkpoint and the database file is synchronized after each completed checkpoint and the WAL file header is synchronized when a WAL file begins to be reused after a checkpoint, but no sync operations occur during most transactions. With synchronous=FULL in WAL mode, an additional sync operation of the WAL file happens after each transaction commit. The extra WAL sync following each transaction helps ensure that transactions are durable across a power loss. Transactions are consistent with or without the extra syncs provided by synchronous=FULL. If durability is not a concern, then synchronous=NORMAL is normally all one needs in WAL mode.

The TEMP schema always has synchronous=OFF since the content of of TEMP is ephemeral and is not expected to survive a power outage. Attempts to change the synchronous setting for TEMP are silently ignored.

See also the fullfsync and checkpoint_fullfsync pragmas.

PRAGMA table_info

PRAGMA schema.table_info(table-name);

This pragma returns one row for each normal column in the named table. Columns in the result set include: "name" (its name); "type" (data type if given, else ''); "notnull" (whether or not the column can be NULL); "dflt_value" (the default value for the column); and "pk" (either zero for columns that are not part of the primary key, or the 1-based index of the column within the primary key).

The "cid" column should not be taken to mean more than "rank within the current result set".

The table named in the table_info pragma can also be a view.

This pragma does not show information about generated columns or hidden columns. Use PRAGMA table_xinfo to get a more complete list of columns that includes generated and hidden columns. PRAGMA table_list

PRAGMA table_list;
PRAGMA schema.table_list;
PRAGMA table_list(table-name);

This pragma returns information about the tables and views in the schema, one table per row of output. The table_list pragma first appeared in SQLite version 3.37.0 (2021-11-27). As of its initial release the columns returned by the table_list pragma include those listed below. Future versions of SQLite will probably add additional columns of output.

  1. schema: the schema in which the table or view appears (for example "main" or "temp").
  2. name: the name of the table or view.
  3. type: the type of object - one of "table", "view", "shadow" (for shadow tables), or "virtual" for virtual tables.
  4. ncol: the number of columns in the table, including generated columns and hidden columns.
  5. wr: 1 if the table is a WITHOUT ROWID table or 0 if is not.
  6. strict: 1 if the table is a STRICT table or 0 if it is not.
  7. Additional columns will likely be added in future releases.

The default behavior is to show all tables in all schemas. If the schema. name appears before the pragma, then only tables in that one schema are shown. If a table-name argument is supplied, then only information about that one table is returned. PRAGMA table_xinfo

PRAGMA schema.table_xinfo(table-name);

This pragma returns one row for each column in the named table, including generated columns and hidden columns. The output has the same columns as for PRAGMA table_info plus a column, "hidden", whose value signifies a normal column (0), a dynamic or stored generated column (2 or 3), or a hidden column in a virtual table (1). The rows for which this field is non-zero are those omitted for PRAGMA table_info. PRAGMA temp_store

PRAGMA temp_store;
PRAGMA temp_store = 0 | DEFAULT | 1 | FILE | 2 | MEMORY;

Query or change the setting of the "temp_store" parameter. When temp_store is DEFAULT (0), the compile-time C preprocessor macro SQLITE_TEMP_STORE is used to determine where temporary tables and indices are stored. When temp_store is MEMORY (2) temporary tables and indices are kept as if they were in pure in-memory databases. When temp_store is FILE (1) temporary tables and indices are stored in a file. The temp_store_directory pragma can be used to specify the directory containing temporary files when FILE is specified. When the temp_store setting is changed, all existing temporary tables, indices, triggers, and views are immediately deleted.

It is possible for the library compile-time C preprocessor symbol SQLITE_TEMP_STORE to override this pragma setting. The following table summarizes the interaction of the SQLITE_TEMP_STORE preprocessor macro and the temp_store pragma:

SQLITE_TEMP_STORE PRAGMA
temp_store 		Storage used for
TEMP tables and indices
0 | any | file
1 | 0 | file
1 | 1 | file
1 | 2 | memory
2 | 0 | memory
2 | 1 | file
2 | 2 | memory
3 | any | memory
PRAGMA temp_store_directory

PRAGMA temp_store_directory;
PRAGMA temp_store_directory = 'directory-name';

Query or change the value of the sqlite3_temp_directory global variable, which many operating-system interface backends use to determine where to store temporary tables and indices.

When the temp_store_directory setting is changed, all existing temporary tables, indices, triggers, and viewers in the database connection that issued the pragma are immediately deleted. In practice, temp_store_directory should be set immediately after the first database connection for a process is opened. If the temp_store_directory is changed for one database connection while other database connections are open in the same process, then the behavior is undefined and probably undesirable.

Changing the temp_store_directory setting is not threadsafe. Never change the temp_store_directory setting if another thread within the application is running any SQLite interface at the same time. Doing so results in undefined behavior. Changing the temp_store_directory setting writes to the sqlite3_temp_directory global variable and that global variable is not protected by a mutex.

The value directory-name should be enclosed in single quotes. To revert the directory to the default, set the directory-name to an empty string, e.g., PRAGMA temp_store_directory = ''. An error is raised if directory-name is not found or is not writable.

The default directory for temporary files depends on the OS. Some OS interfaces may choose to ignore this variable and place temporary files in some other directory different from the directory specified here. In that sense, this pragma is only advisory.

This pragma is deprecated and exists for backwards compatibility only. New applications should avoid using this pragma. Older applications should discontinue use of this pragma at the earliest opportunity. This pragma may be omitted from the build when SQLite is compiled using SQLITE_OMIT_DEPRECATED.

PRAGMA threads

PRAGMA threads;
PRAGMA threads = N;

Query or change the value of the sqlite3_limit(db,SQLITE_LIMIT_WORKER_THREADS,...) limit for the current database connection. This limit sets an upper bound on the number of auxiliary threads that a prepared statement is allowed to launch to assist with a query. The default limit is 0 unless it is changed using the SQLITE_DEFAULT_WORKER_THREADS compile-time option. When the limit is zero, that means no auxiliary threads will be launched.

This pragma is a thin wrapper around the sqlite3_limit(db,SQLITE_LIMIT_WORKER_THREADS,...) interface.

PRAGMA trusted_schema

PRAGMA trusted_schema;
PRAGMA trusted_schema = boolean;

The trusted_schema setting is a per-connection boolean that determines whether or not SQL functions and virtual tables that have not been security audited are allowed to be run by views, triggers, or in expressions of the schema such as CHECK constraints, DEFAULT clauses, generated columns, expression indexes, and/or partial indexes. This setting can also be controlled using the sqlite3_db_config(db,SQLITE_DBCONFIG_TRUSTED_SCHEMA,...) C-language interface.

In order to maintain backwards compatibility, this setting is ON by default. There are advantages to turning it off, and most applications will be unaffected if it is turned off. For that reason, all applications are encouraged to switch this setting off on every database connection as soon as that connection is opened.

The -DSQLITE_TRUSTED_SCHEMA=0 compile-time option will cause this setting to default to OFF. PRAGMA user_version

PRAGMA schema.user_version;
PRAGMA schema.user_version = integer ;

The user_version pragma will get or set the value of the user-version integer at offset 60 in the database header. The user-version is an integer that is available to applications to use however they want. SQLite makes no use of the user-version itself.

See also the application_id pragma and schema_version pragma. PRAGMA vdbe_addoptrace

PRAGMA vdbe_addoptrace = boolean;

If SQLite has been compiled with the SQLITE_DEBUG compile-time option, then the vdbe_addoptrace pragma can be used to cause a complete VDBE opcodes to be displayed as they are created during code generation. This feature is used for debugging SQLite itself. See the VDBE documentation for more information.

This pragma is intended for use when debugging SQLite itself. It is only available when the SQLITE_DEBUG compile-time option is used.

PRAGMA vdbe_debug

PRAGMA vdbe_debug = boolean;

If SQLite has been compiled with the SQLITE_DEBUG compile-time option, then the vdbe_debug pragma is a shorthand for three other debug-only pragmas: vdbe_addoptrace, vdbe_listing, and vdbe_trace. This feature is used for debugging SQLite itself. See the VDBE documentation for more information.

This pragma is intended for use when debugging SQLite itself. It is only available when the SQLITE_DEBUG compile-time option is used.

PRAGMA vdbe_listing

PRAGMA vdbe_listing = boolean;

If SQLite has been compiled with the SQLITE_DEBUG compile-time option, then the vdbe_listing pragma can be used to cause a complete listing of the virtual machine opcodes to appear on standard output as each statement is evaluated. With listing is on, the entire content of a program is printed just prior to beginning execution. The statement executes normally after the listing is printed. This feature is used for debugging SQLite itself. See the VDBE documentation for more information.

This pragma is intended for use when debugging SQLite itself. It is only available when the SQLITE_DEBUG compile-time option is used.

PRAGMA vdbe_trace

PRAGMA vdbe_trace = boolean;

If SQLite has been compiled with the SQLITE_DEBUG compile-time option, then the vdbe_trace pragma can be used to cause virtual machine opcodes to be printed on standard output as they are evaluated. This feature is used for debugging SQLite. See the VDBE documentation for more information.

This pragma is intended for use when debugging SQLite itself. It is only available when the SQLITE_DEBUG compile-time option is used.

PRAGMA wal_autocheckpoint

PRAGMA wal_autocheckpoint;
PRAGMA wal_autocheckpoint=N;

This pragma queries or sets the write-ahead log auto-checkpoint interval. When the write-ahead log is enabled (via the journal_mode pragma) a checkpoint will be run automatically whenever the write-ahead log equals or exceeds N pages in length. Setting the auto-checkpoint size to zero or a negative value turns auto-checkpointing off.

This pragma is a wrapper around the sqlite3_wal_autocheckpoint() C interface. All automatic checkpoints are PASSIVE.

Autocheckpointing is enabled by default with an interval of 1000 or SQLITE_DEFAULT_WAL_AUTOCHECKPOINT.

PRAGMA wal_checkpoint

PRAGMA schema.wal_checkpoint;
PRAGMA schema.wal_checkpoint(PASSIVE);
PRAGMA schema.wal_checkpoint(FULL);
PRAGMA schema.wal_checkpoint(RESTART);
PRAGMA schema.wal_checkpoint(TRUNCATE);

If the write-ahead log is enabled (via the journal_mode pragma), this pragma causes a checkpoint operation to run on database database, or on all attached databases if database is omitted. If write-ahead log mode is disabled, this pragma is a harmless no-op.

Invoking this pragma without an argument is equivalent to calling the sqlite3_wal_checkpoint() C interface.

Invoking this pragma with an argument is equivalent to calling the sqlite3_wal_checkpoint_v2() C interface with a 3rd parameter corresponding to the argument:
PASSIVE
Checkpoint as many frames as possible without waiting for any database readers or writers to finish. Sync the db file if all frames in the log are checkpointed. This mode is the same as calling the sqlite3_wal_checkpoint() C interface. The busy-handler callback is never invoked in this mode.
FULL
This mode blocks (invokes the busy-handler callback) until there is no database writer and all readers are reading from the most recent database snapshot. It then checkpoints all frames in the log file and syncs the database file. FULL blocks concurrent writers while it is running, but readers can proceed.
RESTART
This mode works the same way as FULL with the addition that after checkpointing the log file it blocks (calls the busy-handler callback) until all readers are finished with the log file. This ensures that the next client to write to the database file restarts the log file from the beginning. RESTART blocks concurrent writers while it is running, but allowed readers to proceed.
TRUNCATE
This mode works the same way as RESTART with the addition that the WAL file is truncated to zero bytes upon successful completion.

The wal_checkpoint pragma returns a single row with three integer columns. The first column is usually 0 but will be 1 if a RESTART or FULL or TRUNCATE checkpoint was blocked from completing, for example because another thread or process was actively using the database. In other words, the first column is 0 if the equivalent call to sqlite3_wal_checkpoint_v2() would have returned SQLITE_OK or 1 if the equivalent call would have returned SQLITE_BUSY. The second column is the number of modified pages that have been written to the write-ahead log file. The third column is the number of pages in the write-ahead log file that have been successfully moved back into the database file at the conclusion of the checkpoint. The second and third column are -1 if there is no write-ahead log, for example if this pragma is invoked on a database connection that is not in WAL mode.

PRAGMA writable_schema

PRAGMA writable_schema = boolean;
PRAGMA writable_schema = RESET

When this pragma is on, and the SQLITE_DBCONFIG_DEFENSIVE flag is off, then the sqlite_schema table can be changed using ordinary UPDATE, INSERT, and DELETE statements. If the argument is "RESET" then schema writing is disabled (as with "PRAGMA writable_schema=OFF") and, in addition, the schema is reloaded. Warning: misuse of this pragma can easily result in a corrupt database file.

This page last modified on 2023-02-16 21:36:11 UTC


List of SQLite Syntax Diagrams

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

List of SQLite Syntax Diagrams

  • aggregate-function-invocation
  • alter-table-stmt
  • analyze-stmt
  • attach-stmt
  • begin-stmt
  • column-constraint
  • column-def
  • column-name-list
  • comment-syntax
  • commit-stmt
  • common-table-expression
  • compound-operator
  • compound-select-stmt
  • conflict-clause
  • create-index-stmt
  • create-table-stmt
  • create-trigger-stmt
  • create-view-stmt
  • create-virtual-table-stmt
  • cte-table-name
  • delete-stmt
  • delete-stmt-limited
  • detach-stmt
  • drop-index-stmt
  • drop-table-stmt
  • drop-trigger-stmt
  • drop-view-stmt
  • expr
  • factored-select-stmt
  • filter-clause
  • foreign-key-clause
  • frame-spec
  • indexed-column
  • insert-stmt
  • join-clause
  • join-constraint
  • join-operator
  • literal-value
  • numeric-literal
  • ordering-term
  • over-clause
  • pragma-stmt
  • pragma-value
  • qualified-table-name
  • raise-function
  • recursive-cte
  • reindex-stmt
  • release-stmt
  • result-column
  • returning-clause
  • rollback-stmt
  • savepoint-stmt
  • select-core
  • select-stmt
  • signed-number
  • simple-function-invocation
  • simple-select-stmt
  • sql-stmt
  • sql-stmt-list
  • table-constraint
  • table-options
  • table-or-subquery
  • type-name
  • update-stmt
  • update-stmt-limited
  • upsert-clause
  • vacuum-stmt
  • window-defn
  • window-function-invocation
  • with-clause


Syntax Diagrams For SQLite

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

Syntax Diagrams For SQLite

aggregate-function-invocation:

aggregate-func ( DISTINCT expr ) filter-clause , *

References: expr filter-clause

See also: lang_aggfunc.html lang_expr.html#booleanexpr

alter-table-stmt:

ALTER TABLE schema-name . table-name RENAME TO new-table-name RENAME COLUMN column-name TO new-column-name ADD COLUMN column-def DROP COLUMN column-name
Used by: sql-stmt

References: column-def

See also: lang_altertable.html

analyze-stmt:

ANALYZE schema-name . table-or-index-name schema-name index-or-table-name
Used by: sql-stmt

See also: lang_analyze.html

attach-stmt:

ATTACH DATABASE expr AS schema-name
Used by: sql-stmt

References: expr

See also: lang_attach.html

begin-stmt:

BEGIN EXCLUSIVE TRANSACTION DEFERRED IMMEDIATE
Used by: sql-stmt

See also: lang_transaction.html

column-constraint:

CONSTRAINT name PRIMARY KEY DESC conflict-clause AUTOINCREMENT ASC NOT NULL conflict-clause UNIQUE conflict-clause CHECK ( expr ) DEFAULT ( expr ) literal-value signed-number COLLATE collation-name foreign-key-clause GENERATED ALWAYS AS ( expr ) VIRTUAL STORED
Used by: column-def

References: conflict-clause expr foreign-key-clause literal-value signed-number

See also: gencol.html lang_altertable.html lang_createtable.html lang_createtable.html#tablecoldef

column-def:

column-name type-name column-constraint
Used by: alter-table-stmt create-table-stmt

References: column-constraint type-name

See also: lang_altertable.html lang_altertable.html#altertabaddcol lang_createtable.html lang_createtable.html#tablecoldef

column-name-list:

( column-name ) ,
Used by: update-stmt update-stmt-limited upsert-clause

See also: lang_createtrigger.html lang_insert.html lang_update.html lang_upsert.html

comment-syntax:

-- anything-except-newline newline end-of-input /* anything-except-*/ */

See also: lang_comment.html

commit-stmt:

COMMIT TRANSACTION END
Used by: sql-stmt

See also: lang_transaction.html

common-table-expression:

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,
Used by: compound-select-stmt delete-stmt delete-stmt-limited factored-select-stmt insert-stmt select-stmt simple-select-stmt update-stmt update-stmt-limited

References: select-stmt

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

compound-operator:

UNION UNION INTERSECT EXCEPT ALL
Used by: factored-select-stmt select-stmt

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

compound-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr UNION UNION ALL select-core INTERSECT EXCEPT ordering-term , OFFSET expr , expr

References: common-table-expression expr ordering-term select-core

See also: lang_select.html#compound

conflict-clause:

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE
Used by: column-constraint table-constraint

See also: lang_altertable.html lang_conflict.html lang_createtable.html lang_createtable.html#notnullconst

create-index-stmt:

CREATE UNIQUE INDEX IF NOT EXISTS schema-name . index-name ON table-name ( indexed-column ) , WHERE expr
Used by: sql-stmt

References: expr indexed-column

See also: lang_createindex.html partialindex.html

create-table-stmt:

CREATE TEMP TEMPORARY TABLE IF NOT EXISTS schema-name . table-name ( column-def table-constraint , ) table-options , AS select-stmt
Used by: sql-stmt

References: column-def select-stmt table-constraint table-options

See also: lang_createtable.html

create-trigger-stmt:

CREATE TEMP TEMPORARY TRIGGER IF NOT EXISTS schema-name . trigger-name BEFORE AFTER INSTEAD OF DELETE INSERT UPDATE OF column-name , ON table-name FOR EACH ROW WHEN expr BEGIN update-stmt ; END insert-stmt delete-stmt select-stmt
Used by: sql-stmt

References: delete-stmt expr insert-stmt select-stmt update-stmt

See also: lang_createtrigger.html

create-view-stmt:

CREATE TEMP TEMPORARY VIEW IF NOT EXISTS schema-name . view-name ( column-name ) AS select-stmt ,
Used by: sql-stmt

References: select-stmt

See also: lang_createview.html

create-virtual-table-stmt:

CREATE VIRTUAL TABLE IF NOT EXISTS schema-name . table-name USING module-name ( module-argument ) ,
Used by: sql-stmt

See also: lang_createvtab.html

cte-table-name:

table-name ( column-name ) ,
Used by: recursive-cte with-clause

See also: lang_with.html lang_with.html#recursivecte

delete-stmt:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name returning-clause expr WHERE
Used by: create-trigger-stmt sql-stmt

References: common-table-expression expr qualified-table-name returning-clause

See also: lang_createtrigger.html lang_delete.html

delete-stmt-limited:

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name WHERE expr returning-clause ORDER BY ordering-term , LIMIT expr OFFSET expr , expr
Used by: sql-stmt

References: common-table-expression expr ordering-term qualified-table-name returning-clause

See also: lang_delete.html

detach-stmt:

DETACH DATABASE schema-name
Used by: sql-stmt

See also: lang_detach.html

drop-index-stmt:

DROP INDEX IF EXISTS schema-name . index-name
Used by: sql-stmt

See also: lang_dropindex.html

drop-table-stmt:

DROP TABLE IF EXISTS schema-name . table-name
Used by: sql-stmt

See also: lang_droptable.html

drop-trigger-stmt:

DROP TRIGGER IF EXISTS schema-name . trigger-name
Used by: sql-stmt

See also: lang_droptrigger.html

drop-view-stmt:

DROP VIEW IF EXISTS schema-name . view-name
Used by: sql-stmt

See also: lang_dropview.html

expr:

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function
Used by: aggregate-function-invocation attach-stmt column-constraint compound-select-stmt create-index-stmt create-trigger-stmt delete-stmt delete-stmt-limited factored-select-stmt filter-clause frame-spec indexed-column insert-stmt join-constraint ordering-term over-clause result-column returning-clause select-core select-stmt simple-function-invocation simple-select-stmt table-constraint table-or-subquery update-stmt update-stmt-limited upsert-clause window-defn window-function-invocation

References: filter-clause literal-value over-clause raise-function select-stmt type-name

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

factored-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr compound-operator ordering-term , OFFSET expr , expr

References: common-table-expression compound-operator expr ordering-term select-core

See also: lang_select.html

filter-clause:

FILTER ( WHERE expr )
Used by: aggregate-function-invocation expr window-function-invocation

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

foreign-key-clause:

REFERENCES foreign-table ( column-name ) , ON DELETE SET NULL UPDATE SET DEFAULT CASCADE RESTRICT NO ACTION MATCH name NOT DEFERRABLE INITIALLY DEFERRED INITIALLY IMMEDIATE
Used by: column-constraint table-constraint

See also: lang_altertable.html lang_altertable.html#altertabaddcol lang_createtable.html

frame-spec:

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS
Used by: over-clause window-defn

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

indexed-column:

column-name COLLATE collation-name DESC expr ASC
Used by: create-index-stmt table-constraint upsert-clause

References: expr

See also: lang_createindex.html lang_createtable.html lang_createtable.html#primkeyconst lang_createtable.html#uniqueconst lang_createtrigger.html lang_insert.html lang_upsert.html partialindex.html

insert-stmt:

WITH RECURSIVE common-table-expression , REPLACE INSERT OR ROLLBACK INTO ABORT FAIL IGNORE REPLACE schema-name . table-name AS alias ( column-name ) , VALUES ( expr ) , , upsert-clause select-stmt upsert-clause DEFAULT VALUES returning-clause
Used by: create-trigger-stmt sql-stmt

References: common-table-expression expr returning-clause select-stmt upsert-clause

See also: lang_createtrigger.html lang_insert.html

join-clause:

table-or-subquery join-operator table-or-subquery join-constraint
Used by: select-core select-stmt table-or-subquery update-stmt update-stmt-limited

References: join-constraint join-operator table-or-subquery

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

join-constraint:

USING ( column-name ) , ON expr
Used by: join-clause

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#fromclause lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

join-operator:

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS
Used by: join-clause

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#fromclause lang_select.html#nonstd lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

literal-value:

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE
Used by: column-constraint expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

numeric-literal:

digit . E e digit . digit - digit + 0x hexdigit

See also: lang_expr.html#litvalue

ordering-term:

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST
Used by: compound-select-stmt delete-stmt-limited factored-select-stmt over-clause select-stmt simple-select-stmt update-stmt-limited window-defn

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

over-clause:

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )
Used by: expr

References: expr frame-spec ordering-term

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

pragma-stmt:

PRAGMA schema-name . pragma-name ( pragma-value ) = pragma-value
Used by: sql-stmt

References: pragma-value

See also: pragma.html#syntax

pragma-value:

signed-number name signed-literal
Used by: pragma-stmt

References: signed-number

See also: pragma.html#syntax

qualified-table-name:

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED
Used by: delete-stmt delete-stmt-limited update-stmt update-stmt-limited

See also: lang_createtrigger.html lang_delete.html lang_indexedby.html lang_update.html

raise-function:

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL
Used by: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createtrigger.html#raise lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

recursive-cte:

cte-table-name AS ( initial-select UNION ALL recursive-select ) UNION

References: cte-table-name

See also: lang_with.html#recursivecte

reindex-stmt:

REINDEX schema-name . index-name table-name collation-name
Used by: sql-stmt

See also: lang_reindex.html

release-stmt:

RELEASE SAVEPOINT savepoint-name
Used by: sql-stmt

See also: lang_savepoint.html

result-column:

expr AS column-alias * table-name . *
Used by: select-core select-stmt

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

returning-clause:

RETURNING expr AS column-alias * ,
Used by: delete-stmt delete-stmt-limited insert-stmt update-stmt update-stmt-limited

References: expr

See also: lang_createtrigger.html lang_delete.html lang_insert.html lang_returning.html lang_update.html

rollback-stmt:

ROLLBACK TRANSACTION TO SAVEPOINT savepoint-name
Used by: sql-stmt

See also: lang_savepoint.html lang_transaction.html

savepoint-stmt:

SAVEPOINT savepoint-name
Used by: sql-stmt

See also: lang_savepoint.html

select-core:

SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , ,
Used by: compound-select-stmt factored-select-stmt simple-select-stmt

References: expr join-clause result-column table-or-subquery window-defn

See also: lang_select.html lang_select.html#compound lang_select.html#simpleselect

select-stmt:

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr
Used by: common-table-expression create-table-stmt create-trigger-stmt create-view-stmt expr insert-stmt sql-stmt table-or-subquery with-clause

References: common-table-expression compound-operator expr join-clause ordering-term result-column table-or-subquery window-defn

See also: changes.html#version_3_35_3 lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html lang_with.html#recursivecte partialindex.html releaselog/3_35_3.html releaselog/3_35_4.html releaselog/3_35_5.html

signed-number:

+ numeric-literal -
Used by: column-constraint pragma-value type-name

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html pragma.html#syntax

simple-function-invocation:

simple-func ( expr ) , *

References: expr

See also: lang_expr.html#booleanexpr

simple-select-stmt:

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

References: common-table-expression expr ordering-term select-core

See also: lang_select.html#simpleselect

sql-stmt:

EXPLAIN QUERY PLAN alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt
Used by: sql-stmt-list

References: alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt

See also: lang.html lang_explain.html

sql-stmt-list:

sql-stmt ;

References: sql-stmt

See also: lang.html

table-constraint:

CONSTRAINT name PRIMARY KEY ( indexed-column ) conflict-clause , UNIQUE CHECK ( expr ) FOREIGN KEY ( column-name ) foreign-key-clause ,
Used by: create-table-stmt

References: conflict-clause expr foreign-key-clause indexed-column

See also: lang_createtable.html lang_createtable.html#primkeyconst lang_createtable.html#tablecoldef lang_createtable.html#uniqueconst

table-options:

WITHOUT ROWID STRICT ,
Used by: create-table-stmt

See also: lang_createtable.html

table-or-subquery:

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause
Used by: join-clause select-core select-stmt update-stmt update-stmt-limited

References: expr join-clause select-stmt

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

type-name:

name ( signed-number , signed-number ) ( signed-number )
Used by: column-def expr

References: signed-number

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

update-stmt:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause
Used by: create-trigger-stmt sql-stmt

References: column-name-list common-table-expression expr join-clause qualified-table-name returning-clause table-or-subquery

See also: lang_createtrigger.html lang_update.html

update-stmt-limited:

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause ORDER BY ordering-term , LIMIT expr OFFSET expr , expr
Used by: sql-stmt

References: column-name-list common-table-expression expr join-clause ordering-term qualified-table-name returning-clause table-or-subquery

See also: lang_update.html#upfrom

upsert-clause:

ON CONFLICT ( indexed-column ) WHERE expr DO , conflict target UPDATE SET column-name-list = expr WHERE expr NOTHING , column-name
Used by: insert-stmt

References: column-name-list expr indexed-column

See also: lang_createtrigger.html lang_insert.html lang_upsert.html

vacuum-stmt:

VACUUM schema-name INTO filename
Used by: sql-stmt

See also: lang_vacuum.html

window-defn:

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )
Used by: select-core select-stmt window-function-invocation

References: expr frame-spec ordering-term

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_select.html#compound lang_select.html#simpleselect lang_update.html lang_upsert.html lang_with.html partialindex.html

window-function-invocation:

window-func ( expr ) filter-clause OVER window-name window-defn , *

References: expr filter-clause window-defn

See also: lang_expr.html#booleanexpr

with-clause:

WITH RECURSIVE cte-table-name AS NOT MATERIALIZED ( select-stmt ) MATERIALIZED ,

References: cte-table-name select-stmt

See also: lang_with.html

This page last modified on 2022-01-08 05:02:57 UTC


System.Data.SQLite

SQLite ADO.NET Provider

System.Data.SQLite Namespace

Namespace Hierarchy

Classes

Class | Description
AssemblySourceIdAttribute | Defines a source code identifier custom attribute for an assembly manifest.
AssemblySourceTimeStampAttribute | Defines a source code time-stamp custom attribute for an assembly manifest.
AuthorizerEventArgs | The data associated with a call into the authorizer.
BusyEventArgs | The event data associated with "database is busy" events.
CommitEventArgs | Event arguments raised when a transaction is being committed
ConnectionEventArgs | Event data for connection event handlers.
LogEventArgs | Event data for logging event handlers.
ProgressEventArgs | The event data associated with progress reporting events.
SQLiteBlob | Represents a single SQL blob in SQLite.
SQLiteCommand | SQLite implementation of DbCommand.
SQLiteCommandBuilder | SQLite implementation of DbCommandBuilder.
SQLiteConnection | SQLite implentation of DbConnection.
SQLiteConnectionStringBuilder | SQLite implementation of DbConnectionStringBuilder.
SQLiteContext | This class represents a context from the SQLite core library that can be passed to the sqlite3_result_*() and associated functions.
SQLiteConvert | This base class provides datatype conversion services for the SQLite provider.
SQLiteDataAdapter | SQLite implementation of DbDataAdapter.
SQLiteDataReader | SQLite implementation of DbDataReader.
SQLiteDataReaderValue | This class represents a single value to be returned from the SQLiteDataReader class via its GetBlob, GetBoolean, GetByte, GetBytes, GetChar, GetChars, GetDateTime, GetDecimal, GetDouble, GetFloat, GetGuid, GetInt16, GetInt32, GetInt64, GetString, or GetValue method. If the value of the associated public field of this class is null upon returning from the callback, the null value will only be used if the return type for the SQLiteDataReader method called is not a value type. If the value to be returned from the SQLiteDataReader method is unsuitable (e.g. null with a value type), an exception will be thrown.
SQLiteDelegateFunction | This class implements a SQLite function using a Delegate. All the virtual methods of the SQLiteFunction class are implemented using calls to the SQLiteInvokeDelegate, SQLiteStepDelegate, SQLiteFinalDelegate, and SQLiteCompareDelegate strongly typed delegate types or via the DynamicInvoke method. The arguments are presented in the same order they appear in the associated SQLiteFunction methods with one exception: the first argument is the name of the virtual method being implemented.
SQLiteException | SQLite exception class.
SQLiteFactory | SQLite implementation of DbProviderFactory.
SQLiteFunction | This abstract class is designed to handle user-defined functions easily. An instance of the derived class is made for each connection to the database.
SQLiteFunctionAttribute | A simple custom attribute to enable us to easily find user-defined functions in the loaded assemblies and initialize them in SQLite as connections are made.
SQLiteFunctionEx | Extends SQLiteFunction and allows an inherited class to obtain the collating sequence associated with a function call.
SQLiteIndex | This class represents the various inputs and outputs used with the BestIndex method.
SQLiteIndexConstraint | This class represents the native sqlite3_index_constraint structure from the SQLite core library.
SQLiteIndexConstraintUsage | This class represents the native sqlite3_index_constraint_usage structure from the SQLite core library.
SQLiteIndexInputs | This class represents the various inputs provided by the SQLite core library to the BestIndex method.
SQLiteIndexOrderBy | This class represents the native sqlite3_index_orderby structure from the SQLite core library.
SQLiteIndexOutputs | This class represents the various outputs provided to the SQLite core library by the BestIndex method.
SQLiteLog | Manages the SQLite custom logging functionality and the associated callback for the whole process.
SQLiteMetaDataCollectionNames | MetaDataCollections specific to SQLite
SQLiteModule | This class represents a managed virtual table module implementation. It is not sealed and must be used as the base class for any user-defined virtual table module classes implemented in managed code.
SQLiteModuleCommon | This class contains some virtual methods that may be useful for other virtual table classes. It specifically does NOT implement any of the ISQLiteManagedModule interface methods.
SQLiteModuleEnumerable This class implements a virtual table module that exposes an IEnumerable object instance as a read-only virtual table. It is not sealed and may be used as the base class for any user-defined virtual table class that wraps an IEnumerable object instance. The following short example shows it being used to treat an array of strings as a table data source:
   public static class Sample
   {
     public static void Main()
     {
       using (SQLiteConnection connection = new SQLiteConnection(
           "Data Source=:memory:;"))
       {
         connection.Open();

         connection.CreateModule(new SQLiteModuleEnumerable(
           "sampleModule", new string[] { "one", "two", "three" }));

         using (SQLiteCommand command = connection.CreateCommand())
         {
           command.CommandText =
               "CREATE VIRTUAL TABLE t1 USING sampleModule;";

           command.ExecuteNonQuery();
         }

         using (SQLiteCommand command = connection.CreateCommand())
         {
           command.CommandText = "SELECT * FROM t1;";

           using (SQLiteDataReader dataReader = command.ExecuteReader())
           {
             while (dataReader.Read())
               Console.WriteLine(dataReader[0].ToString());
           }
         }

         connection.Close();
       }
     }
   }
SQLiteModuleNoop | This class implements a virtual table module that does nothing by providing "empty" implementations for all of the ISQLiteManagedModule interface methods. The result codes returned by these "empty" method implementations may be controlled on a per-method basis by using and/or overriding the GetDefaultResultCode, ResultCodeToEofResult, ResultCodeToFindFunctionResult, GetMethodResultCode, and SetMethodResultCode methods from within derived classes.
SQLiteParameter | SQLite implementation of DbParameter.
SQLiteParameterCollection | SQLite implementation of DbParameterCollection.
SQLiteReadArrayEventArgs | This class represents the parameters that are provided to the GetBytes and GetChars methods, with the exception of the column index (provided separately).
SQLiteReadBlobEventArgs | This class represents the parameters that are provided to the GetBlob method, with the exception of the column index (provided separately).
SQLiteReadEventArgs | This class represents the parameters that are provided to the SQLiteDataReader methods, with the exception of the column index (provided separately).
SQLiteReadValueEventArgs | This class represents the parameters and return values for the GetBlob, GetBoolean, GetByte, GetBytes, GetChar, GetChars, GetDateTime, GetDecimal, GetDouble, GetFloat, GetGuid, GetInt16, GetInt32, GetInt64, GetString, and GetValue methods.
SQLiteTransaction | SQLite implementation of DbTransaction that does not support nested transactions.
SQLiteTransaction2 | SQLite implementation of DbTransaction that does support nested transactions.
SQLiteTransactionBase | Base class used by to implement DbTransaction for SQLite.
SQLiteTypeCallbacks | This class represents the custom data type handling callbacks for a single type name.
SQLiteValue | This class represents a value from the SQLite core library that can be passed to the sqlite3_value_*() and associated functions.
SQLiteVirtualTable | This class represents a managed virtual table implementation. It is not sealed and should be used as the base class for any user-defined virtual table classes implemented in managed code.
SQLiteVirtualTableCursor | This class represents a managed virtual table cursor implementation. It is not sealed and should be used as the base class for any user-defined virtual table cursor classes implemented in managed code.
SQLiteVirtualTableCursorEnumerator | This class represents a virtual table cursor to be used with the SQLiteModuleEnumerable class. It is not sealed and may be used as the base class for any user-defined virtual table cursor class that wraps an IEnumerator object instance.
TraceEventArgs | Passed during an Trace callback, these event arguments contain the UTF-8 rendering of the SQL statement text
UpdateEventArgs | Passed during an Update callback, these event arguments detail the type of update operation being performed on the given connection.

Interfaces

Interface | Description
ISQLiteChangeGroup | This interface contains methods used to manipulate multiple sets of changes for a database.
ISQLiteChangeSet | This interface contains methods used to manipulate a set of changes for a database.
ISQLiteChangeSetMetadataItem | This interface contains properties and methods used to fetch metadata about one change within a set of changes for a database.
ISQLiteConnectionPool | This interface represents a custom connection pool implementation usable by System.Data.SQLite.
ISQLiteConnectionPool2 | This interface represents a custom connection pool implementation usable by System.Data.SQLite.
ISQLiteManagedModule | This interface represents a virtual table implementation written in managed code.
ISQLiteNativeHandle | This interface represents a native handle provided by the SQLite core library.
ISQLiteNativeModule | This interface represents a virtual table implementation written in native code.
ISQLiteSchemaExtensions |
ISQLiteSession | This interface contains methods to query and manipulate the state of a change tracking session for a database.

Structures

Structure | Description
CollationSequence | A struct describing the collating sequence a function is executing in

Delegates

Delegate | Description
SessionConflictCallback | This callback is invoked when there is a conflict while apply changes to a database.
SessionTableFilterCallback | This callback is invoked when a determination must be made about whether changes to a specific table should be tracked -OR- applied. It will not be called for tables that are already attached to a ISQLiteSession.
SQLiteAuthorizerEventHandler | Raised when authorization is required to perform an action contained within a SQL query.
SQLiteBackupCallback | Raised between each backup step.
SQLiteBindValueCallback | This represents a method that will be called in response to a request to bind a parameter to a command. If an exception is thrown, it will cause the parameter binding operation to fail -AND- it will continue to unwind the call stack.
SQLiteBusyEventHandler |
SQLiteCallback | An internal callback delegate declaration.
SQLiteCommitHandler | Raised when a transaction is about to be committed. To roll back a transaction, set the rollbackTrans boolean value to true.
SQLiteCompareDelegate | This Delegate type is used with the Compare method.
SQLiteConnectionEventHandler | Raised when an event pertaining to a connection occurs.
SQLiteFinalDelegate | This Delegate type is used with the Final method.
SQLiteInvokeDelegate | This Delegate type is used with the Invoke method.
SQLiteLogEventHandler | Raised when a log event occurs.
SQLiteProgressEventHandler | Raised each time the number of virtual machine instructions is approximately equal to the value of the ProgressOps property.
SQLiteReadValueCallback | This represents a method that will be called in response to a request to read a value from a data reader. If an exception is thrown, it will cause the data reader operation to fail -AND- it will continue to unwind the call stack.
SQLiteStepDelegate | This Delegate type is used with the Step method.
SQLiteTraceEventHandler | Raised when a statement first begins executing on a given connection
SQLiteUpdateEventHandler | Raised when data is inserted, updated and deleted on a given connection

Enumerations

Enumeration | Description
CollationEncodingEnum | The encoding type the collation sequence uses
CollationTypeEnum | The type of collating sequence
FunctionType | The type of user-defined function to declare
SQLiteAuthorizerActionCode | The action code responsible for the current call into the authorizer.
SQLiteAuthorizerReturnCode | The return code for the current call into the authorizer.
SQLiteBusyReturnCode | The possible return codes for the busy callback.
SQLiteChangeSetConflictResult | This enumerated type represents the result of a user-defined conflict resolution callback.
SQLiteChangeSetConflictType | This enumerated type represents a type of conflict seen when apply changes from a change set or patch set.
SQLiteChangeSetStartFlags | This enumerated type represents possible flags that may be passed to the appropriate overloads of various change set creation methods.
SQLiteConfigDbOpsEnum | These are the supported configuration verbs for use with the native SQLite library. They are used with the SetConfigurationOption method.
SQLiteConnectionEventType | These are the event types associated with the SQLiteConnectionEventHandler delegate (and its corresponding event) and the ConnectionEventArgs class.
SQLiteConnectionFlags | The extra behavioral flags that can be applied to a connection.
SQLiteDateFormats | This implementation of SQLite for ADO.NET can process date/time fields in databases in one of six formats.
SQLiteErrorCode | SQLite error codes. Actually, this enumeration represents a return code, which may also indicate success in one of several ways (e.g. SQLITE_OK, SQLITE_ROW, and SQLITE_DONE). Therefore, the name of this enumeration is something of a misnomer.
SQLiteExecuteType | The requested command execution type. This controls which method of the SQLiteCommand object will be called.
SQLiteFunctionFlags | These constants are used with the sqlite3_create_function() API, et al.
SQLiteIndexConstraintOp | These are the allowed values for the operators that are part of a constraint term in the WHERE clause of a query that uses a virtual table.
SQLiteIndexFlags | These are the allowed values for the index flags from the BestIndex method.
SQLiteJournalModeEnum | This enum determines how SQLite treats its journal file.
SQLiteLimitOpsEnum | These constants are used with the sqlite3_limit() API.
SQLiteProgressReturnCode | The possible return codes for the progress callback.
SQLiteTraceFlags | These constants are used with the sqlite3_trace_v2() API and the callbacks registered by it.
SynchronizationModes | The I/O file cache flushing behavior for the connection
TypeAffinity | SQLite has very limited types, and is inherently text-based. The first 5 types below represent the sum of all types SQLite understands. The DateTime extension to the spec is for internal use only.
UpdateEventType | Whenever an update event is triggered on a connection, this enum will indicate exactly what type of operation is being performed.


AssemblySourceIdAttribute Class

Defines a source code identifier custom attribute for an assembly manifest.

For a list of all members of this type, see AssemblySourceIdAttribute Members .

System.Object
Attribute
AssemblySourceIdAttribute

public sealed class AssemblySourceIdAttribute : Attribute

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

AssemblySourceIdAttribute Members | System.Data.SQLite Namespace

Send comments on this topic.

Generated from assembly System.Data.SQLite [1.0.118.0] by NDoc3


AssemblySourceIdAttribute Members

AssemblySourceIdAttribute overview

Public Instance Constructors

AssemblySourceIdAttribute Constructor Constructs an instance of this attribute class using the specified source code identifier value.

Public Instance Properties

SourceId | Gets the source code identifier value.
TypeId (inherited from Attribute) | When implemented in a derived class, gets a unique identifier for this Attribute.

Public Instance Methods

Equals (inherited from Attribute) | Returns a value that indicates whether this instance is equal to a specified object.
GetHashCode (inherited from Attribute) | Returns the hash code for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
IsDefaultAttribute (inherited from Attribute) | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
Match (inherited from Attribute) | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

AssemblySourceIdAttribute Class | System.Data.SQLite Namespace


AssemblySourceIdAttribute Constructor

Constructs an instance of this attribute class using the specified source code identifier value.

AssemblySourceIdAttribute(
string value
);

Parameters

value
The source code identifier value to use.

See Also

AssemblySourceIdAttribute Class | System.Data.SQLite Namespace


AssemblySourceIdAttribute Properties

The properties of the AssemblySourceIdAttribute class are listed below. For a complete list of AssemblySourceIdAttribute class members, see the AssemblySourceIdAttribute Members topic.

Public Instance Properties

SourceId | Gets the source code identifier value.
TypeId (inherited from Attribute) | When implemented in a derived class, gets a unique identifier for this Attribute.

See Also

AssemblySourceIdAttribute Class | System.Data.SQLite Namespace


SourceId Property

SQLite ADO.NET Provider

AssemblySourceIdAttribute.SourceId Property

Gets the source code identifier value.

public string SourceId { public get; }

See Also

AssemblySourceIdAttribute Class | System.Data.SQLite Namespace


AssemblySourceTimeStampAttribute Class

Defines a source code time-stamp custom attribute for an assembly manifest.

For a list of all members of this type, see AssemblySourceTimeStampAttribute Members .

System.Object
Attribute
AssemblySourceTimeStampAttribute

public sealed class AssemblySourceTimeStampAttribute : Attribute

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

AssemblySourceTimeStampAttribute Members | System.Data.SQLite Namespace


AssemblySourceTimeStampAttribute Members

AssemblySourceTimeStampAttribute overview

Public Instance Constructors

AssemblySourceTimeStampAttribute Constructor Constructs an instance of this attribute class using the specified source code time-stamp value.

Public Instance Properties

SourceTimeStamp | Gets the source code time-stamp value.
TypeId (inherited from Attribute) | When implemented in a derived class, gets a unique identifier for this Attribute.

Public Instance Methods

Equals (inherited from Attribute) | Returns a value that indicates whether this instance is equal to a specified object.
GetHashCode (inherited from Attribute) | Returns the hash code for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
IsDefaultAttribute (inherited from Attribute) | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
Match (inherited from Attribute) | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

AssemblySourceTimeStampAttribute Class | System.Data.SQLite Namespace


AssemblySourceTimeStampAttribute Constructor

Constructs an instance of this attribute class using the specified source code time-stamp value.

AssemblySourceTimeStampAttribute(
string value
);

Parameters

value
The source code time-stamp value to use.

See Also

AssemblySourceTimeStampAttribute Class | System.Data.SQLite Namespace


AssemblySourceTimeStampAttribute Properties

The properties of the AssemblySourceTimeStampAttribute class are listed below. For a complete list of AssemblySourceTimeStampAttribute class members, see the AssemblySourceTimeStampAttribute Members topic.

Public Instance Properties

SourceTimeStamp | Gets the source code time-stamp value.
TypeId (inherited from Attribute) | When implemented in a derived class, gets a unique identifier for this Attribute.

See Also

AssemblySourceTimeStampAttribute Class | System.Data.SQLite Namespace


SourceTimeStamp Property

SQLite ADO.NET Provider

AssemblySourceTimeStampAttribute.SourceTimeStamp Property

Gets the source code time-stamp value.

public string SourceTimeStamp { public get; }

See Also

AssemblySourceTimeStampAttribute Class | System.Data.SQLite Namespace


AuthorizerEventArgs Class

The data associated with a call into the authorizer.

For a list of all members of this type, see AuthorizerEventArgs Members .

System.Object
EventArgs
AuthorizerEventArgs

public class AuthorizerEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

AuthorizerEventArgs Members | System.Data.SQLite Namespace


AuthorizerEventArgs Members

AuthorizerEventArgs overview

Public Instance Fields

ActionCode | The action code responsible for the current call into the authorizer.
Argument1 | The first string argument for the current call into the authorizer. The exact value will vary based on the action code, see the SQLiteAuthorizerActionCode enumeration for possible values.
Argument2 | The second string argument for the current call into the authorizer. The exact value will vary based on the action code, see the SQLiteAuthorizerActionCode enumeration for possible values.
Context | The name of the inner-most trigger or view that is responsible for the access attempt or a null value if this access attempt is directly from top-level SQL code.
Database | The database name for the current call into the authorizer, if applicable.
ReturnCode | The return code for the current call into the authorizer.
UserData | The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs Fields

The fields of the AuthorizerEventArgs class are listed below. For a complete list of AuthorizerEventArgs class members, see the AuthorizerEventArgs Members topic.

Public Instance Fields

ActionCode | The action code responsible for the current call into the authorizer.
Argument1 | The first string argument for the current call into the authorizer. The exact value will vary based on the action code, see the SQLiteAuthorizerActionCode enumeration for possible values.
Argument2 | The second string argument for the current call into the authorizer. The exact value will vary based on the action code, see the SQLiteAuthorizerActionCode enumeration for possible values.
Context | The name of the inner-most trigger or view that is responsible for the access attempt or a null value if this access attempt is directly from top-level SQL code.
Database | The database name for the current call into the authorizer, if applicable.
ReturnCode | The return code for the current call into the authorizer.
UserData | The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.ActionCode Field

The action code responsible for the current call into the authorizer.

public readonly SQLiteAuthorizerActionCode ActionCode;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.Argument1 Field

The first string argument for the current call into the authorizer. The exact value will vary based on the action code, see the SQLiteAuthorizerActionCode enumeration for possible values.

public readonly string Argument1;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.Argument2 Field

The second string argument for the current call into the authorizer. The exact value will vary based on the action code, see the SQLiteAuthorizerActionCode enumeration for possible values.

public readonly string Argument2;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.Context Field

The name of the inner-most trigger or view that is responsible for the access attempt or a null value if this access attempt is directly from top-level SQL code.

public readonly string Context;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.Database Field

The database name for the current call into the authorizer, if applicable.

public readonly string Database;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.ReturnCode Field

The return code for the current call into the authorizer.

public SQLiteAuthorizerReturnCode ReturnCode;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


AuthorizerEventArgs.UserData Field

The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

public readonly IntPtr UserData;

See Also

AuthorizerEventArgs Class | System.Data.SQLite Namespace


BusyEventArgs Class

The event data associated with "database is busy" events.

For a list of all members of this type, see BusyEventArgs Members .

System.Object
EventArgs
BusyEventArgs

public class BusyEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

BusyEventArgs Members | System.Data.SQLite Namespace


BusyEventArgs Members

BusyEventArgs overview

Public Instance Fields

Count | The number of times the current database operation has been retried so far.
ReturnCode | The return code for the current call into the busy callback.
UserData | The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

BusyEventArgs Class | System.Data.SQLite Namespace


BusyEventArgs Fields

The fields of the BusyEventArgs class are listed below. For a complete list of BusyEventArgs class members, see the BusyEventArgs Members topic.

Public Instance Fields

Count | The number of times the current database operation has been retried so far.
ReturnCode | The return code for the current call into the busy callback.
UserData | The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

See Also

BusyEventArgs Class | System.Data.SQLite Namespace


BusyEventArgs.Count Field

The number of times the current database operation has been retried so far.

public readonly int Count;

See Also

BusyEventArgs Class | System.Data.SQLite Namespace


BusyEventArgs.ReturnCode Field

The return code for the current call into the busy callback.

public SQLiteBusyReturnCode ReturnCode;

See Also

BusyEventArgs Class | System.Data.SQLite Namespace


BusyEventArgs.UserData Field

The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

public readonly IntPtr UserData;

See Also

BusyEventArgs Class | System.Data.SQLite Namespace


CollationEncodingEnum Enumeration

The encoding type the collation sequence uses

public enum CollationEncodingEnum

Members

Member Name | Description
UTF8 | The collation sequence is UTF8
UTF16LE | The collation sequence is UTF16 little-endian
UTF16BE | The collation sequence is UTF16 big-endian

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


CollationSequence Structure

A struct describing the collating sequence a function is executing in

For a list of all members of this type, see CollationSequence Members .

System.Object
CollationSequence

public struct CollationSequence

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

CollationSequence Members | System.Data.SQLite Namespace


CollationSequence Members

CollationSequence overview

Public Instance Fields

Encoding | The text encoding of the collation sequence
Name | The name of the collating sequence
Type | The type of collating sequence

Public Instance Methods

Compare | Overloaded. Calls the base collating sequence to compare two strings
Equals (inherited from ValueType) | Indicates whether this instance and a specified object are equal.
GetHashCode (inherited from ValueType) | Returns the hash code for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from ValueType) | Returns the fully qualified type name of this instance.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

CollationSequence Class | System.Data.SQLite Namespace


CollationSequence Fields

The fields of the CollationSequence structure are listed below. For a complete list of CollationSequence structure members, see the CollationSequence Members topic.

Public Instance Fields

Encoding | The text encoding of the collation sequence
Name | The name of the collating sequence
Type | The type of collating sequence

See Also

CollationSequence Class | System.Data.SQLite Namespace


CollationSequence.Encoding Field

The text encoding of the collation sequence

public CollationEncodingEnum Encoding;

See Also

CollationSequence Class | System.Data.SQLite Namespace


CollationSequence.Name Field

The name of the collating sequence

public string Name;

See Also

CollationSequence Class | System.Data.SQLite Namespace


CollationSequence.Type Field

The type of collating sequence

public CollationTypeEnum Type;

See Also

CollationSequence Class | System.Data.SQLite Namespace


CollationSequence Methods

The methods of the CollationSequence structure are listed below. For a complete list of CollationSequence structure members, see the CollationSequence Members topic.

Public Instance Methods

Compare | Overloaded. Calls the base collating sequence to compare two strings
Equals (inherited from ValueType) | Indicates whether this instance and a specified object are equal.
GetHashCode (inherited from ValueType) | Returns the hash code for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from ValueType) | Returns the fully qualified type name of this instance.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

CollationSequence Class | System.Data.SQLite Namespace


Compare Method

SQLite ADO.NET Provider

CollationSequence.Compare Method

Calls the base collating sequence to compare two character arrays

Overload List

Calls the base collating sequence to compare two character arrays

public int Compare(char[],char[])

Calls the base collating sequence to compare two strings

public int Compare(string,string)

See Also

CollationSequence Class | System.Data.SQLite Namespace


CollationSequence.Compare(Char, Char) Method

Calls the base collating sequence to compare two character arrays

public int Compare(
char[] c1,
char[] c2
);

Parameters

c1
The first array to compare
c2
The second array to compare

Return Value

-1 if c1 is less than c2, 0 if c1 is equal to c2, and 1 if c1 is greater than c2

See Also

CollationSequence Class | System.Data.SQLite Namespace | CollationSequence.Compare Overload List


CollationSequence.Compare(String, String) Method

Calls the base collating sequence to compare two strings

public int Compare(
string s1,
string s2
);

Parameters

s1
The first string to compare
s2
The second string to compare

Return Value

-1 if s1 is less than s2, 0 if s1 is equal to s2, and 1 if s1 is greater than s2

See Also

CollationSequence Class | System.Data.SQLite Namespace | CollationSequence.Compare Overload List


CollationTypeEnum Enumeration

The type of collating sequence

public enum CollationTypeEnum

Members

Member Name | Description
Binary | The built-in BINARY collating sequence
NoCase | The built-in NOCASE collating sequence
Reverse | The built-in REVERSE collating sequence
Custom | A custom user-defined collating sequence

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


CommitEventArgs Class

Event arguments raised when a transaction is being committed

For a list of all members of this type, see CommitEventArgs Members .

System.Object
EventArgs
CommitEventArgs

public class CommitEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

CommitEventArgs Members | System.Data.SQLite Namespace


CommitEventArgs Members

CommitEventArgs overview

Public Instance Fields

AbortTransaction Set to true to abort the transaction and trigger a rollback

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

CommitEventArgs Class | System.Data.SQLite Namespace


CommitEventArgs Fields

The fields of the CommitEventArgs class are listed below. For a complete list of CommitEventArgs class members, see the CommitEventArgs Members topic.

Public Instance Fields

AbortTransaction Set to true to abort the transaction and trigger a rollback

See Also

CommitEventArgs Class | System.Data.SQLite Namespace


CommitEventArgs.AbortTransaction Field

Set to true to abort the transaction and trigger a rollback

public bool AbortTransaction;

See Also

CommitEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs Class

Event data for connection event handlers.

For a list of all members of this type, see ConnectionEventArgs Members .

System.Object
EventArgs
ConnectionEventArgs

public class ConnectionEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ConnectionEventArgs Members | System.Data.SQLite Namespace


ConnectionEventArgs Members

ConnectionEventArgs overview

Public Instance Fields

Command | The command associated with this event, if any.
CriticalHandle | The critical handle associated with this event, if any.
Data | Extra data associated with this event, if any.
DataReader | The data reader associated with this event, if any.
EventArgs | The StateChangeEventArgs associated with this event, if any.
EventType | The type of event being raised.
Text | Command or message text associated with this event, if any.
Transaction | The transaction associated with this event, if any.

Public Instance Properties

Result

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs Fields

The fields of the ConnectionEventArgs class are listed below. For a complete list of ConnectionEventArgs class members, see the ConnectionEventArgs Members topic.

Public Instance Fields

Command | The command associated with this event, if any.
CriticalHandle | The critical handle associated with this event, if any.
Data | Extra data associated with this event, if any.
DataReader | The data reader associated with this event, if any.
EventArgs | The StateChangeEventArgs associated with this event, if any.
EventType | The type of event being raised.
Text | Command or message text associated with this event, if any.
Transaction | The transaction associated with this event, if any.

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.Command Field

The command associated with this event, if any.

public readonly IDbCommand Command;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.CriticalHandle Field

The critical handle associated with this event, if any.

public readonly CriticalHandle CriticalHandle;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.Data Field

Extra data associated with this event, if any.

public readonly object Data;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.DataReader Field

The data reader associated with this event, if any.

public readonly IDataReader DataReader;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.EventArgs Field

The StateChangeEventArgs associated with this event, if any.

public readonly StateChangeEventArgs EventArgs;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.EventType Field

The type of event being raised.

public readonly SQLiteConnectionEventType EventType;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.Text Field

Command or message text associated with this event, if any.

public readonly string Text;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs.Transaction Field

The transaction associated with this event, if any.

public readonly IDbTransaction Transaction;

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


ConnectionEventArgs Properties

The properties of the ConnectionEventArgs class are listed below. For a complete list of ConnectionEventArgs class members, see the ConnectionEventArgs Members topic.

Public Instance Properties

Result

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


Result Property

SQLite ADO.NET Provider

ConnectionEventArgs.Result Property

public string Result { public get; public set; }

See Also

ConnectionEventArgs Class | System.Data.SQLite Namespace


FunctionType Enumeration

The type of user-defined function to declare

public enum FunctionType

Members

Member Name | Description
Scalar | Scalar functions are designed to be called and return a result immediately. Examples include ABS(), Upper(), Lower(), etc.
Aggregate | Aggregate functions are designed to accumulate data until the end of a call and then return a result gleaned from the accumulated data. Examples include SUM(), COUNT(), AVG(), etc.
Collation | Collating sequences are used to sort textual data in a custom manner, and appear in an ORDER BY clause. Typically text in an ORDER BY is sorted using a straight case-insensitive comparison function. Custom collating sequences can be used to alter the behavior of text sorting in a user-defined manner.
Window | Window functions are designed to apply aggregate and ranking functions over a particular set of rows.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


ISQLiteChangeGroup Interface

This interface contains methods used to manipulate multiple sets of changes for a database.

For a list of all members of this type, see ISQLiteChangeGroup Members .

public interface ISQLiteChangeGroup : IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteChangeGroup Members | System.Data.SQLite Namespace


ISQLiteChangeGroup Members

ISQLiteChangeGroup overview

Public Instance Methods

AddChangeSet | Overloaded. Attempts to add a change set (or patch set) to this change group instance. The underlying data must be contained entirely within the rawData byte array.
CreateChangeSet | Overloaded. Attempts to create and return, via rawData, the combined set of changes represented by this change group instance.

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace


ISQLiteChangeGroup Methods

The methods of the ISQLiteChangeGroup interface are listed below. For a complete list of ISQLiteChangeGroup interface members, see the ISQLiteChangeGroup Members topic.

Public Instance Methods

AddChangeSet | Overloaded. Attempts to add a change set (or patch set) to this change group instance. The underlying data must be contained entirely within the rawData byte array.
CreateChangeSet | Overloaded. Attempts to create and return, via rawData, the combined set of changes represented by this change group instance.

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace


AddChangeSet Method

SQLite ADO.NET Provider

ISQLiteChangeGroup.AddChangeSet Method

Attempts to add a change set (or patch set) to this change group instance. The underlying data must be contained entirely within the rawData byte array.

Overload List

Attempts to add a change set (or patch set) to this change group instance. The underlying data must be contained entirely within the rawData byte array.

void AddChangeSet(byte[])

Attempts to add a change set (or patch set) to this change group instance. The underlying data will be read from the specified Stream.

void AddChangeSet(Stream)

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace


ISQLiteChangeGroup.AddChangeSet(Byte) Method

Attempts to add a change set (or patch set) to this change group instance. The underlying data must be contained entirely within the rawData byte array.

void AddChangeSet(
byte[] rawData
);

Parameters

rawData
The raw byte data for the specified change set (or patch set).

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace | ISQLiteChangeGroup.AddChangeSet Overload List


ISQLiteChangeGroup.AddChangeSet(Stream) Method

Attempts to add a change set (or patch set) to this change group instance. The underlying data will be read from the specified Stream.

void AddChangeSet(
Stream stream
);

Parameters

stream
The Stream instance containing the raw change set (or patch set) data to read.

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace | ISQLiteChangeGroup.AddChangeSet Overload List


CreateChangeSet Method

SQLite ADO.NET Provider

ISQLiteChangeGroup.CreateChangeSet Method

Attempts to create and return, via rawData, the combined set of changes represented by this change group instance.

Overload List

Attempts to create and return, via rawData, the combined set of changes represented by this change group instance.

void CreateChangeSet(ref byte[])

Attempts to create and write, via stream, the combined set of changes represented by this change group instance.

void CreateChangeSet(Stream)

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace


ISQLiteChangeGroup.CreateChangeSet(Byte) Method

Attempts to create and return, via rawData, the combined set of changes represented by this change group instance.

void CreateChangeSet(
ref byte[] rawData
);

Parameters

rawData
Upon success, this will contain the raw byte data for all the changes in this change group instance.

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace | ISQLiteChangeGroup.CreateChangeSet Overload List


ISQLiteChangeGroup.CreateChangeSet(Stream) Method

Attempts to create and write, via stream, the combined set of changes represented by this change group instance.

void CreateChangeSet(
Stream stream
);

Parameters

stream
Upon success, the raw byte data for all the changes in this change group instance will be written to this Stream.

See Also

ISQLiteChangeGroup Interface | System.Data.SQLite Namespace | ISQLiteChangeGroup.CreateChangeSet Overload List


ISQLiteChangeSet Interface

This interface contains methods used to manipulate a set of changes for a database.

For a list of all members of this type, see ISQLiteChangeSet Members .

public interface ISQLiteChangeSet : IEnumerable<ISQLiteChangeSetMetadataItem>, IEnumerable, IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteChangeSet Members | System.Data.SQLite Namespace


ISQLiteChangeSet Members

ISQLiteChangeSet overview

Public Instance Methods

Apply | Overloaded. Attempts to apply the set of changes in this instance to the associated database.
CombineWith | This method combines the specified set of changes with the ones contained in this instance.
Invert | This method "inverts" the set of changes within this instance. Applying an inverted set of changes to a database reverses the effects of applying the uninverted changes. Specifically: <ul><li> Each DELETE change is changed to an INSERT, and </li><li> Each INSERT change is changed to a DELETE, and </li><li> For each UPDATE change, the old.* and new.* values are exchanged. </li></ul> This method does not change the order in which changes appear within the set of changes. It merely reverses the sense of each individual change.

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace


ISQLiteChangeSet Methods

The methods of the ISQLiteChangeSet interface are listed below. For a complete list of ISQLiteChangeSet interface members, see the ISQLiteChangeSet Members topic.

Public Instance Methods

Apply | Overloaded. Attempts to apply the set of changes in this instance to the associated database.
CombineWith | This method combines the specified set of changes with the ones contained in this instance.
Invert | This method "inverts" the set of changes within this instance. Applying an inverted set of changes to a database reverses the effects of applying the uninverted changes. Specifically: <ul><li> Each DELETE change is changed to an INSERT, and </li><li> Each INSERT change is changed to a DELETE, and </li><li> For each UPDATE change, the old.* and new.* values are exchanged. </li></ul> This method does not change the order in which changes appear within the set of changes. It merely reverses the sense of each individual change.

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace


Apply Method

SQLite ADO.NET Provider

ISQLiteChangeSet.Apply Method

Attempts to apply the set of changes in this instance to the associated database.

Overload List

Attempts to apply the set of changes in this instance to the associated database.

void Apply(SessionConflictCallback,SessionTableFilterCallback,object)

Attempts to apply the set of changes in this instance to the associated database.

void Apply(SessionConflictCallback,object)

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace


ISQLiteChangeSet.Apply(SessionConflictCallback, SessionTableFilterCallback, Object) Method

Attempts to apply the set of changes in this instance to the associated database.

void Apply(
SessionConflictCallback conflictCallback,
SessionTableFilterCallback tableFilterCallback,
object clientData
);

Parameters

conflictCallback
The SessionConflictCallback delegate that will need to handle any conflicting changes that may arise.
tableFilterCallback
The optional SessionTableFilterCallback delegate that can be used to filter the list of tables impacted by the set of changes.
clientData
The optional application-defined context data. This value may be null.

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace | ISQLiteChangeSet.Apply Overload List


ISQLiteChangeSet.Apply(SessionConflictCallback, Object) Method

Attempts to apply the set of changes in this instance to the associated database.

void Apply(
SessionConflictCallback conflictCallback,
object clientData
);

Parameters

conflictCallback
The SessionConflictCallback delegate that will need to handle any conflicting changes that may arise.
clientData
The optional application-defined context data. This value may be null.

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace | ISQLiteChangeSet.Apply Overload List


ISQLiteChangeSet.CombineWith Method

This method combines the specified set of changes with the ones contained in this instance.

ISQLiteChangeSet CombineWith(
ISQLiteChangeSet changeSet
);

Parameters

changeSet
The changes to be combined with those in this instance.

Return Value

The new ISQLiteChangeSet instance that represents the resulting set of changes -OR- null if it is not available.

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace


ISQLiteChangeSet.Invert Method

This method "inverts" the set of changes within this instance. Applying an inverted set of changes to a database reverses the effects of applying the uninverted changes. Specifically: <ul><li> Each DELETE change is changed to an INSERT, and </li><li> Each INSERT change is changed to a DELETE, and </li><li> For each UPDATE change, the old.* and new.* values are exchanged. </li></ul> This method does not change the order in which changes appear within the set of changes. It merely reverses the sense of each individual change.

ISQLiteChangeSet Invert();

Return Value

The new ISQLiteChangeSet instance that represents the resulting set of changes -OR- null if it is not available.

See Also

ISQLiteChangeSet Interface | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem Interface

This interface contains properties and methods used to fetch metadata about one change within a set of changes for a database.

For a list of all members of this type, see ISQLiteChangeSetMetadataItem Members .

public interface ISQLiteChangeSetMetadataItem : IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteChangeSetMetadataItem Members | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem Members

ISQLiteChangeSetMetadataItem overview

Public Instance Properties

Indirect | Non-zero if this change is considered to be indirect (i.e. as though they were made via a trigger or foreign key action).
NumberOfColumns | The number of columns impacted by this change. This value can be used to determine the highest valid column index that may be used with the GetOldValue, GetNewValue, and GetConflictValue methods of this interface. It will be this value minus one.
NumberOfForeignKeyConflicts | This method may only be called from within a SessionConflictCallback delegate when the conflict type is ForeignKey. It returns the total number of known foreign key violations in the destination database.
OperationCode | This will contain the value Insert, Update, or Delete, corresponding to the overall type of change this item represents.
PrimaryKeyColumns | This array contains a Boolean for each column in the table associated with this change. The element will be zero if the column is not part of the primary key; otherwise, it will be non-zero.
TableName | The name of the table the change was made to.

Public Instance Methods

GetConflictValue | Queries and returns the conflicting value of a given column for this change. This method may only be called from within a SessionConflictCallback delegate when the conflict type is Data or Conflict.
GetNewValue | Queries and returns the updated value of a given column for this change. This method may only be called when the OperationCode has a value of Insert or Update.
GetOldValue | Queries and returns the original value of a given column for this change. This method may only be called when the OperationCode has a value of Update or Delete.

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem Properties

The properties of the ISQLiteChangeSetMetadataItem interface are listed below. For a complete list of ISQLiteChangeSetMetadataItem interface members, see the ISQLiteChangeSetMetadataItem Members topic.

Public Instance Properties

Indirect | Non-zero if this change is considered to be indirect (i.e. as though they were made via a trigger or foreign key action).
NumberOfColumns | The number of columns impacted by this change. This value can be used to determine the highest valid column index that may be used with the GetOldValue, GetNewValue, and GetConflictValue methods of this interface. It will be this value minus one.
NumberOfForeignKeyConflicts | This method may only be called from within a SessionConflictCallback delegate when the conflict type is ForeignKey. It returns the total number of known foreign key violations in the destination database.
OperationCode | This will contain the value Insert, Update, or Delete, corresponding to the overall type of change this item represents.
PrimaryKeyColumns | This array contains a Boolean for each column in the table associated with this change. The element will be zero if the column is not part of the primary key; otherwise, it will be non-zero.
TableName | The name of the table the change was made to.

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


Indirect Property

SQLite ADO.NET Provider

ISQLiteChangeSetMetadataItem.Indirect Property

Non-zero if this change is considered to be indirect (i.e. as though they were made via a trigger or foreign key action).

public bool Indirect { public get; }

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


NumberOfColumns Property

SQLite ADO.NET Provider

ISQLiteChangeSetMetadataItem.NumberOfColumns Property

The number of columns impacted by this change. This value can be used to determine the highest valid column index that may be used with the GetOldValue, GetNewValue, and GetConflictValue methods of this interface. It will be this value minus one.

public int NumberOfColumns { public get; }

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


NumberOfForeignKeyConflicts Property

SQLite ADO.NET Provider

ISQLiteChangeSetMetadataItem.NumberOfForeignKeyConflicts Property

This method may only be called from within a SessionConflictCallback delegate when the conflict type is ForeignKey. It returns the total number of known foreign key violations in the destination database.

public int NumberOfForeignKeyConflicts { public get; }

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


OperationCode Property

SQLite ADO.NET Provider

ISQLiteChangeSetMetadataItem.OperationCode Property

This will contain the value Insert, Update, or Delete, corresponding to the overall type of change this item represents.

public SQLiteAuthorizerActionCode OperationCode { public get; }

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


PrimaryKeyColumns Property

SQLite ADO.NET Provider

ISQLiteChangeSetMetadataItem.PrimaryKeyColumns Property

This array contains a Boolean for each column in the table associated with this change. The element will be zero if the column is not part of the primary key; otherwise, it will be non-zero.

public bool[] PrimaryKeyColumns { public get; }

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


TableName Property

SQLite ADO.NET Provider

ISQLiteChangeSetMetadataItem.TableName Property

The name of the table the change was made to.

public string TableName { public get; }

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem Methods

The methods of the ISQLiteChangeSetMetadataItem interface are listed below. For a complete list of ISQLiteChangeSetMetadataItem interface members, see the ISQLiteChangeSetMetadataItem Members topic.

Public Instance Methods

GetConflictValue | Queries and returns the conflicting value of a given column for this change. This method may only be called from within a SessionConflictCallback delegate when the conflict type is Data or Conflict.
GetNewValue | Queries and returns the updated value of a given column for this change. This method may only be called when the OperationCode has a value of Insert or Update.
GetOldValue | Queries and returns the original value of a given column for this change. This method may only be called when the OperationCode has a value of Update or Delete.

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem.GetConflictValue Method

Queries and returns the conflicting value of a given column for this change. This method may only be called from within a SessionConflictCallback delegate when the conflict type is Data or Conflict.

SQLiteValue GetConflictValue(
int columnIndex
);

Parameters

columnIndex
The index for the column. This value must be between zero and one less than the total number of columns for this table.

Return Value

The conflicting value of a given column for this change.

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem.GetNewValue Method

Queries and returns the updated value of a given column for this change. This method may only be called when the OperationCode has a value of Insert or Update.

SQLiteValue GetNewValue(
int columnIndex
);

Parameters

columnIndex
The index for the column. This value must be between zero and one less than the total number of columns for this table.

Return Value

The updated value of a given column for this change.

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


ISQLiteChangeSetMetadataItem.GetOldValue Method

Queries and returns the original value of a given column for this change. This method may only be called when the OperationCode has a value of Update or Delete.

SQLiteValue GetOldValue(
int columnIndex
);

Parameters

columnIndex
The index for the column. This value must be between zero and one less than the total number of columns for this table.

Return Value

The original value of a given column for this change.

See Also

ISQLiteChangeSetMetadataItem Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool Interface

This interface represents a custom connection pool implementation usable by System.Data.SQLite.

For a list of all members of this type, see ISQLiteConnectionPool Members .

System.Data.SQLite.ISQLiteConnectionPool
System.Data.SQLite.ISQLiteConnectionPool2

public interface ISQLiteConnectionPool

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteConnectionPool Members | System.Data.SQLite Namespace


ISQLiteConnectionPool Members

ISQLiteConnectionPool overview

Public Instance Methods

Add | Adds a connection to the pool of those associated with the specified database file name.
ClearAllPools | Disposes of all pooled connections.
ClearPool | Disposes of all pooled connections associated with the specified database file name.
GetCounts | Counts the number of pool entries matching the specified file name.
Remove | Removes a connection from the pool of those associated with the specified database file name with the intent of using it to interact with the database.

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool Methods

The methods of the ISQLiteConnectionPool interface are listed below. For a complete list of ISQLiteConnectionPool interface members, see the ISQLiteConnectionPool Members topic.

Public Instance Methods

Add | Adds a connection to the pool of those associated with the specified database file name.
ClearAllPools | Disposes of all pooled connections.
ClearPool | Disposes of all pooled connections associated with the specified database file name.
GetCounts | Counts the number of pool entries matching the specified file name.
Remove | Removes a connection from the pool of those associated with the specified database file name with the intent of using it to interact with the database.

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool.Add Method

Adds a connection to the pool of those associated with the specified database file name.

void Add(
string fileName,
object handle,
int version
);

Parameters

fileName
The database file name.
handle
The database connection handle.
version
The connection pool version at the point the database connection handle was received from the connection pool. This is also the connection pool version that the database connection handle was created under.

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool.ClearAllPools Method

Disposes of all pooled connections.

void ClearAllPools();

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool.ClearPool Method

Disposes of all pooled connections associated with the specified database file name.

void ClearPool(
string fileName
);

Parameters

fileName
The database file name.

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool.GetCounts Method

Counts the number of pool entries matching the specified file name.

void GetCounts(
string fileName,
ref Dictionary<string, int> counts,
ref int openCount,
ref int closeCount,
ref int totalCount
);

Parameters

fileName
The file name to match or null to match all files.
counts
The pool entry counts for each matching file.
openCount
The total number of connections successfully opened from any pool.
closeCount
The total number of connections successfully closed from any pool.
totalCount
The total number of pool entries for all matching files.

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool.Remove Method

Removes a connection from the pool of those associated with the specified database file name with the intent of using it to interact with the database.

object Remove(
string fileName,
int maxPoolSize,
out int version
);

Parameters

fileName
The database file name.
maxPoolSize
The new maximum size of the connection pool for the specified database file name.
version
The connection pool version associated with the returned database connection handle, if any.

Return Value

The database connection handle associated with the specified database file name or null if it cannot be obtained.

See Also

ISQLiteConnectionPool Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool2 Interface

This interface represents a custom connection pool implementation usable by System.Data.SQLite.

For a list of all members of this type, see ISQLiteConnectionPool2 Members .

public interface ISQLiteConnectionPool2 : ISQLiteConnectionPool

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteConnectionPool2 Members | System.Data.SQLite Namespace


ISQLiteConnectionPool2 Members

ISQLiteConnectionPool2 overview

Public Instance Methods

GetCounts | Gets the total number of connections successfully opened and closed from any pool.
Initialize | Initialize the connection pool.
ResetCounts | Resets the total number of connections successfully opened and closed from any pool to zero.
Terminate | Terminate the connection pool.

See Also

ISQLiteConnectionPool2 Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool2 Methods

The methods of the ISQLiteConnectionPool2 interface are listed below. For a complete list of ISQLiteConnectionPool2 interface members, see the ISQLiteConnectionPool2 Members topic.

Public Instance Methods

GetCounts | Gets the total number of connections successfully opened and closed from any pool.
Initialize | Initialize the connection pool.
ResetCounts | Resets the total number of connections successfully opened and closed from any pool to zero.
Terminate | Terminate the connection pool.

See Also

ISQLiteConnectionPool2 Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool2.GetCounts Method

Gets the total number of connections successfully opened and closed from any pool.

void GetCounts(
ref int openCount,
ref int closeCount
);

Parameters

openCount
The total number of connections successfully opened from any pool.
closeCount
The total number of connections successfully closed from any pool.

See Also

ISQLiteConnectionPool2 Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool2.Initialize Method

Initialize the connection pool.

void Initialize(
object argument
);

Parameters

argument
Optional single argument used during the connection pool initialization process.

See Also

ISQLiteConnectionPool2 Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool2.ResetCounts Method

Resets the total number of connections successfully opened and closed from any pool to zero.

void ResetCounts();

See Also

ISQLiteConnectionPool2 Interface | System.Data.SQLite Namespace


ISQLiteConnectionPool2.Terminate Method

Terminate the connection pool.

void Terminate(
object argument
);

Parameters

argument
Optional single argument used during the connection pool termination process.

See Also

ISQLiteConnectionPool2 Interface | System.Data.SQLite Namespace


ISQLiteManagedModule Interface

This interface represents a virtual table implementation written in managed code.

For a list of all members of this type, see ISQLiteManagedModule Members .

public interface ISQLiteManagedModule

Types that implement ISQLiteManagedModule

Type | Description
SQLiteModuleEnumerable(T) | This class implements a virtual table module that exposes an IEnumerable`1 object instance as a read-only virtual table. It is not sealed and may be used as the base class for any user-defined virtual table class that wraps an IEnumerable`1 object instance.
SQLiteModule | This class represents a managed virtual table module implementation. It is not sealed and must be used as the base class for any user-defined virtual table module classes implemented in managed code.
SQLiteModuleCommon | This class contains some virtual methods that may be useful for other virtual table classes. It specifically does NOT implement any of the ISQLiteManagedModule interface methods.
SQLiteModuleEnumerable This class implements a virtual table module that exposes an IEnumerable object instance as a read-only virtual table. It is not sealed and may be used as the base class for any user-defined virtual table class that wraps an IEnumerable object instance. The following short example shows it being used to treat an array of strings as a table data source:
   public static class Sample
   {
     public static void Main()
     {
       using (SQLiteConnection connection = new SQLiteConnection(
           "Data Source=:memory:;"))
       {
         connection.Open();

         connection.CreateModule(new SQLiteModuleEnumerable(
           "sampleModule", new string[] { "one", "two", "three" }));

         using (SQLiteCommand command = connection.CreateCommand())
         {
           command.CommandText =
               "CREATE VIRTUAL TABLE t1 USING sampleModule;";

           command.ExecuteNonQuery();
         }

         using (SQLiteCommand command = connection.CreateCommand())
         {
           command.CommandText = "SELECT * FROM t1;";

           using (SQLiteDataReader dataReader = command.ExecuteReader())
           {
             while (dataReader.Read())
               Console.WriteLine(dataReader[0].ToString());
           }
         }

         connection.Close();
       }
     }
   }
SQLiteModuleNoop | This class implements a virtual table module that does nothing by providing "empty" implementations for all of the ISQLiteManagedModule interface methods. The result codes returned by these "empty" method implementations may be controlled on a per-method basis by using and/or overriding the GetDefaultResultCode, ResultCodeToEofResult, ResultCodeToFindFunctionResult, GetMethodResultCode, and SetMethodResultCode methods from within derived classes.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteManagedModule Members | System.Data.SQLite Namespace


ISQLiteManagedModule Members

ISQLiteManagedModule overview

Public Instance Properties

Declared | Returns non-zero if the schema for the virtual table has been declared.
Name | Returns the name of the module as it was registered with the SQLite core library.

Public Instance Methods

Begin | This method is called in response to the xBegin method.
BestIndex | This method is called in response to the xBestIndex method.
Close | This method is called in response to the xClose method.
Column | This method is called in response to the xColumn method.
Commit | This method is called in response to the xCommit method.
Connect | This method is called in response to the xConnect method.
Create | This method is called in response to the xCreate method.
Destroy | This method is called in response to the xDestroy method.
Disconnect | This method is called in response to the xDisconnect method.
Eof | This method is called in response to the xEof method.
Filter | This method is called in response to the xFilter method.
FindFunction | This method is called in response to the xFindFunction method.
Next | This method is called in response to the xNext method.
Open | This method is called in response to the xOpen method.
Release | This method is called in response to the xRelease method.
Rename | This method is called in response to the xRename method.
Rollback | This method is called in response to the xRollback method.
RollbackTo | This method is called in response to the xRollbackTo method.
RowId | This method is called in response to the xRowId method.
Savepoint | This method is called in response to the xSavepoint method.
Sync | This method is called in response to the xSync method.
Update | This method is called in response to the xUpdate method.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule Properties

The properties of the ISQLiteManagedModule interface are listed below. For a complete list of ISQLiteManagedModule interface members, see the ISQLiteManagedModule Members topic.

Public Instance Properties

Declared | Returns non-zero if the schema for the virtual table has been declared.
Name | Returns the name of the module as it was registered with the SQLite core library.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


Declared Property

SQLite ADO.NET Provider

ISQLiteManagedModule.Declared Property

Returns non-zero if the schema for the virtual table has been declared.

public bool Declared { public get; }

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


Name Property

SQLite ADO.NET Provider

ISQLiteManagedModule.Name Property

Returns the name of the module as it was registered with the SQLite core library.

public string Name { public get; }

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule Methods

The methods of the ISQLiteManagedModule interface are listed below. For a complete list of ISQLiteManagedModule interface members, see the ISQLiteManagedModule Members topic.

Public Instance Methods

Begin | This method is called in response to the xBegin method.
BestIndex | This method is called in response to the xBestIndex method.
Close | This method is called in response to the xClose method.
Column | This method is called in response to the xColumn method.
Commit | This method is called in response to the xCommit method.
Connect | This method is called in response to the xConnect method.
Create | This method is called in response to the xCreate method.
Destroy | This method is called in response to the xDestroy method.
Disconnect | This method is called in response to the xDisconnect method.
Eof | This method is called in response to the xEof method.
Filter | This method is called in response to the xFilter method.
FindFunction | This method is called in response to the xFindFunction method.
Next | This method is called in response to the xNext method.
Open | This method is called in response to the xOpen method.
Release | This method is called in response to the xRelease method.
Rename | This method is called in response to the xRename method.
Rollback | This method is called in response to the xRollback method.
RollbackTo | This method is called in response to the xRollbackTo method.
RowId | This method is called in response to the xRowId method.
Savepoint | This method is called in response to the xSavepoint method.
Sync | This method is called in response to the xSync method.
Update | This method is called in response to the xUpdate method.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Begin Method

This method is called in response to the xBegin method.

SQLiteErrorCode Begin(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.BestIndex Method

This method is called in response to the xBestIndex method.

SQLiteErrorCode BestIndex(
SQLiteVirtualTable table,
SQLiteIndex index
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
index
The SQLiteIndex object instance containing all the data for the inputs and outputs relating to index selection.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Close Method

This method is called in response to the xClose method.

SQLiteErrorCode Close(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Column Method

This method is called in response to the xColumn method.

SQLiteErrorCode Column(
SQLiteVirtualTableCursor cursor,
SQLiteContext context,
int index
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
context
The SQLiteContext object instance to be used for returning the specified column value to the SQLite core library.
index
The zero-based index corresponding to the column containing the value to be returned.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Commit Method

This method is called in response to the xCommit method.

SQLiteErrorCode Commit(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Connect Method

This method is called in response to the xConnect method.

SQLiteErrorCode Connect(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
The SQLiteConnection object instance associated with the virtual table.
pClientData
The native user-data pointer associated with this module, as it was provided to the SQLite core library when the native module instance was created.
arguments
The module name, database name, virtual table name, and all other arguments passed to the CREATE VIRTUAL TABLE statement.
table
Upon success, this parameter must be modified to contain the SQLiteVirtualTable object instance associated with the virtual table.
error
Upon failure, this parameter must be modified to contain an error message.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Create Method

This method is called in response to the xCreate method.

SQLiteErrorCode Create(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
The SQLiteConnection object instance associated with the virtual table.
pClientData
The native user-data pointer associated with this module, as it was provided to the SQLite core library when the native module instance was created.
arguments
The module name, database name, virtual table name, and all other arguments passed to the CREATE VIRTUAL TABLE statement.
table
Upon success, this parameter must be modified to contain the SQLiteVirtualTable object instance associated with the virtual table.
error
Upon failure, this parameter must be modified to contain an error message.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Destroy Method

This method is called in response to the xDestroy method.

SQLiteErrorCode Destroy(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Disconnect Method

This method is called in response to the xDisconnect method.

SQLiteErrorCode Disconnect(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Eof Method

This method is called in response to the xEof method.

bool Eof(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.

Return Value

Non-zero if no more rows are available; zero otherwise.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Filter Method

This method is called in response to the xFilter method.

SQLiteErrorCode Filter(
SQLiteVirtualTableCursor cursor,
int indexNumber,
string indexString,
SQLiteValue[] values
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
indexNumber
Number used to help identify the selected index.
indexString
String used to help identify the selected index.
values
The values corresponding to each column in the selected index.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.FindFunction Method

This method is called in response to the xFindFunction method.

bool FindFunction(
SQLiteVirtualTable table,
int argumentCount,
string name,
ref SQLiteFunction function,
ref IntPtr pClientData
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
argumentCount
The number of arguments to the function being sought.
name
The name of the function being sought.
function
Upon success, this parameter must be modified to contain the SQLiteFunction object instance responsible for implementing the specified function.
pClientData
Upon success, this parameter must be modified to contain the native user-data pointer associated with function.

Return Value

Non-zero if the specified function was found; zero otherwise.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Next Method

This method is called in response to the xNext method.

SQLiteErrorCode Next(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Open Method

This method is called in response to the xOpen method.

SQLiteErrorCode Open(
SQLiteVirtualTable table,
ref SQLiteVirtualTableCursor cursor
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
cursor
Upon success, this parameter must be modified to contain the SQLiteVirtualTableCursor object instance associated with the newly opened virtual table cursor.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Release Method

This method is called in response to the xRelease method.

SQLiteErrorCode Release(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
savepoint
This is an integer used to indicate that any saved states with an identifier greater than or equal to this should be deleted by the virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Rename Method

This method is called in response to the xRename method.

SQLiteErrorCode Rename(
SQLiteVirtualTable table,
string newName
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
newName
The new name for the virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Rollback Method

This method is called in response to the xRollback method.

SQLiteErrorCode Rollback(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.RollbackTo Method

This method is called in response to the xRollbackTo method.

SQLiteErrorCode RollbackTo(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
savepoint
This is an integer identifier used to specify a specific saved state for the virtual table for it to restore itself back to, which should also have the effect of deleting all saved states with an integer identifier greater than this one.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.RowId Method

This method is called in response to the xRowId method.

SQLiteErrorCode RowId(
SQLiteVirtualTableCursor cursor,
ref long rowId
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
rowId
Upon success, this parameter must be modified to contain the unique integer row identifier for the current row for the specified cursor.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Savepoint Method

This method is called in response to the xSavepoint method.

SQLiteErrorCode Savepoint(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
savepoint
This is an integer identifier under which the the current state of the virtual table should be saved.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Sync Method

This method is called in response to the xSync method.

SQLiteErrorCode Sync(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteManagedModule.Update Method

This method is called in response to the xUpdate method.

SQLiteErrorCode Update(
SQLiteVirtualTable table,
SQLiteValue[] values,
ref long rowId
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
values
The array of SQLiteValue object instances containing the new or modified column values, if any.
rowId
Upon success, this parameter must be modified to contain the unique integer row identifier for the row that was inserted, if any.

Return Value

A standard SQLite return code.

See Also

ISQLiteManagedModule Interface | System.Data.SQLite Namespace


ISQLiteNativeHandle Interface

This interface represents a native handle provided by the SQLite core library.

For a list of all members of this type, see ISQLiteNativeHandle Members .

public interface ISQLiteNativeHandle

Types that implement ISQLiteNativeHandle

Type | Description
SQLiteVirtualTableCursorEnumerator(T) | This class represents a virtual table cursor to be used with the SQLiteModuleEnumerable class. It is not sealed and may be used as the base class for any user-defined virtual table cursor class that wraps an IEnumerator`1 object instance.
SQLiteContext | This class represents a context from the SQLite core library that can be passed to the sqlite3_result_*() and associated functions.
SQLiteValue | This class represents a value from the SQLite core library that can be passed to the sqlite3_value_*() and associated functions.
SQLiteVirtualTable | This class represents a managed virtual table implementation. It is not sealed and should be used as the base class for any user-defined virtual table classes implemented in managed code.
SQLiteVirtualTableCursor | This class represents a managed virtual table cursor implementation. It is not sealed and should be used as the base class for any user-defined virtual table cursor classes implemented in managed code.
SQLiteVirtualTableCursorEnumerator | This class represents a virtual table cursor to be used with the SQLiteModuleEnumerable class. It is not sealed and may be used as the base class for any user-defined virtual table cursor class that wraps an IEnumerator object instance.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteNativeHandle Members | System.Data.SQLite Namespace


ISQLiteNativeHandle Members

ISQLiteNativeHandle overview

Public Instance Properties

NativeHandle The native handle value.

See Also

ISQLiteNativeHandle Interface | System.Data.SQLite Namespace


ISQLiteNativeHandle Properties

The properties of the ISQLiteNativeHandle interface are listed below. For a complete list of ISQLiteNativeHandle interface members, see the ISQLiteNativeHandle Members topic.

Public Instance Properties

NativeHandle The native handle value.

See Also

ISQLiteNativeHandle Interface | System.Data.SQLite Namespace


NativeHandle Property

SQLite ADO.NET Provider

ISQLiteNativeHandle.NativeHandle Property

The native handle value.

public IntPtr NativeHandle { public get; }

See Also

ISQLiteNativeHandle Interface | System.Data.SQLite Namespace


ISQLiteNativeModule Interface

This interface represents a virtual table implementation written in native code.

For a list of all members of this type, see ISQLiteNativeModule Members .

public interface ISQLiteNativeModule

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteNativeModule Members | System.Data.SQLite Namespace


ISQLiteNativeModule Members

ISQLiteNativeModule overview

Public Instance Methods

xBegin
int (*xBegin)(sqlite3_vtab *pVTab);
This method begins a transaction on a virtual table. This is method is optional. The xBegin pointer of sqlite3_module may be NULL. This method is always followed by one call to either the xCommit or xRollback method. Virtual table transactions do not nest, so the xBegin method will not be invoked more than once on a single virtual table without an intervening call to either xCommit or xRollback. Multiple calls to other methods can and likely will occur in between the xBegin and the corresponding xCommit or xRollback.
xBestIndex SQLite uses the xBestIndex method of a virtual table module to determine the best way to access the virtual table. The xBestIndex method has a prototype like this:
int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
The SQLite core communicates with the xBestIndex method by filling in certain fields of the sqlite3_index_info structure and passing a pointer to that structure into xBestIndex as the second parameter. The xBestIndex method fills out other fields of this structure which forms the reply. The sqlite3_index_info structure looks like this:
struct sqlite3_index_info {
  /* Inputs */
  const int nConstraint;     /* Number of entries in aConstraint */
  const struct sqlite3_index_constraint {
     int iColumn;              /* Column constrained.  -1 for ROWID */
     unsigned char op;         /* Constraint operator */
     unsigned char usable;     /* True if this constraint is usable */
     int iTermOffset;          /* Used internally - xBestIndex should ignore */
  } *const aConstraint;      /* Table of WHERE clause constraints */
  const int nOrderBy;        /* Number of terms in the ORDER BY clause */
  const struct sqlite3_index_orderby {
     int iColumn;              /* Column number */
     unsigned char desc;       /* True for DESC.  False for ASC. */
  } *const aOrderBy;         /* The ORDER BY clause */
  /* Outputs */
  struct sqlite3_index_constraint_usage {
    int argvIndex;           /* if >0, constraint is part of argv to xFilter */
    unsigned char omit;      /* Do not code a test for this constraint */
  } *const aConstraintUsage;
  int idxNum;                /* Number used to identify the index */
  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
  int orderByConsumed;       /* True if output is already ordered */
  double estimatedCost;      /* Estimated cost of using this index */
  /* Fields below are only available in SQLite 3.8.2 and later */
  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  /* Fields below are only available in SQLite 3.9.0 and later */
  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  /* Fields below are only available in SQLite 3.10.0 and later */
  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
};
Note the warnings on the "estimatedRows", "idxFlags", and colUsed fields. These fields were added with SQLite versions 3.8.2, 3.9.0, and 3.10.0, respectively. Any extension that reads or writes these fields must first check that the version of the SQLite library in use is greater than or equal to appropriate version - perhaps comparing the value returned from sqlite3_libversion_number() against constants 3008002, 3009000, and/or 3010000. The result of attempting to access these fields in an sqlite3_index_info structure created by an older version of SQLite are undefined. In addition, there are some defined constants:
#define SQLITE_INDEX_CONSTRAINT_EQ         2
#define SQLITE_INDEX_CONSTRAINT_GT         4
#define SQLITE_INDEX_CONSTRAINT_LE         8
#define SQLITE_INDEX_CONSTRAINT_LT        16
#define SQLITE_INDEX_CONSTRAINT_GE        32
#define SQLITE_INDEX_CONSTRAINT_MATCH     64
#define SQLITE_INDEX_CONSTRAINT_LIKE      65  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_GLOB      66  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_REGEXP    67  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_NE        68  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNOT     69  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNULL    71  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_IS        72  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_LIMIT     73  /* 3.38.0 and later */
#define SQLITE_INDEX_CONSTRAINT_OFFSET    74  /* 3.38.0 and later */
#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150  /* 3.25.0 and later */
#define SQLITE_INDEX_SCAN_UNIQUE           1  /* Scan visits at most 1 row */
Use the sqlite3_vtab_collation() interface to find the name of the collating sequence that should be used when evaluating the i-th constraint:
const char *sqlite3_vtab_collation(sqlite3_index_info*, int i);
The SQLite core calls the xBestIndex method when it is compiling a query that involves a virtual table. In other words, SQLite calls this method when it is running sqlite3_prepare() or the equivalent. By calling this method, the SQLite core is saying to the virtual table that it needs to access some subset of the rows in the virtual table and it wants to know the most efficient way to do that access. The xBestIndex method replies with information that the SQLite core can then use to conduct an efficient search of the virtual table. While compiling a single SQL query, the SQLite core might call xBestIndex multiple times with different settings in sqlite3_index_info. The SQLite core will then select the combination that appears to give the best performance. Before calling this method, the SQLite core initializes an instance of the sqlite3_index_info structure with information about the query that it is currently trying to process. This information derives mainly from the WHERE clause and ORDER BY or GROUP BY clauses of the query, but also from any ON or USING clauses if the query is a join. The information that the SQLite core provides to the xBestIndex method is held in the part of the structure that is marked as "Inputs". The "Outputs" section is initialized to zero. The information in the sqlite3_index_info structure is ephemeral and may be overwritten or deallocated as soon as the xBestIndex method returns. If the xBestIndex method needs to remember any part of the sqlite3_index_info structure, it should make a copy. Care must be take to store the copy in a place where it will be deallocated, such as in the idxStr field with needToFreeIdxStr set to 1. Note that xBestIndex will always be called before xFilter, since the idxNum and idxStr outputs from xBestIndex are required inputs to xFilter. However, there is no guarantee that xFilter will be called following a successful xBestIndex. The xBestIndex method is required for every virtual table implementation. The main thing that the SQLite core is trying to communicate to the virtual table is the constraints that are available to limit the number of rows that need to be searched. The aConstraint[] array contains one entry for each constraint. There will be exactly nConstraint entries in that array. Each constraint will usually correspond to a term in the WHERE clause or in a USING or ON clause that is of the form
     column  OP  EXPR
Where "column" is a column in the virtual table, OP is an operator like "=" or "<", and EXPR is an arbitrary expression. So, for example, if the WHERE clause contained a term like this:
a = 5
Then one of the constraints would be on the "a" column with operator "=" and an expression of "5". Constraints need not have a literal representation of the WHERE clause. The query optimizer might make transformations to the WHERE clause in order to extract as many constraints as it can. So, for example, if the WHERE clause contained something like this:
x BETWEEN 10 AND 100 AND 999>y
The query optimizer might translate this into three separate constraints:
x >= 10
x <= 100
y < 999
For each such constraint, the aConstraint[].iColumn field indicates which column appears on the left-hand side of the constraint. The first column of the virtual table is column 0. The rowid of the virtual table is column -1. The aConstraint[].op field indicates which operator is used. The SQLITE_INDEX_CONSTRAINT_* constants map integer constants into operator values. Columns occur in the order they were defined by the call to sqlite3_declare_vtab() in the xCreate or xConnect method. Hidden columns are counted when determining the column index. If the xFindFunction() method for the virtual table is defined, and if xFindFunction() sometimes returns SQLITE_INDEX_CONSTRAINT_FUNCTION or larger, then the constraints might also be of the form:
     FUNCTION( column, EXPR)
In this case the aConstraint[].op value is the same as the value returned by xFindFunction() for FUNCTION. The aConstraint[] array contains information about all constraints that apply to the virtual table. But some of the constraints might not be usable because of the way tables are ordered in a join. The xBestIndex method must therefore only consider constraints that have an aConstraint[].usable flag which is true. In addition to WHERE clause constraints, the SQLite core also tells the xBestIndex method about the ORDER BY clause. (In an aggregate query, the SQLite core might put in GROUP BY clause information in place of the ORDER BY clause information, but this fact should not make any difference to the xBestIndex method.) If all terms of the ORDER BY clause are columns in the virtual table, then nOrderBy will be the number of terms in the ORDER BY clause and the aOrderBy[] array will identify the column for each term in the order by clause and whether or not that column is ASC or DESC. In SQLite version 3.10.0 (2016-01-06) and later, the colUsed field is available to indicate which fields of the virtual table are actually used by the statement being prepared. If the lowest bit of colUsed is set, that means that the first column is used. The second lowest bit corresponds to the second column. And so forth. If the most significant bit of colUsed is set, that means that one or more columns other than the first 63 columns are used. If column usage information is needed by the xFilter method, then the required bits must be encoded into either the output idxNum field or idxStr content. For the LIKE, GLOB, REGEXP, and MATCH operators, the aConstraint[].iColumn value is the virtual table column that is the left operand of the operator. However, if these operators are expressed as function calls instead of operators, then the aConstraint[].iColumn value references the virtual table column that is the second argument to that function:
LIKE(EXPR, column)

GLOB(EXPR, column)

REGEXP(EXPR, column)

MATCH(EXPR, column)
Hence, as far as the xBestIndex() method is concerned, the following two forms are equivalent:
column LIKE EXPR

      LIKE(EXPR,column)
This special behavior of looking at the second argument of a function only occurs for the LIKE, GLOB, REGEXP, and MATCH functions. For all other functions, the aConstraint[].iColumn value references the first argument of the function. This special feature of LIKE, GLOB, REGEXP, and MATCH does not apply to the xFindFunction() method, however. The xFindFunction() method always keys off of the left operand of an LIKE, GLOB, REGEXP, or MATCH operator but off of the first argument to function-call equivalents of those operators. When aConstraint[].op is one of SQLITE_INDEX_CONSTRAINT_LIMIT or SQLITE_INDEX_CONSTRAINT_OFFSET, that indicates that there is a LIMIT or OFFSET clause on the SQL query statement that is using the virtual table. The LIMIT and OFFSET operators have no left operand, and so when aConstraint[].op is one of SQLITE_INDEX_CONSTRAINT_LIMIT or SQLITE_INDEX_CONSTRAINT_OFFSET then the aConstraint[].iColumn value is meaningless and should not be used. The sqlite3_vtab_rhs_value() interface can be used to try to access the right-hand operand of a constraint. However, the value of a right-hand operator might not be known at the time that the xBestIndex method is run, so the sqlite3_vtab_rhs_value() call might not be successful. Usually the right operand of a constraint is only available to xBestIndex if it is coded as a literal value in the input SQL. If the right operand is coded as an expression or a host parameter, it probably will not be accessible to xBestIndex. Some operators, such as SQLITE_INDEX_CONSTRAINT_ISNULL and SQLITE_INDEX_CONSTRAINT_ISNOTNULL have no right-hand operand. The sqlite3_vtab_rhs_value() interface always returns SQLITE_NOTFOUND for such operators. Given all of the information above, the job of the xBestIndex method it to figure out the best way to search the virtual table. The xBestIndex method conveys an indexing strategy to the xFilter method through the idxNum and idxStr fields. The idxNum value and idxStr string content are arbitrary as far as the SQLite core is concerned and can have any meaning as long as xBestIndex and xFilter agree on what that meaning is. The SQLite core just copies the information from xBestIndex through to the xFilter method, assuming only that the char sequence referenced via idxStr is NUL terminated. The idxStr value may be a string obtained from an SQLite memory allocation function such as sqlite3_mprintf(). If this is the case, then the needToFreeIdxStr flag must be set to true so that the SQLite core will know to call sqlite3_free() on that string when it has finished with it, and thus avoid a memory leak. The idxStr value may also be a static constant string, in which case the needToFreeIdxStr boolean should remain false. The estimatedCost field should be set to the estimated number of disk access operations required to execute this query against the virtual table. The SQLite core will often call xBestIndex multiple times with different constraints, obtain multiple cost estimates, then choose the query plan that gives the lowest estimate. The SQLite core initializes estimatedCost to a very large value prior to invoking xBestIndex, so if xBestIndex determines that the current combination of parameters is undesirable, it can leave the estimatedCost field unchanged to discourage its use. If the current version of SQLite is 3.8.2 or greater, the estimatedRows field may be set to an estimate of the number of rows returned by the proposed query plan. If this value is not explicitly set, the default estimate of 25 rows is used. If the current version of SQLite is 3.9.0 or greater, the idxFlags field may be set to SQLITE_INDEX_SCAN_UNIQUE to indicate that the virtual table will return only zero or one rows given the input constraints. Additional bits of the idxFlags field might be understood in later versions of SQLite. The aConstraintUsage[] array contains one element for each of the nConstraint constraints in the inputs section of the sqlite3_index_info structure. The aConstraintUsage[] array is used by xBestIndex to tell the core how it is using the constraints. The xBestIndex method may set aConstraintUsage[].argvIndex entries to values greater than zero. Exactly one entry should be set to 1, another to 2, another to 3, and so forth up to as many or as few as the xBestIndex method wants. The EXPR of the corresponding constraints will then be passed in as the argv[] parameters to xFilter. For example, if the aConstraint[3].argvIndex is set to 1, then when xFilter is called, the argv[0] passed to xFilter will have the EXPR value of the aConstraint[3] constraint. By default, the SQLite generates bytecode that will double checks all constraints on each row of the virtual table to verify that they are satisfied. If the virtual table can guarantee that a constraint will always be satisfied, it can try to suppress that double-check by setting aConstraintUsage[].omit. However, with some exceptions, this is only a hint and there is no guarantee that the redundant check of the constraint will be suppressed. Key points:
  • The omit flag is only honored if the argvIndex value for the constraint is greater than 0 and less than or equal to 16. Constraint checking is never suppressed for constraints that do not pass their right operand into the xFilter method. The current implementation is only able to suppress redundant constraint checking for the first 16 values passed to xFilter, though that limitation might be increased in future releases.
  • The omit flag is always honored for SQLITE_INDEX_CONSTRAINT_OFFSET constraints as long as argvIndex is greater than 0. Setting the omit flag on an SQLITE_INDEX_CONSTRAINT_OFFSET constraint indicates to SQLite that the virtual table will itself suppress the first N rows of output, where N is the right operand of the OFFSET operator. If the virtual table implementation sets omit on an SQLITE_INDEX_CONSTRAINT_OFFSET constraint but then fails to suppress the first N rows of output, an incorrect answer will result from the overall query.
If the virtual table will output rows in the order specified by the ORDER BY clause, then the orderByConsumed flag may be set to true. If the output is not automatically in the correct order then orderByConsumed must be left in its default false setting. This will indicate to the SQLite core that it will need to do a separate sorting pass over the data after it comes out of the virtual table. Setting orderByConsumed is an optimization. A query will always get the correct answer if orderByConsumed is left at its default value (0). Unnecessary sort operations might be avoided resulting in a faster query if orderByConsumed is set, but setting orderByConsumed incorrectly can result in an incorrect answer. It is suggested that new virtual table implementations leave the orderByConsumed value unset initially, and then after everything else is known to be working correctly, go back and attempt to optimize by setting orderByConsumed where appropriate. Sometimes the orderByConsumed flag can be safely set even if the outputs from the virtual table are not strictly in the order specified by nOrderBy and aOrderBy. If the sqlite3_vtab_distinct() interface returns 1 or 2, that indicates that the ordering can be relaxed. See the documentation on sqlite3_vtab_distinct() for further information. The xBestIndex method should return SQLITE_OK on success. If any kind of fatal error occurs, an appropriate error code (ex: SQLITE_NOMEM) should be returned instead. If xBestIndex returns SQLITE_CONSTRAINT, that does not indicate an error. Rather, SQLITE_CONSTRAINT indicates that the particular combination of input parameters specified is insufficient for the virtual table to do its job. This is logically the same as setting the estimatedCost to infinity. If every call to xBestIndex for a particular query plan returns SQLITE_CONSTRAINT, that means there is no way for the virtual table to be safely used, and the sqlite3_prepare() call will fail with a "no query solution" error. The SQLITE_CONSTRAINT return from xBestIndex is useful for table-valued functions that have required parameters. If the aConstraint[].usable field is false for one of the required parameter, then the xBestIndex method should return SQLITE_CONSTRAINT. If a required field does not appear in the aConstraint[] array at all, that means that the corresponding parameter is omitted from the input SQL. In that case, xBestIndex should set an error message in pVTab->zErrMsg and return SQLITE_ERROR. To summarize:
  1. The aConstraint[].usable value for a required parameter is false → return SQLITE_CONSTRAINT.
  2. A required parameter does not appears anywhere in the aConstraint[] array → Set an error message in pVTab->zErrMsg and return SQLITE_ERROR
The following example will better illustrate the use of SQLITE_CONSTRAINT as a return value from xBestIndex:
SELECT * FROM realtab, tablevaluedfunc(realtab.x);
Assuming that the first hidden column of "tablevaluedfunc" is "param1", the query above is semantically equivalent to this:
SELECT * FROM realtab, tablevaluedfunc
 WHERE tablevaluedfunc.param1 = realtab.x;
The query planner must decide between many possible implementations of this query, but two plans in particular are of note:
  1. Scan all rows of realtab and for each row, find rows in tablevaluedfunc where param1 is equal to realtab.x
  2. Scan all rows of tablevalued func and for each row find rows in realtab where x is equal to tablevaluedfunc.param1.
The xBestIndex method will be invoked once for each of the potential plans above. For plan 1, the aConstraint[].usable flag for the SQLITE_CONSTRAINT_EQ constraint on the param1 column will be true because the right-hand side value for the "param1 = ?" constraint will be known, since it is determined by the outer realtab loop. But for plan 2, the aConstraint[].usable flag for "param1 = ?" will be false because the right-hand side value is determined by an inner loop and is thus an unknown quantity. Because param1 is a required input to the table-valued functions, the xBestIndex method should return SQLITE_CONSTRAINT when presented with plan 2, indicating that a required input is missing. This forces the query planner to select plan 1.
xClose
int (*xClose)(sqlite3_vtab_cursor*);
The xClose method closes a cursor previously opened by xOpen. The SQLite core will always call xClose once for each cursor opened using xOpen. This method must release all resources allocated by the corresponding xOpen call. The routine will not be called again even if it returns an error. The SQLite core will not use the sqlite3_vtab_cursor again after it has been closed. The xClose method is required for every virtual table implementation.
xColumn
int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int N);
The SQLite core invokes this method in order to find the value for the N-th column of the current row. N is zero-based so the first column is numbered 0. The xColumn method may return its result back to SQLite using one of the following interface:
  • sqlite3_result_blob()
  • sqlite3_result_double()
  • sqlite3_result_int()
  • sqlite3_result_int64()
  • sqlite3_result_null()
  • sqlite3_result_text()
  • sqlite3_result_text16()
  • sqlite3_result_text16le()
  • sqlite3_result_text16be()
  • sqlite3_result_zeroblob()
If the xColumn method implementation calls none of the functions above, then the value of the column defaults to an SQL NULL. To raise an error, the xColumn method should use one of the result_text() methods to set the error message text, then return an appropriate error code. The xColumn method must return SQLITE_OK on success. The xColumn method is required for every virtual table implementation.
xCommit
int (*xCommit)(sqlite3_vtab *pVTab);
This method causes a virtual table transaction to commit. This is method is optional. The xCommit pointer of sqlite3_module may be NULL. A call to this method always follows a prior call to xBegin and xSync.
xConnect
int (*xConnect)(sqlite3*, void *pAux,
             int argc, char *const*argv,
             sqlite3_vtab **ppVTab,
             char **pzErr);
The xConnect method is very similar to xCreate. It has the same parameters and constructs a new sqlite3_vtab structure just like xCreate. And it must also call sqlite3_declare_vtab() like xCreate. It should also make all of the same sqlite3_vtab_config() calls as xCreate. The difference is that xConnect is called to establish a new connection to an existing virtual table whereas xCreate is called to create a new virtual table from scratch. The xCreate and xConnect methods are only different when the virtual table has some kind of backing store that must be initialized the first time the virtual table is created. The xCreate method creates and initializes the backing store. The xConnect method just connects to an existing backing store. When xCreate and xConnect are the same, the table is an eponymous virtual table. As an example, consider a virtual table implementation that provides read-only access to existing comma-separated-value (CSV) files on disk. There is no backing store that needs to be created or initialized for such a virtual table (since the CSV files already exist on disk) so the xCreate and xConnect methods will be identical for that module. Another example is a virtual table that implements a full-text index. The xCreate method must create and initialize data structures to hold the dictionary and posting lists for that index. The xConnect method, on the other hand, only has to locate and use an existing dictionary and posting lists that were created by a prior xCreate call. The xConnect method must return SQLITE_OK if it is successful in creating the new virtual table, or SQLITE_ERROR if it is not successful. If not successful, the sqlite3_vtab structure must not be allocated. An error message may optionally be returned in *pzErr if unsuccessful. Space to hold the error message string must be allocated using an SQLite memory allocation function like sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will attempt to free the space using sqlite3_free() after the error has been reported up to the application. The xConnect method is required for every virtual table implementation, though the xCreate and xConnect pointers of the sqlite3_module object may point to the same function if the virtual table does not need to initialize backing store.
xCreate
int (*xCreate)(sqlite3 *db, void *pAux,
             int argc, char *const*argv,
             sqlite3_vtab **ppVTab,
             char **pzErr);
The xCreate method is called to create a new instance of a virtual table in response to a CREATE VIRTUAL TABLE statement. If the xCreate method is the same pointer as the xConnect method, then the virtual table is an eponymous virtual table. If the xCreate method is omitted (if it is a NULL pointer) then the virtual table is an eponymous-only virtual table. The db parameter is a pointer to the SQLite database connection that is executing the CREATE VIRTUAL TABLE statement. The pAux argument is the copy of the client data pointer that was the fourth argument to the sqlite3_create_module() or sqlite3_create_module_v2() call that registered the virtual table module. The argv parameter is an array of argc pointers to null terminated strings. The first string, argv[0], is the name of the module being invoked. The module name is the name provided as the second argument to sqlite3_create_module() and as the argument to the USING clause of the CREATE VIRTUAL TABLE statement that is running. The second, argv[1], is the name of the database in which the new virtual table is being created. The database name is "main" for the primary database, or "temp" for TEMP database, or the name given at the end of the ATTACH statement for attached databases. The third element of the array, argv[2], is the name of the new virtual table, as specified following the TABLE keyword in the CREATE VIRTUAL TABLE statement. If present, the fourth and subsequent strings in the argv[] array report the arguments to the module name in the CREATE VIRTUAL TABLE statement. The job of this method is to construct the new virtual table object (an sqlite3_vtab object) and return a pointer to it in *ppVTab. As part of the task of creating a new sqlite3_vtab structure, this method must invoke sqlite3_declare_vtab() to tell the SQLite core about the columns and datatypes in the virtual table. The sqlite3_declare_vtab() API has the following prototype:
int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable)
The first argument to sqlite3_declare_vtab() must be the same database connection pointer as the first parameter to this method. The second argument to sqlite3_declare_vtab() must a zero-terminated UTF-8 string that contains a well-formed CREATE TABLE statement that defines the columns in the virtual table and their data types. The name of the table in this CREATE TABLE statement is ignored, as are all constraints. Only the column names and datatypes matter. The CREATE TABLE statement string need not to be held in persistent memory. The string can be deallocated and/or reused as soon as the sqlite3_declare_vtab() routine returns. The xConnect method can also optionally request special features for the virtual table by making one or more calls to the sqlite3_vtab_config() interface:
int sqlite3_vtab_config(sqlite3 *db, int op, ...);
Calls to sqlite3_vtab_config() are optional. But for maximum security, it is recommended that virtual table implementations invoke "sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY)" if the virtual table will not be used from inside of triggers or views. The xCreate method need not initialize the pModule, nRef, and zErrMsg fields of the sqlite3_vtab object. The SQLite core will take care of that chore. The xCreate should return SQLITE_OK if it is successful in creating the new virtual table, or SQLITE_ERROR if it is not successful. If not successful, the sqlite3_vtab structure must not be allocated. An error message may optionally be returned in *pzErr if unsuccessful. Space to hold the error message string must be allocated using an SQLite memory allocation function like sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will attempt to free the space using sqlite3_free() after the error has been reported up to the application. If the xCreate method is omitted (left as a NULL pointer) then the virtual table is an eponymous-only virtual table. New instances of the virtual table cannot be created using CREATE VIRTUAL TABLE and the virtual table can only be used via its module name. Note that SQLite versions prior to 3.9.0 (2015-10-14) do not understand eponymous-only virtual tables and will segfault if an attempt is made to CREATE VIRTUAL TABLE on an eponymous-only virtual table because the xCreate method was not checked for null. If the xCreate method is the exact same pointer as the xConnect method, that indicates that the virtual table does not need to initialize backing store. Such a virtual table can be used as an eponymous virtual table or as a named virtual table using CREATE VIRTUAL TABLE or both. If a column datatype contains the special keyword "HIDDEN" (in any combination of upper and lower case letters) then that keyword it is omitted from the column datatype name and the column is marked as a hidden column internally. A hidden column differs from a normal column in three respects:
  • Hidden columns are not listed in the dataset returned by "PRAGMA table_info",
  • Hidden columns are not included in the expansion of a "*" expression in the result set of a SELECT, and
  • Hidden columns are not included in the implicit column-list used by an INSERT statement that lacks an explicit column-list.
For example, if the following SQL is passed to sqlite3_declare_vtab():
CREATE TABLE x(a HIDDEN VARCHAR(12), b INTEGER, c INTEGER Hidden);
Then the virtual table would be created with two hidden columns, and with datatypes of "VARCHAR(12)" and "INTEGER". An example use of hidden columns can be seen in the FTS3 virtual table implementation, where every FTS virtual table contains an FTS hidden column that is used to pass information from the virtual table into FTS auxiliary functions and to the FTS MATCH operator. A virtual table that contains hidden columns can be used like a table-valued function in the FROM clause of a SELECT statement. The arguments to the table-valued function become constraints on the HIDDEN columns of the virtual table. For example, the "generate_series" extension (located in the ext/misc/series.c file in the source tree) implements an eponymous virtual table with the following schema:
CREATE TABLE generate_series(
  value,
  start HIDDEN,
  stop HIDDEN,
  step HIDDEN
);
The sqlite3_module.xBestIndex method in the implementation of this table checks for equality constraints against the HIDDEN columns, and uses those as input parameters to determine the range of integer "value" outputs to generate. Reasonable defaults are used for any unconstrained columns. For example, to list all integers between 5 and 50:
SELECT value FROM generate_series(5,50);
The previous query is equivalent to the following:
SELECT value FROM generate_series WHERE start=5 AND stop=50;
Arguments on the virtual table name are matched to hidden columns in order. The number of arguments can be less than the number of hidden columns, in which case the latter hidden columns are unconstrained. However, an error results if there are more arguments than there are hidden columns in the virtual table. Beginning with SQLite version 3.14.0 (2016-08-08), the CREATE TABLE statement that is passed into sqlite3_declare_vtab() may contain a WITHOUT ROWID clause. This is useful for cases where the virtual table rows cannot easily be mapped into unique integers. A CREATE TABLE statement that includes WITHOUT ROWID must define one or more columns as the PRIMARY KEY. Every column of the PRIMARY KEY must individually be NOT NULL and all columns for each row must be collectively unique. Note that SQLite does not enforce the PRIMARY KEY for a WITHOUT ROWID virtual table. Enforcement is the responsibility of the underlying virtual table implementation. But SQLite does assume that the PRIMARY KEY constraint is valid - that the identified columns really are UNIQUE and NOT NULL - and it uses that assumption to optimize queries against the virtual table. The rowid column is not accessible on a WITHOUT ROWID virtual table (of course). The xUpdate method was originally designed around having a ROWID as a single value. The xUpdate method has been expanded to accommodate an arbitrary PRIMARY KEY in place of the ROWID, but the PRIMARY KEY must still be only one column. For this reason, SQLite will reject any WITHOUT ROWID virtual table that has more than one PRIMARY KEY column and a non-NULL xUpdate method.
xDestroy
int (*xDestroy)(sqlite3_vtab *pVTab);
This method releases a connection to a virtual table, just like the xDisconnect method, and it also destroys the underlying table implementation. This method undoes the work of xCreate. The xDisconnect method is called whenever a database connection that uses a virtual table is closed. The xDestroy method is only called when a DROP TABLE statement is executed against the virtual table. The xDestroy method is required for every virtual table implementation, though it is acceptable for the xDisconnect and xDestroy methods to be the same function if that makes sense for the particular virtual table.
xDisconnect
int (*xDisconnect)(sqlite3_vtab *pVTab);
This method releases a connection to a virtual table. Only the sqlite3_vtab object is destroyed. The virtual table is not destroyed and any backing store associated with the virtual table persists. This method undoes the work of xConnect. This method is a destructor for a connection to the virtual table. Contrast this method with xDestroy. The xDestroy is a destructor for the entire virtual table. The xDisconnect method is required for every virtual table implementation, though it is acceptable for the xDisconnect and xDestroy methods to be the same function if that makes sense for the particular virtual table.
xEof
int (*xEof)(sqlite3_vtab_cursor*);
The xEof method must return false (zero) if the specified cursor currently points to a valid row of data, or true (non-zero) otherwise. This method is called by the SQL engine immediately after each xFilter and xNext invocation. The xEof method is required for every virtual table implementation.
xFilter
int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
              int argc, sqlite3_value **argv);
This method begins a search of a virtual table. The first argument is a cursor opened by xOpen. The next two arguments define a particular search index previously chosen by xBestIndex. The specific meanings of idxNum and idxStr are unimportant as long as xFilter and xBestIndex agree on what that meaning is. The xBestIndex function may have requested the values of certain expressions using the aConstraintUsage[].argvIndex values of the sqlite3_index_info structure. Those values are passed to xFilter using the argc and argv parameters. If the virtual table contains one or more rows that match the search criteria, then the cursor must be left point at the first row. Subsequent calls to xEof must return false (zero). If there are no rows match, then the cursor must be left in a state that will cause the xEof to return true (non-zero). The SQLite engine will use the xColumn and xRowid methods to access that row content. The xNext method will be used to advance to the next row. This method must return SQLITE_OK if successful, or an sqlite error code if an error occurs. The xFilter method is required for every virtual table implementation.
xFindFunction
int (*xFindFunction)(
  sqlite3_vtab *pVtab,
  int nArg,
  const char *zName,
  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
  void **ppArg
);
This method is called during sqlite3_prepare() to give the virtual table implementation an opportunity to overload functions. This method may be set to NULL in which case no overloading occurs. When a function uses a column from a virtual table as its first argument, this method is called to see if the virtual table would like to overload the function. The first three parameters are inputs: the virtual table, the number of arguments to the function, and the name of the function. If no overloading is desired, this method returns 0. To overload the function, this method writes the new function implementation into *pxFunc and writes user data into *ppArg and returns either 1 or a number between SQLITE_INDEX_CONSTRAINT_FUNCTION and 255. Historically, the return value from xFindFunction() was either zero or one. Zero means that the function is not overloaded and one means that it is overload. The ability to return values of SQLITE_INDEX_CONSTRAINT_FUNCTION or greater was added in version 3.25.0 (2018-09-15). If xFindFunction returns SQLITE_INDEX_CONSTRAINT_FUNCTION or greater, than means that the function takes two arguments and the function can be used as a boolean in the WHERE clause of a query and that the virtual table is able to exploit that function to speed up the query result. When xFindFunction returns SQLITE_INDEX_CONSTRAINT_FUNCTION or larger, the value returned becomes the sqlite3_index_info.aConstraint.op value for one of the constraints passed into xBestIndex(). The first argument to the function is the column identified by aConstraint[].iColumn field of the constraint and the second argument to the function is the value that will be passed into xFilter() (if the aConstraintUsage[].argvIndex value is set) or the value returned from sqlite3_vtab_rhs_value(). The Geopoly module is an example of a virtual table that makes use of SQLITE_INDEX_CONSTRAINT_FUNCTION to improve performance. The xFindFunction() method for Geopoly returns SQLITE_INDEX_CONSTRAINT_FUNCTION for the geopoly_overlap() SQL function and it returns SQLITE_INDEX_CONSTRAINT_FUNCTION+1 for the geopoly_within() SQL function. This permits search optimizations for queries such as:
SELECT * FROM geopolytab WHERE geopoly_overlap(_shape, $query_polygon);
SELECT * FROM geopolytab WHERE geopoly_within(_shape, $query_polygon);
Note that infix functions (LIKE, GLOB, REGEXP, and MATCH) reverse the order of their arguments. So "like(A,B)" would normally work the same as "B like A". However, xFindFunction() always looks a the left-most argument, not the first logical argument. Hence, for the form "B like A", SQLite looks at the left operand "B" and if that operand is a virtual table column it invokes the xFindFunction() method on that virtual table. But if the form "like(A,B)" is used instead, then SQLite checks the A term to see if it is column of a virtual table and if so it invokes the xFindFunction() method for the virtual table of column A. The function pointer returned by this routine must be valid for the lifetime of the sqlite3_vtab object given in the first parameter.
xNext
int (*xNext)(sqlite3_vtab_cursor*);
The xNext method advances a virtual table cursor to the next row of a result set initiated by xFilter. If the cursor is already pointing at the last row when this routine is called, then the cursor no longer points to valid data and a subsequent call to the xEof method must return true (non-zero). If the cursor is successfully advanced to another row of content, then subsequent calls to xEof must return false (zero). This method must return SQLITE_OK if successful, or an sqlite error code if an error occurs. The xNext method is required for every virtual table implementation.
xOpen
int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
The xOpen method creates a new cursor used for accessing (read and/or writing) a virtual table. A successful invocation of this method will allocate the memory for the sqlite3_vtab_cursor (or a subclass), initialize the new object, and make *ppCursor point to the new object. The successful call then returns SQLITE_OK. For every successful call to this method, the SQLite core will later invoke the xClose method to destroy the allocated cursor. The xOpen method need not initialize the pVtab field of the sqlite3_vtab_cursor structure. The SQLite core will take care of that chore automatically. A virtual table implementation must be able to support an arbitrary number of simultaneously open cursors. When initially opened, the cursor is in an undefined state. The SQLite core will invoke the xFilter method on the cursor prior to any attempt to position or read from the cursor. The xOpen method is required for every virtual table implementation.
xRelease
int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later. When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M. None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().
xRename
int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
This method provides notification that the virtual table implementation that the virtual table will be given a new name. If this method returns SQLITE_OK then SQLite renames the table. If this method returns an error code then the renaming is prevented. The xRename method is optional. If omitted, then the virtual table may not be renamed using the ALTER TABLE RENAME command. The PRAGMA legacy_alter_table setting is enabled prior to invoking this method, and the value for legacy_alter_table is restored after this method finishes. This is necessary for the correct operation of virtual tables that make use of shadow tables where the shadow tables must be renamed to match the new virtual table name. If the legacy_alter_format is off, then the xConnect method will be invoked for the virtual table every time the xRename method tries to change the name of the shadow table.
xRollback
int (*xRollback)(sqlite3_vtab *pVTab);
This method causes a virtual table transaction to rollback. This is method is optional. The xRollback pointer of sqlite3_module may be NULL. A call to this method always follows a prior call to xBegin.
xRollbackTo
int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later. When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M. None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().
xRowId
int (*xRowid)(sqlite3_vtab_cursor *pCur, sqlite_int64 *pRowid);
A successful invocation of this method will cause *pRowid to be filled with the rowid of row that the virtual table cursor pCur is currently pointing at. This method returns SQLITE_OK on success. It returns an appropriate error code on failure. The xRowid method is required for every virtual table implementation.
xSavepoint
int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later. When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M. None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().
xSync
int (*xSync)(sqlite3_vtab *pVTab);
This method signals the start of a two-phase commit on a virtual table. This is method is optional. The xSync pointer of sqlite3_module may be NULL. This method is only invoked after call to the xBegin method and prior to an xCommit or xRollback. In order to implement two-phase commit, the xSync method on all virtual tables is invoked prior to invoking the xCommit method on any virtual table. If any of the xSync methods fail, the entire transaction is rolled back.
xUpdate
int (*xUpdate)(
  sqlite3_vtab *pVTab,
  int argc,
  sqlite3_value **argv,
  sqlite_int64 *pRowid
);
All changes to a virtual table are made using the xUpdate method. This one method can be used to insert, delete, or update. The argc parameter specifies the number of entries in the argv array. The value of argc will be 1 for a pure delete operation or N+2 for an insert or replace or update where N is the number of columns in the table. In the previous sentence, N includes any hidden columns. Every argv entry will have a non-NULL value in C but may contain the SQL value NULL. In other words, it is always true that argv[i]!=0 for i between 0 and argc-1. However, it might be the case that sqlite3_value_type(argv[i])==SQLITE_NULL. The argv[0] parameter is the rowid of a row in the virtual table to be deleted. If argv[0] is an SQL NULL, then no deletion occurs. The argv[1] parameter is the rowid of a new row to be inserted into the virtual table. If argv[1] is an SQL NULL, then the implementation must choose a rowid for the newly inserted row. Subsequent argv[] entries contain values of the columns of the virtual table, in the order that the columns were declared. The number of columns will match the table declaration that the xConnect or xCreate method made using the sqlite3_declare_vtab() call. All hidden columns are included. When doing an insert without a rowid (argc>1, argv[1] is an SQL NULL), on a virtual table that uses ROWID (but not on a WITHOUT ROWID virtual table), the implementation must set *pRowid to the rowid of the newly inserted row; this will become the value returned by the sqlite3_last_insert_rowid() function. Setting this value in all the other cases is a harmless no-op; the SQLite engine ignores the *pRowid return value if argc==1 or argv[1] is not an SQL NULL. Each call to xUpdate will fall into one of cases shown below. Not that references to argv[i] mean the SQL value held within the argv[i] object, not the argv[i] object itself.
argc = 1
 argv[0] ≠ NULL

            DELETE: The single row with rowid or PRIMARY KEY equal to argv[0] is deleted.
            No insert occurs.

argc > 1
 argv[0] = NULL

            INSERT: A new row is inserted with column values taken from
            argv[2] and following.  In a rowid virtual table, if argv[1] is an SQL NULL,
            then a new unique rowid is generated automatically.  The argv[1] will be NULL
            for a WITHOUT ROWID virtual table, in which case the implementation should
            take the PRIMARY KEY value from the appropriate column in argv[2] and following.

argc > 1
 argv[0] ≠ NULL
 argv[0] = argv[1]

            UPDATE:
            The row with rowid or PRIMARY KEY argv[0] is updated with new values
            in argv[2] and following parameters.

argc > 1
 argv[0] ≠ NULL
 argv[0] ≠ argv[1]

            UPDATE with rowid or PRIMARY KEY change:
            The row with rowid or PRIMARY KEY argv[0] is updated with
            the rowid or PRIMARY KEY in argv[1]
            and new values in argv[2] and following parameters. This will occur
            when an SQL statement updates a rowid, as in the statement:

               UPDATE table SET rowid=rowid+1 WHERE ...;
The xUpdate method must return SQLITE_OK if and only if it is successful. If a failure occurs, the xUpdate must return an appropriate error code. On a failure, the pVTab->zErrMsg element may optionally be replaced with error message text stored in memory allocated from SQLite using functions such as sqlite3_mprintf() or sqlite3_malloc(). If the xUpdate method violates some constraint of the virtual table (including, but not limited to, attempting to store a value of the wrong datatype, attempting to store a value that is too large or too small, or attempting to change a read-only value) then the xUpdate must fail with an appropriate error code. If the xUpdate method is performing an UPDATE, then sqlite3_value_nochange(X) can be used to discover which columns of the virtual table were actually modified by the UPDATE statement. The sqlite3_value_nochange(X) interface returns true for columns that do not change. On every UPDATE, SQLite will first invoke xColumn separately for each unchanging column in the table to obtain the value for that column. The xColumn method can check to see if the column is unchanged at the SQL level by invoking sqlite3_vtab_nochange(). If xColumn sees that the column is not being modified, it should return without setting a result using one of the sqlite3_result_xxxxx() interfaces. Only in that case sqlite3_value_nochange() will be true within the xUpdate method. If xColumn does invoke one or more sqlite3_result_xxxxx() interfaces, then SQLite understands that as a change in the value of the column and the sqlite3_value_nochange() call for that column within xUpdate will return false. There might be one or more sqlite3_vtab_cursor objects open and in use on the virtual table instance and perhaps even on the row of the virtual table when the xUpdate method is invoked. The implementation of xUpdate must be prepared for attempts to delete or modify rows of the table out from other existing cursors. If the virtual table cannot accommodate such changes, the xUpdate method must return an error code. The xUpdate method is optional. If the xUpdate pointer in the sqlite3_module for a virtual table is a NULL pointer, then the virtual table is read-only.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule Methods

The methods of the ISQLiteNativeModule interface are listed below. For a complete list of ISQLiteNativeModule interface members, see the ISQLiteNativeModule Members topic.

Public Instance Methods

xBegin
int (*xBegin)(sqlite3_vtab *pVTab);
This method begins a transaction on a virtual table. This is method is optional. The xBegin pointer of sqlite3_module may be NULL. This method is always followed by one call to either the xCommit or xRollback method. Virtual table transactions do not nest, so the xBegin method will not be invoked more than once on a single virtual table without an intervening call to either xCommit or xRollback. Multiple calls to other methods can and likely will occur in between the xBegin and the corresponding xCommit or xRollback.
xBestIndex SQLite uses the xBestIndex method of a virtual table module to determine the best way to access the virtual table. The xBestIndex method has a prototype like this:
int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
The SQLite core communicates with the xBestIndex method by filling in certain fields of the sqlite3_index_info structure and passing a pointer to that structure into xBestIndex as the second parameter. The xBestIndex method fills out other fields of this structure which forms the reply. The sqlite3_index_info structure looks like this:
struct sqlite3_index_info {
  /* Inputs */
  const int nConstraint;     /* Number of entries in aConstraint */
  const struct sqlite3_index_constraint {
     int iColumn;              /* Column constrained.  -1 for ROWID */
     unsigned char op;         /* Constraint operator */
     unsigned char usable;     /* True if this constraint is usable */
     int iTermOffset;          /* Used internally - xBestIndex should ignore */
  } *const aConstraint;      /* Table of WHERE clause constraints */
  const int nOrderBy;        /* Number of terms in the ORDER BY clause */
  const struct sqlite3_index_orderby {
     int iColumn;              /* Column number */
     unsigned char desc;       /* True for DESC.  False for ASC. */
  } *const aOrderBy;         /* The ORDER BY clause */
  /* Outputs */
  struct sqlite3_index_constraint_usage {
    int argvIndex;           /* if >0, constraint is part of argv to xFilter */
    unsigned char omit;      /* Do not code a test for this constraint */
  } *const aConstraintUsage;
  int idxNum;                /* Number used to identify the index */
  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
  int orderByConsumed;       /* True if output is already ordered */
  double estimatedCost;      /* Estimated cost of using this index */
  /* Fields below are only available in SQLite 3.8.2 and later */
  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  /* Fields below are only available in SQLite 3.9.0 and later */
  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  /* Fields below are only available in SQLite 3.10.0 and later */
  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
};
Note the warnings on the "estimatedRows", "idxFlags", and colUsed fields. These fields were added with SQLite versions 3.8.2, 3.9.0, and 3.10.0, respectively. Any extension that reads or writes these fields must first check that the version of the SQLite library in use is greater than or equal to appropriate version - perhaps comparing the value returned from sqlite3_libversion_number() against constants 3008002, 3009000, and/or 3010000. The result of attempting to access these fields in an sqlite3_index_info structure created by an older version of SQLite are undefined. In addition, there are some defined constants:
#define SQLITE_INDEX_CONSTRAINT_EQ         2
#define SQLITE_INDEX_CONSTRAINT_GT         4
#define SQLITE_INDEX_CONSTRAINT_LE         8
#define SQLITE_INDEX_CONSTRAINT_LT        16
#define SQLITE_INDEX_CONSTRAINT_GE        32
#define SQLITE_INDEX_CONSTRAINT_MATCH     64
#define SQLITE_INDEX_CONSTRAINT_LIKE      65  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_GLOB      66  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_REGEXP    67  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_NE        68  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNOT     69  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNULL    71  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_IS        72  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_LIMIT     73  /* 3.38.0 and later */
#define SQLITE_INDEX_CONSTRAINT_OFFSET    74  /* 3.38.0 and later */
#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150  /* 3.25.0 and later */
#define SQLITE_INDEX_SCAN_UNIQUE           1  /* Scan visits at most 1 row */
Use the sqlite3_vtab_collation() interface to find the name of the collating sequence that should be used when evaluating the i-th constraint:
const char *sqlite3_vtab_collation(sqlite3_index_info*, int i);
The SQLite core calls the xBestIndex method when it is compiling a query that involves a virtual table. In other words, SQLite calls this method when it is running sqlite3_prepare() or the equivalent. By calling this method, the SQLite core is saying to the virtual table that it needs to access some subset of the rows in the virtual table and it wants to know the most efficient way to do that access. The xBestIndex method replies with information that the SQLite core can then use to conduct an efficient search of the virtual table. While compiling a single SQL query, the SQLite core might call xBestIndex multiple times with different settings in sqlite3_index_info. The SQLite core will then select the combination that appears to give the best performance. Before calling this method, the SQLite core initializes an instance of the sqlite3_index_info structure with information about the query that it is currently trying to process. This information derives mainly from the WHERE clause and ORDER BY or GROUP BY clauses of the query, but also from any ON or USING clauses if the query is a join. The information that the SQLite core provides to the xBestIndex method is held in the part of the structure that is marked as "Inputs". The "Outputs" section is initialized to zero. The information in the sqlite3_index_info structure is ephemeral and may be overwritten or deallocated as soon as the xBestIndex method returns. If the xBestIndex method needs to remember any part of the sqlite3_index_info structure, it should make a copy. Care must be take to store the copy in a place where it will be deallocated, such as in the idxStr field with needToFreeIdxStr set to 1. Note that xBestIndex will always be called before xFilter, since the idxNum and idxStr outputs from xBestIndex are required inputs to xFilter. However, there is no guarantee that xFilter will be called following a successful xBestIndex. The xBestIndex method is required for every virtual table implementation. The main thing that the SQLite core is trying to communicate to the virtual table is the constraints that are available to limit the number of rows that need to be searched. The aConstraint[] array contains one entry for each constraint. There will be exactly nConstraint entries in that array. Each constraint will usually correspond to a term in the WHERE clause or in a USING or ON clause that is of the form
     column  OP  EXPR
Where "column" is a column in the virtual table, OP is an operator like "=" or "<", and EXPR is an arbitrary expression. So, for example, if the WHERE clause contained a term like this:
a = 5
Then one of the constraints would be on the "a" column with operator "=" and an expression of "5". Constraints need not have a literal representation of the WHERE clause. The query optimizer might make transformations to the WHERE clause in order to extract as many constraints as it can. So, for example, if the WHERE clause contained something like this:
x BETWEEN 10 AND 100 AND 999>y
The query optimizer might translate this into three separate constraints:
x >= 10
x <= 100
y < 999
For each such constraint, the aConstraint[].iColumn field indicates which column appears on the left-hand side of the constraint. The first column of the virtual table is column 0. The rowid of the virtual table is column -1. The aConstraint[].op field indicates which operator is used. The SQLITE_INDEX_CONSTRAINT_* constants map integer constants into operator values. Columns occur in the order they were defined by the call to sqlite3_declare_vtab() in the xCreate or xConnect method. Hidden columns are counted when determining the column index. If the xFindFunction() method for the virtual table is defined, and if xFindFunction() sometimes returns SQLITE_INDEX_CONSTRAINT_FUNCTION or larger, then the constraints might also be of the form:
     FUNCTION( column, EXPR)
In this case the aConstraint[].op value is the same as the value returned by xFindFunction() for FUNCTION. The aConstraint[] array contains information about all constraints that apply to the virtual table. But some of the constraints might not be usable because of the way tables are ordered in a join. The xBestIndex method must therefore only consider constraints that have an aConstraint[].usable flag which is true. In addition to WHERE clause constraints, the SQLite core also tells the xBestIndex method about the ORDER BY clause. (In an aggregate query, the SQLite core might put in GROUP BY clause information in place of the ORDER BY clause information, but this fact should not make any difference to the xBestIndex method.) If all terms of the ORDER BY clause are columns in the virtual table, then nOrderBy will be the number of terms in the ORDER BY clause and the aOrderBy[] array will identify the column for each term in the order by clause and whether or not that column is ASC or DESC. In SQLite version 3.10.0 (2016-01-06) and later, the colUsed field is available to indicate which fields of the virtual table are actually used by the statement being prepared. If the lowest bit of colUsed is set, that means that the first column is used. The second lowest bit corresponds to the second column. And so forth. If the most significant bit of colUsed is set, that means that one or more columns other than the first 63 columns are used. If column usage information is needed by the xFilter method, then the required bits must be encoded into either the output idxNum field or idxStr content. For the LIKE, GLOB, REGEXP, and MATCH operators, the aConstraint[].iColumn value is the virtual table column that is the left operand of the operator. However, if these operators are expressed as function calls instead of operators, then the aConstraint[].iColumn value references the virtual table column that is the second argument to that function:
LIKE(EXPR, column)

GLOB(EXPR, column)

REGEXP(EXPR, column)

MATCH(EXPR, column)
Hence, as far as the xBestIndex() method is concerned, the following two forms are equivalent:
column LIKE EXPR

      LIKE(EXPR,column)
This special behavior of looking at the second argument of a function only occurs for the LIKE, GLOB, REGEXP, and MATCH functions. For all other functions, the aConstraint[].iColumn value references the first argument of the function. This special feature of LIKE, GLOB, REGEXP, and MATCH does not apply to the xFindFunction() method, however. The xFindFunction() method always keys off of the left operand of an LIKE, GLOB, REGEXP, or MATCH operator but off of the first argument to function-call equivalents of those operators. When aConstraint[].op is one of SQLITE_INDEX_CONSTRAINT_LIMIT or SQLITE_INDEX_CONSTRAINT_OFFSET, that indicates that there is a LIMIT or OFFSET clause on the SQL query statement that is using the virtual table. The LIMIT and OFFSET operators have no left operand, and so when aConstraint[].op is one of SQLITE_INDEX_CONSTRAINT_LIMIT or SQLITE_INDEX_CONSTRAINT_OFFSET then the aConstraint[].iColumn value is meaningless and should not be used. The sqlite3_vtab_rhs_value() interface can be used to try to access the right-hand operand of a constraint. However, the value of a right-hand operator might not be known at the time that the xBestIndex method is run, so the sqlite3_vtab_rhs_value() call might not be successful. Usually the right operand of a constraint is only available to xBestIndex if it is coded as a literal value in the input SQL. If the right operand is coded as an expression or a host parameter, it probably will not be accessible to xBestIndex. Some operators, such as SQLITE_INDEX_CONSTRAINT_ISNULL and SQLITE_INDEX_CONSTRAINT_ISNOTNULL have no right-hand operand. The sqlite3_vtab_rhs_value() interface always returns SQLITE_NOTFOUND for such operators. Given all of the information above, the job of the xBestIndex method it to figure out the best way to search the virtual table. The xBestIndex method conveys an indexing strategy to the xFilter method through the idxNum and idxStr fields. The idxNum value and idxStr string content are arbitrary as far as the SQLite core is concerned and can have any meaning as long as xBestIndex and xFilter agree on what that meaning is. The SQLite core just copies the information from xBestIndex through to the xFilter method, assuming only that the char sequence referenced via idxStr is NUL terminated. The idxStr value may be a string obtained from an SQLite memory allocation function such as sqlite3_mprintf(). If this is the case, then the needToFreeIdxStr flag must be set to true so that the SQLite core will know to call sqlite3_free() on that string when it has finished with it, and thus avoid a memory leak. The idxStr value may also be a static constant string, in which case the needToFreeIdxStr boolean should remain false. The estimatedCost field should be set to the estimated number of disk access operations required to execute this query against the virtual table. The SQLite core will often call xBestIndex multiple times with different constraints, obtain multiple cost estimates, then choose the query plan that gives the lowest estimate. The SQLite core initializes estimatedCost to a very large value prior to invoking xBestIndex, so if xBestIndex determines that the current combination of parameters is undesirable, it can leave the estimatedCost field unchanged to discourage its use. If the current version of SQLite is 3.8.2 or greater, the estimatedRows field may be set to an estimate of the number of rows returned by the proposed query plan. If this value is not explicitly set, the default estimate of 25 rows is used. If the current version of SQLite is 3.9.0 or greater, the idxFlags field may be set to SQLITE_INDEX_SCAN_UNIQUE to indicate that the virtual table will return only zero or one rows given the input constraints. Additional bits of the idxFlags field might be understood in later versions of SQLite. The aConstraintUsage[] array contains one element for each of the nConstraint constraints in the inputs section of the sqlite3_index_info structure. The aConstraintUsage[] array is used by xBestIndex to tell the core how it is using the constraints. The xBestIndex method may set aConstraintUsage[].argvIndex entries to values greater than zero. Exactly one entry should be set to 1, another to 2, another to 3, and so forth up to as many or as few as the xBestIndex method wants. The EXPR of the corresponding constraints will then be passed in as the argv[] parameters to xFilter. For example, if the aConstraint[3].argvIndex is set to 1, then when xFilter is called, the argv[0] passed to xFilter will have the EXPR value of the aConstraint[3] constraint. By default, the SQLite generates bytecode that will double checks all constraints on each row of the virtual table to verify that they are satisfied. If the virtual table can guarantee that a constraint will always be satisfied, it can try to suppress that double-check by setting aConstraintUsage[].omit. However, with some exceptions, this is only a hint and there is no guarantee that the redundant check of the constraint will be suppressed. Key points:
  • The omit flag is only honored if the argvIndex value for the constraint is greater than 0 and less than or equal to 16. Constraint checking is never suppressed for constraints that do not pass their right operand into the xFilter method. The current implementation is only able to suppress redundant constraint checking for the first 16 values passed to xFilter, though that limitation might be increased in future releases.
  • The omit flag is always honored for SQLITE_INDEX_CONSTRAINT_OFFSET constraints as long as argvIndex is greater than 0. Setting the omit flag on an SQLITE_INDEX_CONSTRAINT_OFFSET constraint indicates to SQLite that the virtual table will itself suppress the first N rows of output, where N is the right operand of the OFFSET operator. If the virtual table implementation sets omit on an SQLITE_INDEX_CONSTRAINT_OFFSET constraint but then fails to suppress the first N rows of output, an incorrect answer will result from the overall query.
If the virtual table will output rows in the order specified by the ORDER BY clause, then the orderByConsumed flag may be set to true. If the output is not automatically in the correct order then orderByConsumed must be left in its default false setting. This will indicate to the SQLite core that it will need to do a separate sorting pass over the data after it comes out of the virtual table. Setting orderByConsumed is an optimization. A query will always get the correct answer if orderByConsumed is left at its default value (0). Unnecessary sort operations might be avoided resulting in a faster query if orderByConsumed is set, but setting orderByConsumed incorrectly can result in an incorrect answer. It is suggested that new virtual table implementations leave the orderByConsumed value unset initially, and then after everything else is known to be working correctly, go back and attempt to optimize by setting orderByConsumed where appropriate. Sometimes the orderByConsumed flag can be safely set even if the outputs from the virtual table are not strictly in the order specified by nOrderBy and aOrderBy. If the sqlite3_vtab_distinct() interface returns 1 or 2, that indicates that the ordering can be relaxed. See the documentation on sqlite3_vtab_distinct() for further information. The xBestIndex method should return SQLITE_OK on success. If any kind of fatal error occurs, an appropriate error code (ex: SQLITE_NOMEM) should be returned instead. If xBestIndex returns SQLITE_CONSTRAINT, that does not indicate an error. Rather, SQLITE_CONSTRAINT indicates that the particular combination of input parameters specified is insufficient for the virtual table to do its job. This is logically the same as setting the estimatedCost to infinity. If every call to xBestIndex for a particular query plan returns SQLITE_CONSTRAINT, that means there is no way for the virtual table to be safely used, and the sqlite3_prepare() call will fail with a "no query solution" error. The SQLITE_CONSTRAINT return from xBestIndex is useful for table-valued functions that have required parameters. If the aConstraint[].usable field is false for one of the required parameter, then the xBestIndex method should return SQLITE_CONSTRAINT. If a required field does not appear in the aConstraint[] array at all, that means that the corresponding parameter is omitted from the input SQL. In that case, xBestIndex should set an error message in pVTab->zErrMsg and return SQLITE_ERROR. To summarize:
  1. The aConstraint[].usable value for a required parameter is false → return SQLITE_CONSTRAINT.
  2. A required parameter does not appears anywhere in the aConstraint[] array → Set an error message in pVTab->zErrMsg and return SQLITE_ERROR
The following example will better illustrate the use of SQLITE_CONSTRAINT as a return value from xBestIndex:
SELECT * FROM realtab, tablevaluedfunc(realtab.x);
Assuming that the first hidden column of "tablevaluedfunc" is "param1", the query above is semantically equivalent to this:
SELECT * FROM realtab, tablevaluedfunc
 WHERE tablevaluedfunc.param1 = realtab.x;
The query planner must decide between many possible implementations of this query, but two plans in particular are of note:
  1. Scan all rows of realtab and for each row, find rows in tablevaluedfunc where param1 is equal to realtab.x
  2. Scan all rows of tablevalued func and for each row find rows in realtab where x is equal to tablevaluedfunc.param1.
The xBestIndex method will be invoked once for each of the potential plans above. For plan 1, the aConstraint[].usable flag for the SQLITE_CONSTRAINT_EQ constraint on the param1 column will be true because the right-hand side value for the "param1 = ?" constraint will be known, since it is determined by the outer realtab loop. But for plan 2, the aConstraint[].usable flag for "param1 = ?" will be false because the right-hand side value is determined by an inner loop and is thus an unknown quantity. Because param1 is a required input to the table-valued functions, the xBestIndex method should return SQLITE_CONSTRAINT when presented with plan 2, indicating that a required input is missing. This forces the query planner to select plan 1.
xClose
int (*xClose)(sqlite3_vtab_cursor*);
The xClose method closes a cursor previously opened by xOpen. The SQLite core will always call xClose once for each cursor opened using xOpen. This method must release all resources allocated by the corresponding xOpen call. The routine will not be called again even if it returns an error. The SQLite core will not use the sqlite3_vtab_cursor again after it has been closed. The xClose method is required for every virtual table implementation.
xColumn
int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int N);
The SQLite core invokes this method in order to find the value for the N-th column of the current row. N is zero-based so the first column is numbered 0. The xColumn method may return its result back to SQLite using one of the following interface:
  • sqlite3_result_blob()
  • sqlite3_result_double()
  • sqlite3_result_int()
  • sqlite3_result_int64()
  • sqlite3_result_null()
  • sqlite3_result_text()
  • sqlite3_result_text16()
  • sqlite3_result_text16le()
  • sqlite3_result_text16be()
  • sqlite3_result_zeroblob()
If the xColumn method implementation calls none of the functions above, then the value of the column defaults to an SQL NULL. To raise an error, the xColumn method should use one of the result_text() methods to set the error message text, then return an appropriate error code. The xColumn method must return SQLITE_OK on success. The xColumn method is required for every virtual table implementation.
xCommit
int (*xCommit)(sqlite3_vtab *pVTab);
This method causes a virtual table transaction to commit. This is method is optional. The xCommit pointer of sqlite3_module may be NULL. A call to this method always follows a prior call to xBegin and xSync.
xConnect
int (*xConnect)(sqlite3*, void *pAux,
             int argc, char *const*argv,
             sqlite3_vtab **ppVTab,
             char **pzErr);
The xConnect method is very similar to xCreate. It has the same parameters and constructs a new sqlite3_vtab structure just like xCreate. And it must also call sqlite3_declare_vtab() like xCreate. It should also make all of the same sqlite3_vtab_config() calls as xCreate. The difference is that xConnect is called to establish a new connection to an existing virtual table whereas xCreate is called to create a new virtual table from scratch. The xCreate and xConnect methods are only different when the virtual table has some kind of backing store that must be initialized the first time the virtual table is created. The xCreate method creates and initializes the backing store. The xConnect method just connects to an existing backing store. When xCreate and xConnect are the same, the table is an eponymous virtual table. As an example, consider a virtual table implementation that provides read-only access to existing comma-separated-value (CSV) files on disk. There is no backing store that needs to be created or initialized for such a virtual table (since the CSV files already exist on disk) so the xCreate and xConnect methods will be identical for that module. Another example is a virtual table that implements a full-text index. The xCreate method must create and initialize data structures to hold the dictionary and posting lists for that index. The xConnect method, on the other hand, only has to locate and use an existing dictionary and posting lists that were created by a prior xCreate call. The xConnect method must return SQLITE_OK if it is successful in creating the new virtual table, or SQLITE_ERROR if it is not successful. If not successful, the sqlite3_vtab structure must not be allocated. An error message may optionally be returned in *pzErr if unsuccessful. Space to hold the error message string must be allocated using an SQLite memory allocation function like sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will attempt to free the space using sqlite3_free() after the error has been reported up to the application. The xConnect method is required for every virtual table implementation, though the xCreate and xConnect pointers of the sqlite3_module object may point to the same function if the virtual table does not need to initialize backing store.
xCreate
int (*xCreate)(sqlite3 *db, void *pAux,
             int argc, char *const*argv,
             sqlite3_vtab **ppVTab,
             char **pzErr);
The xCreate method is called to create a new instance of a virtual table in response to a CREATE VIRTUAL TABLE statement. If the xCreate method is the same pointer as the xConnect method, then the virtual table is an eponymous virtual table. If the xCreate method is omitted (if it is a NULL pointer) then the virtual table is an eponymous-only virtual table. The db parameter is a pointer to the SQLite database connection that is executing the CREATE VIRTUAL TABLE statement. The pAux argument is the copy of the client data pointer that was the fourth argument to the sqlite3_create_module() or sqlite3_create_module_v2() call that registered the virtual table module. The argv parameter is an array of argc pointers to null terminated strings. The first string, argv[0], is the name of the module being invoked. The module name is the name provided as the second argument to sqlite3_create_module() and as the argument to the USING clause of the CREATE VIRTUAL TABLE statement that is running. The second, argv[1], is the name of the database in which the new virtual table is being created. The database name is "main" for the primary database, or "temp" for TEMP database, or the name given at the end of the ATTACH statement for attached databases. The third element of the array, argv[2], is the name of the new virtual table, as specified following the TABLE keyword in the CREATE VIRTUAL TABLE statement. If present, the fourth and subsequent strings in the argv[] array report the arguments to the module name in the CREATE VIRTUAL TABLE statement. The job of this method is to construct the new virtual table object (an sqlite3_vtab object) and return a pointer to it in *ppVTab. As part of the task of creating a new sqlite3_vtab structure, this method must invoke sqlite3_declare_vtab() to tell the SQLite core about the columns and datatypes in the virtual table. The sqlite3_declare_vtab() API has the following prototype:
int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable)
The first argument to sqlite3_declare_vtab() must be the same database connection pointer as the first parameter to this method. The second argument to sqlite3_declare_vtab() must a zero-terminated UTF-8 string that contains a well-formed CREATE TABLE statement that defines the columns in the virtual table and their data types. The name of the table in this CREATE TABLE statement is ignored, as are all constraints. Only the column names and datatypes matter. The CREATE TABLE statement string need not to be held in persistent memory. The string can be deallocated and/or reused as soon as the sqlite3_declare_vtab() routine returns. The xConnect method can also optionally request special features for the virtual table by making one or more calls to the sqlite3_vtab_config() interface:
int sqlite3_vtab_config(sqlite3 *db, int op, ...);
Calls to sqlite3_vtab_config() are optional. But for maximum security, it is recommended that virtual table implementations invoke "sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY)" if the virtual table will not be used from inside of triggers or views. The xCreate method need not initialize the pModule, nRef, and zErrMsg fields of the sqlite3_vtab object. The SQLite core will take care of that chore. The xCreate should return SQLITE_OK if it is successful in creating the new virtual table, or SQLITE_ERROR if it is not successful. If not successful, the sqlite3_vtab structure must not be allocated. An error message may optionally be returned in *pzErr if unsuccessful. Space to hold the error message string must be allocated using an SQLite memory allocation function like sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will attempt to free the space using sqlite3_free() after the error has been reported up to the application. If the xCreate method is omitted (left as a NULL pointer) then the virtual table is an eponymous-only virtual table. New instances of the virtual table cannot be created using CREATE VIRTUAL TABLE and the virtual table can only be used via its module name. Note that SQLite versions prior to 3.9.0 (2015-10-14) do not understand eponymous-only virtual tables and will segfault if an attempt is made to CREATE VIRTUAL TABLE on an eponymous-only virtual table because the xCreate method was not checked for null. If the xCreate method is the exact same pointer as the xConnect method, that indicates that the virtual table does not need to initialize backing store. Such a virtual table can be used as an eponymous virtual table or as a named virtual table using CREATE VIRTUAL TABLE or both. If a column datatype contains the special keyword "HIDDEN" (in any combination of upper and lower case letters) then that keyword it is omitted from the column datatype name and the column is marked as a hidden column internally. A hidden column differs from a normal column in three respects:
  • Hidden columns are not listed in the dataset returned by "PRAGMA table_info",
  • Hidden columns are not included in the expansion of a "*" expression in the result set of a SELECT, and
  • Hidden columns are not included in the implicit column-list used by an INSERT statement that lacks an explicit column-list.
For example, if the following SQL is passed to sqlite3_declare_vtab():
CREATE TABLE x(a HIDDEN VARCHAR(12), b INTEGER, c INTEGER Hidden);
Then the virtual table would be created with two hidden columns, and with datatypes of "VARCHAR(12)" and "INTEGER". An example use of hidden columns can be seen in the FTS3 virtual table implementation, where every FTS virtual table contains an FTS hidden column that is used to pass information from the virtual table into FTS auxiliary functions and to the FTS MATCH operator. A virtual table that contains hidden columns can be used like a table-valued function in the FROM clause of a SELECT statement. The arguments to the table-valued function become constraints on the HIDDEN columns of the virtual table. For example, the "generate_series" extension (located in the ext/misc/series.c file in the source tree) implements an eponymous virtual table with the following schema:
CREATE TABLE generate_series(
  value,
  start HIDDEN,
  stop HIDDEN,
  step HIDDEN
);
The sqlite3_module.xBestIndex method in the implementation of this table checks for equality constraints against the HIDDEN columns, and uses those as input parameters to determine the range of integer "value" outputs to generate. Reasonable defaults are used for any unconstrained columns. For example, to list all integers between 5 and 50:
SELECT value FROM generate_series(5,50);
The previous query is equivalent to the following:
SELECT value FROM generate_series WHERE start=5 AND stop=50;
Arguments on the virtual table name are matched to hidden columns in order. The number of arguments can be less than the number of hidden columns, in which case the latter hidden columns are unconstrained. However, an error results if there are more arguments than there are hidden columns in the virtual table. Beginning with SQLite version 3.14.0 (2016-08-08), the CREATE TABLE statement that is passed into sqlite3_declare_vtab() may contain a WITHOUT ROWID clause. This is useful for cases where the virtual table rows cannot easily be mapped into unique integers. A CREATE TABLE statement that includes WITHOUT ROWID must define one or more columns as the PRIMARY KEY. Every column of the PRIMARY KEY must individually be NOT NULL and all columns for each row must be collectively unique. Note that SQLite does not enforce the PRIMARY KEY for a WITHOUT ROWID virtual table. Enforcement is the responsibility of the underlying virtual table implementation. But SQLite does assume that the PRIMARY KEY constraint is valid - that the identified columns really are UNIQUE and NOT NULL - and it uses that assumption to optimize queries against the virtual table. The rowid column is not accessible on a WITHOUT ROWID virtual table (of course). The xUpdate method was originally designed around having a ROWID as a single value. The xUpdate method has been expanded to accommodate an arbitrary PRIMARY KEY in place of the ROWID, but the PRIMARY KEY must still be only one column. For this reason, SQLite will reject any WITHOUT ROWID virtual table that has more than one PRIMARY KEY column and a non-NULL xUpdate method.
xDestroy
int (*xDestroy)(sqlite3_vtab *pVTab);
This method releases a connection to a virtual table, just like the xDisconnect method, and it also destroys the underlying table implementation. This method undoes the work of xCreate. The xDisconnect method is called whenever a database connection that uses a virtual table is closed. The xDestroy method is only called when a DROP TABLE statement is executed against the virtual table. The xDestroy method is required for every virtual table implementation, though it is acceptable for the xDisconnect and xDestroy methods to be the same function if that makes sense for the particular virtual table.
xDisconnect
int (*xDisconnect)(sqlite3_vtab *pVTab);
This method releases a connection to a virtual table. Only the sqlite3_vtab object is destroyed. The virtual table is not destroyed and any backing store associated with the virtual table persists. This method undoes the work of xConnect. This method is a destructor for a connection to the virtual table. Contrast this method with xDestroy. The xDestroy is a destructor for the entire virtual table. The xDisconnect method is required for every virtual table implementation, though it is acceptable for the xDisconnect and xDestroy methods to be the same function if that makes sense for the particular virtual table.
xEof
int (*xEof)(sqlite3_vtab_cursor*);
The xEof method must return false (zero) if the specified cursor currently points to a valid row of data, or true (non-zero) otherwise. This method is called by the SQL engine immediately after each xFilter and xNext invocation. The xEof method is required for every virtual table implementation.
xFilter
int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
              int argc, sqlite3_value **argv);
This method begins a search of a virtual table. The first argument is a cursor opened by xOpen. The next two arguments define a particular search index previously chosen by xBestIndex. The specific meanings of idxNum and idxStr are unimportant as long as xFilter and xBestIndex agree on what that meaning is. The xBestIndex function may have requested the values of certain expressions using the aConstraintUsage[].argvIndex values of the sqlite3_index_info structure. Those values are passed to xFilter using the argc and argv parameters. If the virtual table contains one or more rows that match the search criteria, then the cursor must be left point at the first row. Subsequent calls to xEof must return false (zero). If there are no rows match, then the cursor must be left in a state that will cause the xEof to return true (non-zero). The SQLite engine will use the xColumn and xRowid methods to access that row content. The xNext method will be used to advance to the next row. This method must return SQLITE_OK if successful, or an sqlite error code if an error occurs. The xFilter method is required for every virtual table implementation.
xFindFunction
int (*xFindFunction)(
  sqlite3_vtab *pVtab,
  int nArg,
  const char *zName,
  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
  void **ppArg
);
This method is called during sqlite3_prepare() to give the virtual table implementation an opportunity to overload functions. This method may be set to NULL in which case no overloading occurs. When a function uses a column from a virtual table as its first argument, this method is called to see if the virtual table would like to overload the function. The first three parameters are inputs: the virtual table, the number of arguments to the function, and the name of the function. If no overloading is desired, this method returns 0. To overload the function, this method writes the new function implementation into *pxFunc and writes user data into *ppArg and returns either 1 or a number between SQLITE_INDEX_CONSTRAINT_FUNCTION and 255. Historically, the return value from xFindFunction() was either zero or one. Zero means that the function is not overloaded and one means that it is overload. The ability to return values of SQLITE_INDEX_CONSTRAINT_FUNCTION or greater was added in version 3.25.0 (2018-09-15). If xFindFunction returns SQLITE_INDEX_CONSTRAINT_FUNCTION or greater, than means that the function takes two arguments and the function can be used as a boolean in the WHERE clause of a query and that the virtual table is able to exploit that function to speed up the query result. When xFindFunction returns SQLITE_INDEX_CONSTRAINT_FUNCTION or larger, the value returned becomes the sqlite3_index_info.aConstraint.op value for one of the constraints passed into xBestIndex(). The first argument to the function is the column identified by aConstraint[].iColumn field of the constraint and the second argument to the function is the value that will be passed into xFilter() (if the aConstraintUsage[].argvIndex value is set) or the value returned from sqlite3_vtab_rhs_value(). The Geopoly module is an example of a virtual table that makes use of SQLITE_INDEX_CONSTRAINT_FUNCTION to improve performance. The xFindFunction() method for Geopoly returns SQLITE_INDEX_CONSTRAINT_FUNCTION for the geopoly_overlap() SQL function and it returns SQLITE_INDEX_CONSTRAINT_FUNCTION+1 for the geopoly_within() SQL function. This permits search optimizations for queries such as:
SELECT * FROM geopolytab WHERE geopoly_overlap(_shape, $query_polygon);
SELECT * FROM geopolytab WHERE geopoly_within(_shape, $query_polygon);
Note that infix functions (LIKE, GLOB, REGEXP, and MATCH) reverse the order of their arguments. So "like(A,B)" would normally work the same as "B like A". However, xFindFunction() always looks a the left-most argument, not the first logical argument. Hence, for the form "B like A", SQLite looks at the left operand "B" and if that operand is a virtual table column it invokes the xFindFunction() method on that virtual table. But if the form "like(A,B)" is used instead, then SQLite checks the A term to see if it is column of a virtual table and if so it invokes the xFindFunction() method for the virtual table of column A. The function pointer returned by this routine must be valid for the lifetime of the sqlite3_vtab object given in the first parameter.
xNext
int (*xNext)(sqlite3_vtab_cursor*);
The xNext method advances a virtual table cursor to the next row of a result set initiated by xFilter. If the cursor is already pointing at the last row when this routine is called, then the cursor no longer points to valid data and a subsequent call to the xEof method must return true (non-zero). If the cursor is successfully advanced to another row of content, then subsequent calls to xEof must return false (zero). This method must return SQLITE_OK if successful, or an sqlite error code if an error occurs. The xNext method is required for every virtual table implementation.
xOpen
int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
The xOpen method creates a new cursor used for accessing (read and/or writing) a virtual table. A successful invocation of this method will allocate the memory for the sqlite3_vtab_cursor (or a subclass), initialize the new object, and make *ppCursor point to the new object. The successful call then returns SQLITE_OK. For every successful call to this method, the SQLite core will later invoke the xClose method to destroy the allocated cursor. The xOpen method need not initialize the pVtab field of the sqlite3_vtab_cursor structure. The SQLite core will take care of that chore automatically. A virtual table implementation must be able to support an arbitrary number of simultaneously open cursors. When initially opened, the cursor is in an undefined state. The SQLite core will invoke the xFilter method on the cursor prior to any attempt to position or read from the cursor. The xOpen method is required for every virtual table implementation.
xRelease
int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later. When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M. None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().
xRename
int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
This method provides notification that the virtual table implementation that the virtual table will be given a new name. If this method returns SQLITE_OK then SQLite renames the table. If this method returns an error code then the renaming is prevented. The xRename method is optional. If omitted, then the virtual table may not be renamed using the ALTER TABLE RENAME command. The PRAGMA legacy_alter_table setting is enabled prior to invoking this method, and the value for legacy_alter_table is restored after this method finishes. This is necessary for the correct operation of virtual tables that make use of shadow tables where the shadow tables must be renamed to match the new virtual table name. If the legacy_alter_format is off, then the xConnect method will be invoked for the virtual table every time the xRename method tries to change the name of the shadow table.
xRollback
int (*xRollback)(sqlite3_vtab *pVTab);
This method causes a virtual table transaction to rollback. This is method is optional. The xRollback pointer of sqlite3_module may be NULL. A call to this method always follows a prior call to xBegin.
xRollbackTo
int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later. When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M. None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().
xRowId
int (*xRowid)(sqlite3_vtab_cursor *pCur, sqlite_int64 *pRowid);
A successful invocation of this method will cause *pRowid to be filled with the rowid of row that the virtual table cursor pCur is currently pointing at. This method returns SQLITE_OK on success. It returns an appropriate error code on failure. The xRowid method is required for every virtual table implementation.
xSavepoint
int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);
These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later. When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M. None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().
xSync
int (*xSync)(sqlite3_vtab *pVTab);
This method signals the start of a two-phase commit on a virtual table. This is method is optional. The xSync pointer of sqlite3_module may be NULL. This method is only invoked after call to the xBegin method and prior to an xCommit or xRollback. In order to implement two-phase commit, the xSync method on all virtual tables is invoked prior to invoking the xCommit method on any virtual table. If any of the xSync methods fail, the entire transaction is rolled back.
xUpdate
int (*xUpdate)(
  sqlite3_vtab *pVTab,
  int argc,
  sqlite3_value **argv,
  sqlite_int64 *pRowid
);
All changes to a virtual table are made using the xUpdate method. This one method can be used to insert, delete, or update. The argc parameter specifies the number of entries in the argv array. The value of argc will be 1 for a pure delete operation or N+2 for an insert or replace or update where N is the number of columns in the table. In the previous sentence, N includes any hidden columns. Every argv entry will have a non-NULL value in C but may contain the SQL value NULL. In other words, it is always true that argv[i]!=0 for i between 0 and argc-1. However, it might be the case that sqlite3_value_type(argv[i])==SQLITE_NULL. The argv[0] parameter is the rowid of a row in the virtual table to be deleted. If argv[0] is an SQL NULL, then no deletion occurs. The argv[1] parameter is the rowid of a new row to be inserted into the virtual table. If argv[1] is an SQL NULL, then the implementation must choose a rowid for the newly inserted row. Subsequent argv[] entries contain values of the columns of the virtual table, in the order that the columns were declared. The number of columns will match the table declaration that the xConnect or xCreate method made using the sqlite3_declare_vtab() call. All hidden columns are included. When doing an insert without a rowid (argc>1, argv[1] is an SQL NULL), on a virtual table that uses ROWID (but not on a WITHOUT ROWID virtual table), the implementation must set *pRowid to the rowid of the newly inserted row; this will become the value returned by the sqlite3_last_insert_rowid() function. Setting this value in all the other cases is a harmless no-op; the SQLite engine ignores the *pRowid return value if argc==1 or argv[1] is not an SQL NULL. Each call to xUpdate will fall into one of cases shown below. Not that references to argv[i] mean the SQL value held within the argv[i] object, not the argv[i] object itself.
argc = 1
 argv[0] ≠ NULL

            DELETE: The single row with rowid or PRIMARY KEY equal to argv[0] is deleted.
            No insert occurs.

argc > 1
 argv[0] = NULL

            INSERT: A new row is inserted with column values taken from
            argv[2] and following.  In a rowid virtual table, if argv[1] is an SQL NULL,
            then a new unique rowid is generated automatically.  The argv[1] will be NULL
            for a WITHOUT ROWID virtual table, in which case the implementation should
            take the PRIMARY KEY value from the appropriate column in argv[2] and following.

argc > 1
 argv[0] ≠ NULL
 argv[0] = argv[1]

            UPDATE:
            The row with rowid or PRIMARY KEY argv[0] is updated with new values
            in argv[2] and following parameters.

argc > 1
 argv[0] ≠ NULL
 argv[0] ≠ argv[1]

            UPDATE with rowid or PRIMARY KEY change:
            The row with rowid or PRIMARY KEY argv[0] is updated with
            the rowid or PRIMARY KEY in argv[1]
            and new values in argv[2] and following parameters. This will occur
            when an SQL statement updates a rowid, as in the statement:

               UPDATE table SET rowid=rowid+1 WHERE ...;
The xUpdate method must return SQLITE_OK if and only if it is successful. If a failure occurs, the xUpdate must return an appropriate error code. On a failure, the pVTab->zErrMsg element may optionally be replaced with error message text stored in memory allocated from SQLite using functions such as sqlite3_mprintf() or sqlite3_malloc(). If the xUpdate method violates some constraint of the virtual table (including, but not limited to, attempting to store a value of the wrong datatype, attempting to store a value that is too large or too small, or attempting to change a read-only value) then the xUpdate must fail with an appropriate error code. If the xUpdate method is performing an UPDATE, then sqlite3_value_nochange(X) can be used to discover which columns of the virtual table were actually modified by the UPDATE statement. The sqlite3_value_nochange(X) interface returns true for columns that do not change. On every UPDATE, SQLite will first invoke xColumn separately for each unchanging column in the table to obtain the value for that column. The xColumn method can check to see if the column is unchanged at the SQL level by invoking sqlite3_vtab_nochange(). If xColumn sees that the column is not being modified, it should return without setting a result using one of the sqlite3_result_xxxxx() interfaces. Only in that case sqlite3_value_nochange() will be true within the xUpdate method. If xColumn does invoke one or more sqlite3_result_xxxxx() interfaces, then SQLite understands that as a change in the value of the column and the sqlite3_value_nochange() call for that column within xUpdate will return false. There might be one or more sqlite3_vtab_cursor objects open and in use on the virtual table instance and perhaps even on the row of the virtual table when the xUpdate method is invoked. The implementation of xUpdate must be prepared for attempts to delete or modify rows of the table out from other existing cursors. If the virtual table cannot accommodate such changes, the xUpdate method must return an error code. The xUpdate method is optional. If the xUpdate pointer in the sqlite3_module for a virtual table is a NULL pointer, then the virtual table is read-only.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xBegin Method

int (*xBegin)(sqlite3_vtab *pVTab);

This method begins a transaction on a virtual table. This is method is optional. The xBegin pointer of sqlite3_module may be NULL.

This method is always followed by one call to either the xCommit or xRollback method. Virtual table transactions do not nest, so the xBegin method will not be invoked more than once on a single virtual table without an intervening call to either xCommit or xRollback. Multiple calls to other methods can and likely will occur in between the xBegin and the corresponding xCommit or xRollback.

SQLiteErrorCode xBegin(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xBestIndex Method

SQLite uses the xBestIndex method of a virtual table module to determine the best way to access the virtual table. The xBestIndex method has a prototype like this:

int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);

The SQLite core communicates with the xBestIndex method by filling in certain fields of the sqlite3_index_info structure and passing a pointer to that structure into xBestIndex as the second parameter. The xBestIndex method fills out other fields of this structure which forms the reply. The sqlite3_index_info structure looks like this:

struct sqlite3_index_info {
  /* Inputs */
  const int nConstraint;     /* Number of entries in aConstraint */
  const struct sqlite3_index_constraint {
     int iColumn;              /* Column constrained.  -1 for ROWID */
     unsigned char op;         /* Constraint operator */
     unsigned char usable;     /* True if this constraint is usable */
     int iTermOffset;          /* Used internally - xBestIndex should ignore */
  } *const aConstraint;      /* Table of WHERE clause constraints */
  const int nOrderBy;        /* Number of terms in the ORDER BY clause */
  const struct sqlite3_index_orderby {
     int iColumn;              /* Column number */
     unsigned char desc;       /* True for DESC.  False for ASC. */
  } *const aOrderBy;         /* The ORDER BY clause */
  /* Outputs */
  struct sqlite3_index_constraint_usage {
    int argvIndex;           /* if >0, constraint is part of argv to xFilter */
    unsigned char omit;      /* Do not code a test for this constraint */
  } *const aConstraintUsage;
  int idxNum;                /* Number used to identify the index */
  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
  int orderByConsumed;       /* True if output is already ordered */
  double estimatedCost;      /* Estimated cost of using this index */
  /* Fields below are only available in SQLite 3.8.2 and later */
  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */
  /* Fields below are only available in SQLite 3.9.0 and later */
  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */
  /* Fields below are only available in SQLite 3.10.0 and later */
  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */
};

Note the warnings on the "estimatedRows", "idxFlags", and colUsed fields. These fields were added with SQLite versions 3.8.2, 3.9.0, and 3.10.0, respectively. Any extension that reads or writes these fields must first check that the version of the SQLite library in use is greater than or equal to appropriate version - perhaps comparing the value returned from sqlite3_libversion_number() against constants 3008002, 3009000, and/or 3010000. The result of attempting to access these fields in an sqlite3_index_info structure created by an older version of SQLite are undefined.

In addition, there are some defined constants:

#define SQLITE_INDEX_CONSTRAINT_EQ         2
#define SQLITE_INDEX_CONSTRAINT_GT         4
#define SQLITE_INDEX_CONSTRAINT_LE         8
#define SQLITE_INDEX_CONSTRAINT_LT        16
#define SQLITE_INDEX_CONSTRAINT_GE        32
#define SQLITE_INDEX_CONSTRAINT_MATCH     64
#define SQLITE_INDEX_CONSTRAINT_LIKE      65  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_GLOB      66  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_REGEXP    67  /* 3.10.0 and later */
#define SQLITE_INDEX_CONSTRAINT_NE        68  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNOT     69  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_ISNULL    71  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_IS        72  /* 3.21.0 and later */
#define SQLITE_INDEX_CONSTRAINT_LIMIT     73  /* 3.38.0 and later */
#define SQLITE_INDEX_CONSTRAINT_OFFSET    74  /* 3.38.0 and later */
#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150  /* 3.25.0 and later */
#define SQLITE_INDEX_SCAN_UNIQUE           1  /* Scan visits at most 1 row */

Use the sqlite3_vtab_collation() interface to find the name of the collating sequence that should be used when evaluating the i-th constraint:

const char *sqlite3_vtab_collation(sqlite3_index_info*, int i);

The SQLite core calls the xBestIndex method when it is compiling a query that involves a virtual table. In other words, SQLite calls this method when it is running sqlite3_prepare() or the equivalent. By calling this method, the SQLite core is saying to the virtual table that it needs to access some subset of the rows in the virtual table and it wants to know the most efficient way to do that access. The xBestIndex method replies with information that the SQLite core can then use to conduct an efficient search of the virtual table.

While compiling a single SQL query, the SQLite core might call xBestIndex multiple times with different settings in sqlite3_index_info. The SQLite core will then select the combination that appears to give the best performance.

Before calling this method, the SQLite core initializes an instance of the sqlite3_index_info structure with information about the query that it is currently trying to process. This information derives mainly from the WHERE clause and ORDER BY or GROUP BY clauses of the query, but also from any ON or USING clauses if the query is a join. The information that the SQLite core provides to the xBestIndex method is held in the part of the structure that is marked as "Inputs". The "Outputs" section is initialized to zero.

The information in the sqlite3_index_info structure is ephemeral and may be overwritten or deallocated as soon as the xBestIndex method returns. If the xBestIndex method needs to remember any part of the sqlite3_index_info structure, it should make a copy. Care must be take to store the copy in a place where it will be deallocated, such as in the idxStr field with needToFreeIdxStr set to 1.

Note that xBestIndex will always be called before xFilter, since the idxNum and idxStr outputs from xBestIndex are required inputs to xFilter. However, there is no guarantee that xFilter will be called following a successful xBestIndex.

The xBestIndex method is required for every virtual table implementation.

The main thing that the SQLite core is trying to communicate to the virtual table is the constraints that are available to limit the number of rows that need to be searched. The aConstraint[] array contains one entry for each constraint. There will be exactly nConstraint entries in that array.

Each constraint will usually correspond to a term in the WHERE clause or in a USING or ON clause that is of the form

     column  OP  EXPR

Where "column" is a column in the virtual table, OP is an operator like "=" or "<", and EXPR is an arbitrary expression. So, for example, if the WHERE clause contained a term like this:

a = 5

Then one of the constraints would be on the "a" column with operator "=" and an expression of "5". Constraints need not have a literal representation of the WHERE clause. The query optimizer might make transformations to the WHERE clause in order to extract as many constraints as it can. So, for example, if the WHERE clause contained something like this:

x BETWEEN 10 AND 100 AND 999>y

The query optimizer might translate this into three separate constraints:

x >= 10
x <= 100
y < 999

For each such constraint, the aConstraint[].iColumn field indicates which column appears on the left-hand side of the constraint. The first column of the virtual table is column 0. The rowid of the virtual table is column -1. The aConstraint[].op field indicates which operator is used. The SQLITE_INDEX_CONSTRAINT_* constants map integer constants into operator values. Columns occur in the order they were defined by the call to sqlite3_declare_vtab() in the xCreate or xConnect method. Hidden columns are counted when determining the column index.

If the xFindFunction() method for the virtual table is defined, and if xFindFunction() sometimes returns SQLITE_INDEX_CONSTRAINT_FUNCTION or larger, then the constraints might also be of the form:

     FUNCTION( column, EXPR)

In this case the aConstraint[].op value is the same as the value returned by xFindFunction() for FUNCTION.

The aConstraint[] array contains information about all constraints that apply to the virtual table. But some of the constraints might not be usable because of the way tables are ordered in a join. The xBestIndex method must therefore only consider constraints that have an aConstraint[].usable flag which is true.

In addition to WHERE clause constraints, the SQLite core also tells the xBestIndex method about the ORDER BY clause. (In an aggregate query, the SQLite core might put in GROUP BY clause information in place of the ORDER BY clause information, but this fact should not make any difference to the xBestIndex method.) If all terms of the ORDER BY clause are columns in the virtual table, then nOrderBy will be the number of terms in the ORDER BY clause and the aOrderBy[] array will identify the column for each term in the order by clause and whether or not that column is ASC or DESC.

In SQLite version 3.10.0 (2016-01-06) and later, the colUsed field is available to indicate which fields of the virtual table are actually used by the statement being prepared. If the lowest bit of colUsed is set, that means that the first column is used. The second lowest bit corresponds to the second column. And so forth. If the most significant bit of colUsed is set, that means that one or more columns other than the first 63 columns are used. If column usage information is needed by the xFilter method, then the required bits must be encoded into either the output idxNum field or idxStr content.

For the LIKE, GLOB, REGEXP, and MATCH operators, the aConstraint[].iColumn value is the virtual table column that is the left operand of the operator. However, if these operators are expressed as function calls instead of operators, then the aConstraint[].iColumn value references the virtual table column that is the second argument to that function:

LIKE(EXPR, column)

GLOB(EXPR, column)

REGEXP(EXPR, column)

MATCH(EXPR, column)

Hence, as far as the xBestIndex() method is concerned, the following two forms are equivalent:

          column LIKE EXPR

      LIKE(EXPR,column)

This special behavior of looking at the second argument of a function only occurs for the LIKE, GLOB, REGEXP, and MATCH functions. For all other functions, the aConstraint[].iColumn value references the first argument of the function.

This special feature of LIKE, GLOB, REGEXP, and MATCH does not apply to the xFindFunction() method, however. The xFindFunction() method always keys off of the left operand of an LIKE, GLOB, REGEXP, or MATCH operator but off of the first argument to function-call equivalents of those operators.

When aConstraint[].op is one of SQLITE_INDEX_CONSTRAINT_LIMIT or SQLITE_INDEX_CONSTRAINT_OFFSET, that indicates that there is a LIMIT or OFFSET clause on the SQL query statement that is using the virtual table. The LIMIT and OFFSET operators have no left operand, and so when aConstraint[].op is one of SQLITE_INDEX_CONSTRAINT_LIMIT or SQLITE_INDEX_CONSTRAINT_OFFSET then the aConstraint[].iColumn value is meaningless and should not be used.

The sqlite3_vtab_rhs_value() interface can be used to try to access the right-hand operand of a constraint. However, the value of a right-hand operator might not be known at the time that the xBestIndex method is run, so the sqlite3_vtab_rhs_value() call might not be successful. Usually the right operand of a constraint is only available to xBestIndex if it is coded as a literal value in the input SQL. If the right operand is coded as an expression or a host parameter, it probably will not be accessible to xBestIndex. Some operators, such as SQLITE_INDEX_CONSTRAINT_ISNULL and SQLITE_INDEX_CONSTRAINT_ISNOTNULL have no right-hand operand. The sqlite3_vtab_rhs_value() interface always returns SQLITE_NOTFOUND for such operators.

Given all of the information above, the job of the xBestIndex method it to figure out the best way to search the virtual table.

The xBestIndex method conveys an indexing strategy to the xFilter method through the idxNum and idxStr fields. The idxNum value and idxStr string content are arbitrary as far as the SQLite core is concerned and can have any meaning as long as xBestIndex and xFilter agree on what that meaning is. The SQLite core just copies the information from xBestIndex through to the xFilter method, assuming only that the char sequence referenced via idxStr is NUL terminated.

The idxStr value may be a string obtained from an SQLite memory allocation function such as sqlite3_mprintf(). If this is the case, then the needToFreeIdxStr flag must be set to true so that the SQLite core will know to call sqlite3_free() on that string when it has finished with it, and thus avoid a memory leak. The idxStr value may also be a static constant string, in which case the needToFreeIdxStr boolean should remain false.

The estimatedCost field should be set to the estimated number of disk access operations required to execute this query against the virtual table. The SQLite core will often call xBestIndex multiple times with different constraints, obtain multiple cost estimates, then choose the query plan that gives the lowest estimate. The SQLite core initializes estimatedCost to a very large value prior to invoking xBestIndex, so if xBestIndex determines that the current combination of parameters is undesirable, it can leave the estimatedCost field unchanged to discourage its use.

If the current version of SQLite is 3.8.2 or greater, the estimatedRows field may be set to an estimate of the number of rows returned by the proposed query plan. If this value is not explicitly set, the default estimate of 25 rows is used.

If the current version of SQLite is 3.9.0 or greater, the idxFlags field may be set to SQLITE_INDEX_SCAN_UNIQUE to indicate that the virtual table will return only zero or one rows given the input constraints. Additional bits of the idxFlags field might be understood in later versions of SQLite.

The aConstraintUsage[] array contains one element for each of the nConstraint constraints in the inputs section of the sqlite3_index_info structure. The aConstraintUsage[] array is used by xBestIndex to tell the core how it is using the constraints.

The xBestIndex method may set aConstraintUsage[].argvIndex entries to values greater than zero. Exactly one entry should be set to 1, another to 2, another to 3, and so forth up to as many or as few as the xBestIndex method wants. The EXPR of the corresponding constraints will then be passed in as the argv[] parameters to xFilter.

For example, if the aConstraint[3].argvIndex is set to 1, then when xFilter is called, the argv[0] passed to xFilter will have the EXPR value of the aConstraint[3] constraint.

By default, the SQLite generates bytecode that will double checks all constraints on each row of the virtual table to verify that they are satisfied. If the virtual table can guarantee that a constraint will always be satisfied, it can try to suppress that double-check by setting aConstraintUsage[].omit. However, with some exceptions, this is only a hint and there is no guarantee that the redundant check of the constraint will be suppressed. Key points:

  • The omit flag is only honored if the argvIndex value for the constraint is greater than 0 and less than or equal to 16. Constraint checking is never suppressed for constraints that do not pass their right operand into the xFilter method. The current implementation is only able to suppress redundant constraint checking for the first 16 values passed to xFilter, though that limitation might be increased in future releases.
  • The omit flag is always honored for SQLITE_INDEX_CONSTRAINT_OFFSET constraints as long as argvIndex is greater than 0. Setting the omit flag on an SQLITE_INDEX_CONSTRAINT_OFFSET constraint indicates to SQLite that the virtual table will itself suppress the first N rows of output, where N is the right operand of the OFFSET operator. If the virtual table implementation sets omit on an SQLITE_INDEX_CONSTRAINT_OFFSET constraint but then fails to suppress the first N rows of output, an incorrect answer will result from the overall query.

If the virtual table will output rows in the order specified by the ORDER BY clause, then the orderByConsumed flag may be set to true. If the output is not automatically in the correct order then orderByConsumed must be left in its default false setting. This will indicate to the SQLite core that it will need to do a separate sorting pass over the data after it comes out of the virtual table. Setting orderByConsumed is an optimization. A query will always get the correct answer if orderByConsumed is left at its default value (0). Unnecessary sort operations might be avoided resulting in a faster query if orderByConsumed is set, but setting orderByConsumed incorrectly can result in an incorrect answer. It is suggested that new virtual table implementations leave the orderByConsumed value unset initially, and then after everything else is known to be working correctly, go back and attempt to optimize by setting orderByConsumed where appropriate.

Sometimes the orderByConsumed flag can be safely set even if the outputs from the virtual table are not strictly in the order specified by nOrderBy and aOrderBy. If the sqlite3_vtab_distinct() interface returns 1 or 2, that indicates that the ordering can be relaxed. See the documentation on sqlite3_vtab_distinct() for further information.

The xBestIndex method should return SQLITE_OK on success. If any kind of fatal error occurs, an appropriate error code (ex: SQLITE_NOMEM) should be returned instead.

If xBestIndex returns SQLITE_CONSTRAINT, that does not indicate an error. Rather, SQLITE_CONSTRAINT indicates that the particular combination of input parameters specified is insufficient for the virtual table to do its job. This is logically the same as setting the estimatedCost to infinity. If every call to xBestIndex for a particular query plan returns SQLITE_CONSTRAINT, that means there is no way for the virtual table to be safely used, and the sqlite3_prepare() call will fail with a "no query solution" error.

The SQLITE_CONSTRAINT return from xBestIndex is useful for table-valued functions that have required parameters. If the aConstraint[].usable field is false for one of the required parameter, then the xBestIndex method should return SQLITE_CONSTRAINT. If a required field does not appear in the aConstraint[] array at all, that means that the corresponding parameter is omitted from the input SQL. In that case, xBestIndex should set an error message in pVTab->zErrMsg and return SQLITE_ERROR. To summarize:

  1. The aConstraint[].usable value for a required parameter is false → return SQLITE_CONSTRAINT.
  2. A required parameter does not appears anywhere in the aConstraint[] array → Set an error message in pVTab->zErrMsg and return SQLITE_ERROR

The following example will better illustrate the use of SQLITE_CONSTRAINT as a return value from xBestIndex:

SELECT * FROM realtab, tablevaluedfunc(realtab.x);

Assuming that the first hidden column of "tablevaluedfunc" is "param1", the query above is semantically equivalent to this:

SELECT * FROM realtab, tablevaluedfunc
 WHERE tablevaluedfunc.param1 = realtab.x;

The query planner must decide between many possible implementations of this query, but two plans in particular are of note:

  1. Scan all rows of realtab and for each row, find rows in tablevaluedfunc where param1 is equal to realtab.x
  2. Scan all rows of tablevalued func and for each row find rows in realtab where x is equal to tablevaluedfunc.param1.

The xBestIndex method will be invoked once for each of the potential plans above. For plan 1, the aConstraint[].usable flag for the SQLITE_CONSTRAINT_EQ constraint on the param1 column will be true because the right-hand side value for the "param1 = ?" constraint will be known, since it is determined by the outer realtab loop. But for plan 2, the aConstraint[].usable flag for "param1 = ?" will be false because the right-hand side value is determined by an inner loop and is thus an unknown quantity. Because param1 is a required input to the table-valued functions, the xBestIndex method should return SQLITE_CONSTRAINT when presented with plan 2, indicating that a required input is missing. This forces the query planner to select plan 1.

SQLiteErrorCode xBestIndex(
IntPtr pVtab,
IntPtr pIndex
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
pIndex
The native pointer to the sqlite3_index_info structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xClose Method

int (*xClose)(sqlite3_vtab_cursor*);

The xClose method closes a cursor previously opened by xOpen. The SQLite core will always call xClose once for each cursor opened using xOpen.

This method must release all resources allocated by the corresponding xOpen call. The routine will not be called again even if it returns an error. The SQLite core will not use the sqlite3_vtab_cursor again after it has been closed.

The xClose method is required for every virtual table implementation.

SQLiteErrorCode xClose(
IntPtr pCursor
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xColumn Method

int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int N);

The SQLite core invokes this method in order to find the value for the N-th column of the current row. N is zero-based so the first column is numbered 0. The xColumn method may return its result back to SQLite using one of the following interface:

  • sqlite3_result_blob()
  • sqlite3_result_double()
  • sqlite3_result_int()
  • sqlite3_result_int64()
  • sqlite3_result_null()
  • sqlite3_result_text()
  • sqlite3_result_text16()
  • sqlite3_result_text16le()
  • sqlite3_result_text16be()
  • sqlite3_result_zeroblob()

If the xColumn method implementation calls none of the functions above, then the value of the column defaults to an SQL NULL.

To raise an error, the xColumn method should use one of the result_text() methods to set the error message text, then return an appropriate error code. The xColumn method must return SQLITE_OK on success.

The xColumn method is required for every virtual table implementation.

SQLiteErrorCode xColumn(
IntPtr pCursor,
IntPtr pContext,
int index
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.
pContext
The native pointer to the sqlite3_context structure to be used for returning the specified column value to the SQLite core library.
index
The zero-based index corresponding to the column containing the value to be returned.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xCommit Method

int (*xCommit)(sqlite3_vtab *pVTab);

This method causes a virtual table transaction to commit. This is method is optional. The xCommit pointer of sqlite3_module may be NULL.

A call to this method always follows a prior call to xBegin and xSync.

SQLiteErrorCode xCommit(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xConnect Method

int (*xConnect)(sqlite3*, void *pAux,
             int argc, char *const*argv,
             sqlite3_vtab **ppVTab,
             char **pzErr);

The xConnect method is very similar to xCreate. It has the same parameters and constructs a new sqlite3_vtab structure just like xCreate. And it must also call sqlite3_declare_vtab() like xCreate. It should also make all of the same sqlite3_vtab_config() calls as xCreate.

The difference is that xConnect is called to establish a new connection to an existing virtual table whereas xCreate is called to create a new virtual table from scratch.

The xCreate and xConnect methods are only different when the virtual table has some kind of backing store that must be initialized the first time the virtual table is created. The xCreate method creates and initializes the backing store. The xConnect method just connects to an existing backing store. When xCreate and xConnect are the same, the table is an eponymous virtual table.

As an example, consider a virtual table implementation that provides read-only access to existing comma-separated-value (CSV) files on disk. There is no backing store that needs to be created or initialized for such a virtual table (since the CSV files already exist on disk) so the xCreate and xConnect methods will be identical for that module.

Another example is a virtual table that implements a full-text index. The xCreate method must create and initialize data structures to hold the dictionary and posting lists for that index. The xConnect method, on the other hand, only has to locate and use an existing dictionary and posting lists that were created by a prior xCreate call.

The xConnect method must return SQLITE_OK if it is successful in creating the new virtual table, or SQLITE_ERROR if it is not successful. If not successful, the sqlite3_vtab structure must not be allocated. An error message may optionally be returned in *pzErr if unsuccessful. Space to hold the error message string must be allocated using an SQLite memory allocation function like sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will attempt to free the space using sqlite3_free() after the error has been reported up to the application.

The xConnect method is required for every virtual table implementation, though the xCreate and xConnect pointers of the sqlite3_module object may point to the same function if the virtual table does not need to initialize backing store.

SQLiteErrorCode xConnect(
IntPtr pDb,
IntPtr pAux,
int argc,
IntPtr argv,
ref IntPtr pVtab,
ref IntPtr pError
);

Parameters

pDb
The native database connection handle.
pAux
The original native pointer value that was provided to the sqlite3_create_module(), sqlite3_create_module_v2() or sqlite3_create_disposable_module() functions.
argc
The number of arguments from the CREATE VIRTUAL TABLE statement.
argv
The array of string arguments from the CREATE VIRTUAL TABLE statement.
pVtab
Upon success, this parameter must be modified to point to the newly created native sqlite3_vtab derived structure.
pError
Upon failure, this parameter must be modified to point to the error message, with the underlying memory having been obtained from the sqlite3_malloc() function.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xCreate Method

int (*xCreate)(sqlite3 *db, void *pAux,
             int argc, char *const*argv,
             sqlite3_vtab **ppVTab,
             char **pzErr);

The xCreate method is called to create a new instance of a virtual table in response to a CREATE VIRTUAL TABLE statement. If the xCreate method is the same pointer as the xConnect method, then the virtual table is an eponymous virtual table. If the xCreate method is omitted (if it is a NULL pointer) then the virtual table is an eponymous-only virtual table.

The db parameter is a pointer to the SQLite database connection that is executing the CREATE VIRTUAL TABLE statement. The pAux argument is the copy of the client data pointer that was the fourth argument to the sqlite3_create_module() or sqlite3_create_module_v2() call that registered the virtual table module. The argv parameter is an array of argc pointers to null terminated strings. The first string, argv[0], is the name of the module being invoked. The module name is the name provided as the second argument to sqlite3_create_module() and as the argument to the USING clause of the CREATE VIRTUAL TABLE statement that is running. The second, argv[1], is the name of the database in which the new virtual table is being created. The database name is "main" for the primary database, or "temp" for TEMP database, or the name given at the end of the ATTACH statement for attached databases. The third element of the array, argv[2], is the name of the new virtual table, as specified following the TABLE keyword in the CREATE VIRTUAL TABLE statement. If present, the fourth and subsequent strings in the argv[] array report the arguments to the module name in the CREATE VIRTUAL TABLE statement.

The job of this method is to construct the new virtual table object (an sqlite3_vtab object) and return a pointer to it in *ppVTab.

As part of the task of creating a new sqlite3_vtab structure, this method must invoke sqlite3_declare_vtab() to tell the SQLite core about the columns and datatypes in the virtual table. The sqlite3_declare_vtab() API has the following prototype:

int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable)

The first argument to sqlite3_declare_vtab() must be the same database connection pointer as the first parameter to this method. The second argument to sqlite3_declare_vtab() must a zero-terminated UTF-8 string that contains a well-formed CREATE TABLE statement that defines the columns in the virtual table and their data types. The name of the table in this CREATE TABLE statement is ignored, as are all constraints. Only the column names and datatypes matter. The CREATE TABLE statement string need not to be held in persistent memory. The string can be deallocated and/or reused as soon as the sqlite3_declare_vtab() routine returns.

The xConnect method can also optionally request special features for the virtual table by making one or more calls to the sqlite3_vtab_config() interface:

int sqlite3_vtab_config(sqlite3 *db, int op, ...);

Calls to sqlite3_vtab_config() are optional. But for maximum security, it is recommended that virtual table implementations invoke "sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY)" if the virtual table will not be used from inside of triggers or views.

The xCreate method need not initialize the pModule, nRef, and zErrMsg fields of the sqlite3_vtab object. The SQLite core will take care of that chore.

The xCreate should return SQLITE_OK if it is successful in creating the new virtual table, or SQLITE_ERROR if it is not successful. If not successful, the sqlite3_vtab structure must not be allocated. An error message may optionally be returned in *pzErr if unsuccessful. Space to hold the error message string must be allocated using an SQLite memory allocation function like sqlite3_malloc() or sqlite3_mprintf() as the SQLite core will attempt to free the space using sqlite3_free() after the error has been reported up to the application.

If the xCreate method is omitted (left as a NULL pointer) then the virtual table is an eponymous-only virtual table. New instances of the virtual table cannot be created using CREATE VIRTUAL TABLE and the virtual table can only be used via its module name. Note that SQLite versions prior to 3.9.0 (2015-10-14) do not understand eponymous-only virtual tables and will segfault if an attempt is made to CREATE VIRTUAL TABLE on an eponymous-only virtual table because the xCreate method was not checked for null.

If the xCreate method is the exact same pointer as the xConnect method, that indicates that the virtual table does not need to initialize backing store. Such a virtual table can be used as an eponymous virtual table or as a named virtual table using CREATE VIRTUAL TABLE or both.

If a column datatype contains the special keyword "HIDDEN" (in any combination of upper and lower case letters) then that keyword it is omitted from the column datatype name and the column is marked as a hidden column internally. A hidden column differs from a normal column in three respects:

  • Hidden columns are not listed in the dataset returned by "PRAGMA table_info",
  • Hidden columns are not included in the expansion of a "*" expression in the result set of a SELECT, and
  • Hidden columns are not included in the implicit column-list used by an INSERT statement that lacks an explicit column-list.

For example, if the following SQL is passed to sqlite3_declare_vtab():

CREATE TABLE x(a HIDDEN VARCHAR(12), b INTEGER, c INTEGER Hidden);

Then the virtual table would be created with two hidden columns, and with datatypes of "VARCHAR(12)" and "INTEGER".

An example use of hidden columns can be seen in the FTS3 virtual table implementation, where every FTS virtual table contains an FTS hidden column that is used to pass information from the virtual table into FTS auxiliary functions and to the FTS MATCH operator.

A virtual table that contains hidden columns can be used like a table-valued function in the FROM clause of a SELECT statement. The arguments to the table-valued function become constraints on the HIDDEN columns of the virtual table.

For example, the "generate_series" extension (located in the ext/misc/series.c file in the source tree) implements an eponymous virtual table with the following schema:

CREATE TABLE generate_series(
  value,
  start HIDDEN,
  stop HIDDEN,
  step HIDDEN
);

The sqlite3_module.xBestIndex method in the implementation of this table checks for equality constraints against the HIDDEN columns, and uses those as input parameters to determine the range of integer "value" outputs to generate. Reasonable defaults are used for any unconstrained columns. For example, to list all integers between 5 and 50:

SELECT value FROM generate_series(5,50);

The previous query is equivalent to the following:

SELECT value FROM generate_series WHERE start=5 AND stop=50;

Arguments on the virtual table name are matched to hidden columns in order. The number of arguments can be less than the number of hidden columns, in which case the latter hidden columns are unconstrained. However, an error results if there are more arguments than there are hidden columns in the virtual table.

Beginning with SQLite version 3.14.0 (2016-08-08), the CREATE TABLE statement that is passed into sqlite3_declare_vtab() may contain a WITHOUT ROWID clause. This is useful for cases where the virtual table rows cannot easily be mapped into unique integers. A CREATE TABLE statement that includes WITHOUT ROWID must define one or more columns as the PRIMARY KEY. Every column of the PRIMARY KEY must individually be NOT NULL and all columns for each row must be collectively unique.

Note that SQLite does not enforce the PRIMARY KEY for a WITHOUT ROWID virtual table. Enforcement is the responsibility of the underlying virtual table implementation. But SQLite does assume that the PRIMARY KEY constraint is valid - that the identified columns really are UNIQUE and NOT NULL - and it uses that assumption to optimize queries against the virtual table.

The rowid column is not accessible on a WITHOUT ROWID virtual table (of course).

The xUpdate method was originally designed around having a ROWID as a single value. The xUpdate method has been expanded to accommodate an arbitrary PRIMARY KEY in place of the ROWID, but the PRIMARY KEY must still be only one column. For this reason, SQLite will reject any WITHOUT ROWID virtual table that has more than one PRIMARY KEY column and a non-NULL xUpdate method.

SQLiteErrorCode xCreate(
IntPtr pDb,
IntPtr pAux,
int argc,
IntPtr argv,
ref IntPtr pVtab,
ref IntPtr pError
);

Parameters

pDb
The native database connection handle.
pAux
The original native pointer value that was provided to the sqlite3_create_module(), sqlite3_create_module_v2() or sqlite3_create_disposable_module() functions.
argc
The number of arguments from the CREATE VIRTUAL TABLE statement.
argv
The array of string arguments from the CREATE VIRTUAL TABLE statement.
pVtab
Upon success, this parameter must be modified to point to the newly created native sqlite3_vtab derived structure.
pError
Upon failure, this parameter must be modified to point to the error message, with the underlying memory having been obtained from the sqlite3_malloc() function.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xDestroy Method

int (*xDestroy)(sqlite3_vtab *pVTab);

This method releases a connection to a virtual table, just like the xDisconnect method, and it also destroys the underlying table implementation. This method undoes the work of xCreate.

The xDisconnect method is called whenever a database connection that uses a virtual table is closed. The xDestroy method is only called when a DROP TABLE statement is executed against the virtual table.

The xDestroy method is required for every virtual table implementation, though it is acceptable for the xDisconnect and xDestroy methods to be the same function if that makes sense for the particular virtual table.

SQLiteErrorCode xDestroy(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xDisconnect Method

int (*xDisconnect)(sqlite3_vtab *pVTab);

This method releases a connection to a virtual table. Only the sqlite3_vtab object is destroyed. The virtual table is not destroyed and any backing store associated with the virtual table persists.

This method undoes the work of xConnect.

This method is a destructor for a connection to the virtual table. Contrast this method with xDestroy. The xDestroy is a destructor for the entire virtual table.

The xDisconnect method is required for every virtual table implementation, though it is acceptable for the xDisconnect and xDestroy methods to be the same function if that makes sense for the particular virtual table.

SQLiteErrorCode xDisconnect(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xEof Method

int (*xEof)(sqlite3_vtab_cursor*);

The xEof method must return false (zero) if the specified cursor currently points to a valid row of data, or true (non-zero) otherwise. This method is called by the SQL engine immediately after each xFilter and xNext invocation.

The xEof method is required for every virtual table implementation.

int xEof(
IntPtr pCursor
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.

Return Value

Non-zero if no more rows are available; zero otherwise.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xFilter Method

int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
              int argc, sqlite3_value **argv);

This method begins a search of a virtual table. The first argument is a cursor opened by xOpen. The next two arguments define a particular search index previously chosen by xBestIndex. The specific meanings of idxNum and idxStr are unimportant as long as xFilter and xBestIndex agree on what that meaning is.

The xBestIndex function may have requested the values of certain expressions using the aConstraintUsage[].argvIndex values of the sqlite3_index_info structure. Those values are passed to xFilter using the argc and argv parameters.

If the virtual table contains one or more rows that match the search criteria, then the cursor must be left point at the first row. Subsequent calls to xEof must return false (zero). If there are no rows match, then the cursor must be left in a state that will cause the xEof to return true (non-zero). The SQLite engine will use the xColumn and xRowid methods to access that row content. The xNext method will be used to advance to the next row.

This method must return SQLITE_OK if successful, or an sqlite error code if an error occurs.

The xFilter method is required for every virtual table implementation.

SQLiteErrorCode xFilter(
IntPtr pCursor,
int idxNum,
IntPtr idxStr,
int argc,
IntPtr argv
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.
idxNum
Number used to help identify the selected index.
idxStr
The native pointer to the UTF-8 encoded string containing the string used to help identify the selected index.
argc
The number of native pointers to sqlite3_value structures specified in argv.
argv
An array of native pointers to sqlite3_value structures containing filtering criteria for the selected index.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xFindFunction Method

int (*xFindFunction)(
  sqlite3_vtab *pVtab,
  int nArg,
  const char *zName,
  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
  void **ppArg
);

This method is called during sqlite3_prepare() to give the virtual table implementation an opportunity to overload functions. This method may be set to NULL in which case no overloading occurs.

When a function uses a column from a virtual table as its first argument, this method is called to see if the virtual table would like to overload the function. The first three parameters are inputs: the virtual table, the number of arguments to the function, and the name of the function. If no overloading is desired, this method returns 0. To overload the function, this method writes the new function implementation into *pxFunc and writes user data into *ppArg and returns either 1 or a number between SQLITE_INDEX_CONSTRAINT_FUNCTION and 255.

Historically, the return value from xFindFunction() was either zero or one. Zero means that the function is not overloaded and one means that it is overload. The ability to return values of SQLITE_INDEX_CONSTRAINT_FUNCTION or greater was added in version 3.25.0 (2018-09-15). If xFindFunction returns SQLITE_INDEX_CONSTRAINT_FUNCTION or greater, than means that the function takes two arguments and the function can be used as a boolean in the WHERE clause of a query and that the virtual table is able to exploit that function to speed up the query result. When xFindFunction returns SQLITE_INDEX_CONSTRAINT_FUNCTION or larger, the value returned becomes the sqlite3_index_info.aConstraint.op value for one of the constraints passed into xBestIndex(). The first argument to the function is the column identified by aConstraint[].iColumn field of the constraint and the second argument to the function is the value that will be passed into xFilter() (if the aConstraintUsage[].argvIndex value is set) or the value returned from sqlite3_vtab_rhs_value().

The Geopoly module is an example of a virtual table that makes use of SQLITE_INDEX_CONSTRAINT_FUNCTION to improve performance. The xFindFunction() method for Geopoly returns SQLITE_INDEX_CONSTRAINT_FUNCTION for the geopoly_overlap() SQL function and it returns SQLITE_INDEX_CONSTRAINT_FUNCTION+1 for the geopoly_within() SQL function. This permits search optimizations for queries such as:

SELECT * FROM geopolytab WHERE geopoly_overlap(_shape, $query_polygon);
SELECT * FROM geopolytab WHERE geopoly_within(_shape, $query_polygon);

Note that infix functions (LIKE, GLOB, REGEXP, and MATCH) reverse the order of their arguments. So "like(A,B)" would normally work the same as "B like A". However, xFindFunction() always looks a the left-most argument, not the first logical argument. Hence, for the form "B like A", SQLite looks at the left operand "B" and if that operand is a virtual table column it invokes the xFindFunction() method on that virtual table. But if the form "like(A,B)" is used instead, then SQLite checks the A term to see if it is column of a virtual table and if so it invokes the xFindFunction() method for the virtual table of column A.

The function pointer returned by this routine must be valid for the lifetime of the sqlite3_vtab object given in the first parameter.

int xFindFunction(
IntPtr pVtab,
int nArg,
IntPtr zName,
ref SQLiteCallback callback,
ref IntPtr pClientData
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
nArg
The number of arguments to the function being sought.
zName
The name of the function being sought.
callback
Upon success, this parameter must be modified to contain the delegate responsible for implementing the specified function.
pClientData
Upon success, this parameter must be modified to contain the native user-data pointer associated with callback.

Return Value

Non-zero if the specified function was found; zero otherwise.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xNext Method

int (*xNext)(sqlite3_vtab_cursor*);

The xNext method advances a virtual table cursor to the next row of a result set initiated by xFilter. If the cursor is already pointing at the last row when this routine is called, then the cursor no longer points to valid data and a subsequent call to the xEof method must return true (non-zero). If the cursor is successfully advanced to another row of content, then subsequent calls to xEof must return false (zero).

This method must return SQLITE_OK if successful, or an sqlite error code if an error occurs.

The xNext method is required for every virtual table implementation.

SQLiteErrorCode xNext(
IntPtr pCursor
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xOpen Method

int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);

The xOpen method creates a new cursor used for accessing (read and/or writing) a virtual table. A successful invocation of this method will allocate the memory for the sqlite3_vtab_cursor (or a subclass), initialize the new object, and make *ppCursor point to the new object. The successful call then returns SQLITE_OK.

For every successful call to this method, the SQLite core will later invoke the xClose method to destroy the allocated cursor.

The xOpen method need not initialize the pVtab field of the sqlite3_vtab_cursor structure. The SQLite core will take care of that chore automatically.

A virtual table implementation must be able to support an arbitrary number of simultaneously open cursors.

When initially opened, the cursor is in an undefined state. The SQLite core will invoke the xFilter method on the cursor prior to any attempt to position or read from the cursor.

The xOpen method is required for every virtual table implementation.

SQLiteErrorCode xOpen(
IntPtr pVtab,
ref IntPtr pCursor
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
pCursor
Upon success, this parameter must be modified to point to the newly created native sqlite3_vtab_cursor derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xRelease Method

int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);

These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later.

When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M.

None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().

SQLiteErrorCode xRelease(
IntPtr pVtab,
int iSavepoint
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
iSavepoint
This is an integer used to indicate that any saved states with an identifier greater than or equal to this should be deleted by the virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xRename Method

int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);

This method provides notification that the virtual table implementation that the virtual table will be given a new name. If this method returns SQLITE_OK then SQLite renames the table. If this method returns an error code then the renaming is prevented.

The xRename method is optional. If omitted, then the virtual table may not be renamed using the ALTER TABLE RENAME command.

The PRAGMA legacy_alter_table setting is enabled prior to invoking this method, and the value for legacy_alter_table is restored after this method finishes. This is necessary for the correct operation of virtual tables that make use of shadow tables where the shadow tables must be renamed to match the new virtual table name. If the legacy_alter_format is off, then the xConnect method will be invoked for the virtual table every time the xRename method tries to change the name of the shadow table.

SQLiteErrorCode xRename(
IntPtr pVtab,
IntPtr zNew
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
zNew
The native pointer to the UTF-8 encoded string containing the new name for the virtual table.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xRollback Method

int (*xRollback)(sqlite3_vtab *pVTab);

This method causes a virtual table transaction to rollback. This is method is optional. The xRollback pointer of sqlite3_module may be NULL.

A call to this method always follows a prior call to xBegin.

SQLiteErrorCode xRollback(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xRollbackTo Method

int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);

These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later.

When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M.

None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().

SQLiteErrorCode xRollbackTo(
IntPtr pVtab,
int iSavepoint
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
iSavepoint
This is an integer identifier used to specify a specific saved state for the virtual table for it to restore itself back to, which should also have the effect of deleting all saved states with an integer identifier greater than this one.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xRowId Method

int (*xRowid)(sqlite3_vtab_cursor *pCur, sqlite_int64 *pRowid);

A successful invocation of this method will cause *pRowid to be filled with the rowid of row that the virtual table cursor pCur is currently pointing at. This method returns SQLITE_OK on success. It returns an appropriate error code on failure.

The xRowid method is required for every virtual table implementation.

SQLiteErrorCode xRowId(
IntPtr pCursor,
ref long rowId
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.
rowId
Upon success, this parameter must be modified to contain the unique integer row identifier for the current row for the specified cursor.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xSavepoint Method

int (*xSavepoint)(sqlite3_vtab *pVtab, int);
int (*xRelease)(sqlite3_vtab *pVtab, int);
int (*xRollbackTo)(sqlite3_vtab *pVtab, int);

These methods provide the virtual table implementation an opportunity to implement nested transactions. They are always optional and will only be called in SQLite version 3.7.7 (2011-06-23) and later.

When xSavepoint(X,N) is invoked, that is a signal to the virtual table X that it should save its current state as savepoint N. A subsequent call to xRollbackTo(X,R) means that the state of the virtual table should return to what it was when xSavepoint(X,R) was last called. The call to xRollbackTo(X,R) will invalidate all savepoints with N>R; none of the invalided savepoints will be rolled back or released without first being reinitialized by a call to xSavepoint(). A call to xRelease(X,M) invalidates all savepoints where N>=M.

None of the xSavepoint(), xRelease(), or xRollbackTo() methods will ever be called except in between calls to xBegin() and either xCommit() or xRollback().

SQLiteErrorCode xSavepoint(
IntPtr pVtab,
int iSavepoint
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
iSavepoint
This is an integer identifier under which the the current state of the virtual table should be saved.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xSync Method

int (*xSync)(sqlite3_vtab *pVTab);

This method signals the start of a two-phase commit on a virtual table. This is method is optional. The xSync pointer of sqlite3_module may be NULL.

This method is only invoked after call to the xBegin method and prior to an xCommit or xRollback. In order to implement two-phase commit, the xSync method on all virtual tables is invoked prior to invoking the xCommit method on any virtual table. If any of the xSync methods fail, the entire transaction is rolled back.

SQLiteErrorCode xSync(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteNativeModule.xUpdate Method

int (*xUpdate)(
  sqlite3_vtab *pVTab,
  int argc,
  sqlite3_value **argv,
  sqlite_int64 *pRowid
);

All changes to a virtual table are made using the xUpdate method. This one method can be used to insert, delete, or update.

The argc parameter specifies the number of entries in the argv array. The value of argc will be 1 for a pure delete operation or N+2 for an insert or replace or update where N is the number of columns in the table. In the previous sentence, N includes any hidden columns.

Every argv entry will have a non-NULL value in C but may contain the SQL value NULL. In other words, it is always true that argv[i]!=0 for i between 0 and argc-1. However, it might be the case that sqlite3_value_type(argv[i])==SQLITE_NULL.

The argv[0] parameter is the rowid of a row in the virtual table to be deleted. If argv[0] is an SQL NULL, then no deletion occurs.

The argv[1] parameter is the rowid of a new row to be inserted into the virtual table. If argv[1] is an SQL NULL, then the implementation must choose a rowid for the newly inserted row. Subsequent argv[] entries contain values of the columns of the virtual table, in the order that the columns were declared. The number of columns will match the table declaration that the xConnect or xCreate method made using the sqlite3_declare_vtab() call. All hidden columns are included.

When doing an insert without a rowid (argc>1, argv[1] is an SQL NULL), on a virtual table that uses ROWID (but not on a WITHOUT ROWID virtual table), the implementation must set *pRowid to the rowid of the newly inserted row; this will become the value returned by the sqlite3_last_insert_rowid() function. Setting this value in all the other cases is a harmless no-op; the SQLite engine ignores the *pRowid return value if argc==1 or argv[1] is not an SQL NULL.

Each call to xUpdate will fall into one of cases shown below. Not that references to argv[i] mean the SQL value held within the argv[i] object, not the argv[i] object itself.

argc = 1
 argv[0] ≠ NULL

            DELETE: The single row with rowid or PRIMARY KEY equal to argv[0] is deleted.
            No insert occurs.

argc > 1
 argv[0] = NULL

            INSERT: A new row is inserted with column values taken from
            argv[2] and following.  In a rowid virtual table, if argv[1] is an SQL NULL,
            then a new unique rowid is generated automatically.  The argv[1] will be NULL
            for a WITHOUT ROWID virtual table, in which case the implementation should
            take the PRIMARY KEY value from the appropriate column in argv[2] and following.

argc > 1
 argv[0] ≠ NULL
 argv[0] = argv[1]

            UPDATE:
            The row with rowid or PRIMARY KEY argv[0] is updated with new values
            in argv[2] and following parameters.

argc > 1
 argv[0] ≠ NULL
 argv[0] ≠ argv[1]

            UPDATE with rowid or PRIMARY KEY change:
            The row with rowid or PRIMARY KEY argv[0] is updated with
            the rowid or PRIMARY KEY in argv[1]
            and new values in argv[2] and following parameters. This will occur
            when an SQL statement updates a rowid, as in the statement:

               UPDATE table SET rowid=rowid+1 WHERE ...;

The xUpdate method must return SQLITE_OK if and only if it is successful. If a failure occurs, the xUpdate must return an appropriate error code. On a failure, the pVTab->zErrMsg element may optionally be replaced with error message text stored in memory allocated from SQLite using functions such as sqlite3_mprintf() or sqlite3_malloc().

If the xUpdate method violates some constraint of the virtual table (including, but not limited to, attempting to store a value of the wrong datatype, attempting to store a value that is too large or too small, or attempting to change a read-only value) then the xUpdate must fail with an appropriate error code.

If the xUpdate method is performing an UPDATE, then sqlite3_value_nochange(X) can be used to discover which columns of the virtual table were actually modified by the UPDATE statement. The sqlite3_value_nochange(X) interface returns true for columns that do not change. On every UPDATE, SQLite will first invoke xColumn separately for each unchanging column in the table to obtain the value for that column. The xColumn method can check to see if the column is unchanged at the SQL level by invoking sqlite3_vtab_nochange(). If xColumn sees that the column is not being modified, it should return without setting a result using one of the sqlite3_result_xxxxx() interfaces. Only in that case sqlite3_value_nochange() will be true within the xUpdate method. If xColumn does invoke one or more sqlite3_result_xxxxx() interfaces, then SQLite understands that as a change in the value of the column and the sqlite3_value_nochange() call for that column within xUpdate will return false.

There might be one or more sqlite3_vtab_cursor objects open and in use on the virtual table instance and perhaps even on the row of the virtual table when the xUpdate method is invoked. The implementation of xUpdate must be prepared for attempts to delete or modify rows of the table out from other existing cursors. If the virtual table cannot accommodate such changes, the xUpdate method must return an error code.

The xUpdate method is optional. If the xUpdate pointer in the sqlite3_module for a virtual table is a NULL pointer, then the virtual table is read-only.

SQLiteErrorCode xUpdate(
IntPtr pVtab,
int argc,
IntPtr argv,
ref long rowId
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
argc
The number of new or modified column values contained in argv.
argv
The array of native pointers to sqlite3_value structures containing the new or modified column values, if any.
rowId
Upon success, this parameter must be modified to contain the unique integer row identifier for the row that was inserted, if any.

Return Value

A standard SQLite return code.

See Also

ISQLiteNativeModule Interface | System.Data.SQLite Namespace


ISQLiteSchemaExtensions Interface

For a list of all members of this type, see ISQLiteSchemaExtensions Members .

public interface ISQLiteSchemaExtensions

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteSchemaExtensions Members | System.Data.SQLite Namespace


ISQLiteSchemaExtensions Members

ISQLiteSchemaExtensions overview

Public Instance Methods

BuildTempSchema Creates temporary tables on the connection so schema information can be queried.

See Also

ISQLiteSchemaExtensions Interface | System.Data.SQLite Namespace


ISQLiteSchemaExtensions Methods

The methods of the ISQLiteSchemaExtensions interface are listed below. For a complete list of ISQLiteSchemaExtensions interface members, see the ISQLiteSchemaExtensions Members topic.

Public Instance Methods

BuildTempSchema Creates temporary tables on the connection so schema information can be queried.

See Also

ISQLiteSchemaExtensions Interface | System.Data.SQLite Namespace


ISQLiteSchemaExtensions.BuildTempSchema Method

Creates temporary tables on the connection so schema information can be queried.

void BuildTempSchema(
SQLiteConnection connection
);

Parameters

connection
The connection upon which to build the schema tables.

See Also

ISQLiteSchemaExtensions Interface | System.Data.SQLite Namespace


ISQLiteSession Interface

This interface contains methods to query and manipulate the state of a change tracking session for a database.

For a list of all members of this type, see ISQLiteSession Members .

public interface ISQLiteSession : IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ISQLiteSession Members | System.Data.SQLite Namespace


ISQLiteSession Members

ISQLiteSession overview

Public Instance Methods

AttachTable | Upon success, causes changes to the specified table(s) to start being tracked. Any tables impacted by calls to this method will not cause the SessionTableFilterCallback callback to be invoked.
CreateChangeSet | Overloaded. Attempts to create and return, via rawData, the combined set of changes represented by this session instance.
CreatePatchSet | Overloaded. Attempts to create and return, via rawData, the combined set of changes represented by this session instance as a patch set.
GetMemoryBytesInUse | This method attempts to determine the amount of memory used by the session.
IsEmpty | Determines if there are any tracked changes currently within the data for this session.
IsEnabled | Determines if this session is currently tracking changes to its associated database.
IsIndirect | Determines if this session is currently set to mark changes as indirect (i.e. as though they were made via a trigger or foreign key action).
LoadDifferencesFromTable | This method loads the differences between two tables [with the same name, set of columns, and primary key definition] into this session instance.
SetTableFilter | This method is used to set the table filter for this instance.
SetToDirect | Clears the indirect flag for this session. Subsequent changes will be marked as direct until this flag is changed again.
SetToDisabled | Disables tracking of changes to the associated database.
SetToEnabled | Enables tracking of changes to the associated database.
SetToIndirect | Sets the indirect flag for this session. Subsequent changes will be marked as indirect until this flag is changed again.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession Methods

The methods of the ISQLiteSession interface are listed below. For a complete list of ISQLiteSession interface members, see the ISQLiteSession Members topic.

Public Instance Methods

AttachTable | Upon success, causes changes to the specified table(s) to start being tracked. Any tables impacted by calls to this method will not cause the SessionTableFilterCallback callback to be invoked.
CreateChangeSet | Overloaded. Attempts to create and return, via rawData, the combined set of changes represented by this session instance.
CreatePatchSet | Overloaded. Attempts to create and return, via rawData, the combined set of changes represented by this session instance as a patch set.
GetMemoryBytesInUse | This method attempts to determine the amount of memory used by the session.
IsEmpty | Determines if there are any tracked changes currently within the data for this session.
IsEnabled | Determines if this session is currently tracking changes to its associated database.
IsIndirect | Determines if this session is currently set to mark changes as indirect (i.e. as though they were made via a trigger or foreign key action).
LoadDifferencesFromTable | This method loads the differences between two tables [with the same name, set of columns, and primary key definition] into this session instance.
SetTableFilter | This method is used to set the table filter for this instance.
SetToDirect | Clears the indirect flag for this session. Subsequent changes will be marked as direct until this flag is changed again.
SetToDisabled | Disables tracking of changes to the associated database.
SetToEnabled | Enables tracking of changes to the associated database.
SetToIndirect | Sets the indirect flag for this session. Subsequent changes will be marked as indirect until this flag is changed again.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.AttachTable Method

Upon success, causes changes to the specified table(s) to start being tracked. Any tables impacted by calls to this method will not cause the SessionTableFilterCallback callback to be invoked.

void AttachTable(
string name
);

Parameters

name
The name of the table to be tracked -OR- null to track all applicable tables within this database.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


CreateChangeSet Method

SQLite ADO.NET Provider

ISQLiteSession.CreateChangeSet Method

Attempts to create and return, via rawData, the combined set of changes represented by this session instance.

Overload List

Attempts to create and return, via rawData, the combined set of changes represented by this session instance.

void CreateChangeSet(ref byte[])

Attempts to create and write, via stream, the combined set of changes represented by this session instance.

void CreateChangeSet(Stream)

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.CreateChangeSet(Byte) Method

Attempts to create and return, via rawData, the combined set of changes represented by this session instance.

void CreateChangeSet(
ref byte[] rawData
);

Parameters

rawData
Upon success, this will contain the raw byte data for all the changes in this session instance.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace | ISQLiteSession.CreateChangeSet Overload List


ISQLiteSession.CreateChangeSet(Stream) Method

Attempts to create and write, via stream, the combined set of changes represented by this session instance.

void CreateChangeSet(
Stream stream
);

Parameters

stream
Upon success, the raw byte data for all the changes in this session instance will be written to this Stream.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace | ISQLiteSession.CreateChangeSet Overload List


CreatePatchSet Method

SQLite ADO.NET Provider

ISQLiteSession.CreatePatchSet Method

Attempts to create and return, via rawData, the combined set of changes represented by this session instance as a patch set.

Overload List

Attempts to create and return, via rawData, the combined set of changes represented by this session instance as a patch set.

void CreatePatchSet(ref byte[])

Attempts to create and write, via stream, the combined set of changes represented by this session instance as a patch set.

void CreatePatchSet(Stream)

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.CreatePatchSet(Byte) Method

Attempts to create and return, via rawData, the combined set of changes represented by this session instance as a patch set.

void CreatePatchSet(
ref byte[] rawData
);

Parameters

rawData
Upon success, this will contain the raw byte data for all the changes in this session instance.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace | ISQLiteSession.CreatePatchSet Overload List


ISQLiteSession.CreatePatchSet(Stream) Method

Attempts to create and write, via stream, the combined set of changes represented by this session instance as a patch set.

void CreatePatchSet(
Stream stream
);

Parameters

stream
Upon success, the raw byte data for all the changes in this session instance will be written to this Stream.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace | ISQLiteSession.CreatePatchSet Overload List


ISQLiteSession.GetMemoryBytesInUse Method

This method attempts to determine the amount of memory used by the session.

long GetMemoryBytesInUse();

Return Value

Number of bytes used by the session -OR- negative one if its value cannot be obtained.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.IsEmpty Method

Determines if there are any tracked changes currently within the data for this session.

bool IsEmpty();

Return Value

Non-zero if there are no changes within the data for this session; otherwise, zero.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.IsEnabled Method

Determines if this session is currently tracking changes to its associated database.

bool IsEnabled();

Return Value

Non-zero if changes to the associated database are being trakced; otherwise, zero.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.IsIndirect Method

Determines if this session is currently set to mark changes as indirect (i.e. as though they were made via a trigger or foreign key action).

bool IsIndirect();

Return Value

Non-zero if changes to the associated database are being marked as indirect; otherwise, zero.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.LoadDifferencesFromTable Method

This method loads the differences between two tables [with the same name, set of columns, and primary key definition] into this session instance.

void LoadDifferencesFromTable(
string fromDatabaseName,
string tableName
);

Parameters

fromDatabaseName
The name of the database containing the table with the original data (i.e. it will need updating in order to be identical to the one within the database associated with this session instance).
tableName
The name of the table.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.SetTableFilter Method

This method is used to set the table filter for this instance.

void SetTableFilter(
SessionTableFilterCallback callback,
object clientData
);

Parameters

callback
The table filter callback -OR- null to clear any existing table filter callback.
clientData
The optional application-defined context data. This value may be null.

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.SetToDirect Method

Clears the indirect flag for this session. Subsequent changes will be marked as direct until this flag is changed again.

void SetToDirect();

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.SetToDisabled Method

Disables tracking of changes to the associated database.

void SetToDisabled();

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.SetToEnabled Method

Enables tracking of changes to the associated database.

void SetToEnabled();

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


ISQLiteSession.SetToIndirect Method

Sets the indirect flag for this session. Subsequent changes will be marked as indirect until this flag is changed again.

void SetToIndirect();

See Also

ISQLiteSession Interface | System.Data.SQLite Namespace


LogEventArgs Class

Event data for logging event handlers.

For a list of all members of this type, see LogEventArgs Members .

System.Object
EventArgs
LogEventArgs

public class LogEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

LogEventArgs Members | System.Data.SQLite Namespace


LogEventArgs Members

LogEventArgs overview

Public Instance Fields

Data | Extra data associated with this event, if any.
ErrorCode | The error code. The type of this object value should be Int32 or SQLiteErrorCode.
Message | SQL statement text as the statement first begins executing

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

LogEventArgs Class | System.Data.SQLite Namespace


LogEventArgs Fields

The fields of the LogEventArgs class are listed below. For a complete list of LogEventArgs class members, see the LogEventArgs Members topic.

Public Instance Fields

Data | Extra data associated with this event, if any.
ErrorCode | The error code. The type of this object value should be Int32 or SQLiteErrorCode.
Message | SQL statement text as the statement first begins executing

See Also

LogEventArgs Class | System.Data.SQLite Namespace


LogEventArgs.Data Field

Extra data associated with this event, if any.

public readonly object Data;

See Also

LogEventArgs Class | System.Data.SQLite Namespace


LogEventArgs.ErrorCode Field

The error code. The type of this object value should be Int32 or SQLiteErrorCode.

public readonly object ErrorCode;

See Also

LogEventArgs Class | System.Data.SQLite Namespace


LogEventArgs.Message Field

SQL statement text as the statement first begins executing

public readonly string Message;

See Also

LogEventArgs Class | System.Data.SQLite Namespace


ProgressEventArgs Class

The event data associated with progress reporting events.

For a list of all members of this type, see ProgressEventArgs Members .

System.Object
EventArgs
ProgressEventArgs

public class ProgressEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

ProgressEventArgs Members | System.Data.SQLite Namespace


ProgressEventArgs Members

ProgressEventArgs overview

Public Instance Fields

ReturnCode | The return code for the current call into the progress callback.
UserData | The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

ProgressEventArgs Class | System.Data.SQLite Namespace


ProgressEventArgs Fields

The fields of the ProgressEventArgs class are listed below. For a complete list of ProgressEventArgs class members, see the ProgressEventArgs Members topic.

Public Instance Fields

ReturnCode | The return code for the current call into the progress callback.
UserData | The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

See Also

ProgressEventArgs Class | System.Data.SQLite Namespace


ProgressEventArgs.ReturnCode Field

The return code for the current call into the progress callback.

public SQLiteProgressReturnCode ReturnCode;

See Also

ProgressEventArgs Class | System.Data.SQLite Namespace


ProgressEventArgs.UserData Field

The user-defined native data associated with this event. Currently, this will always contain the value of Zero.

public readonly IntPtr UserData;

See Also

ProgressEventArgs Class | System.Data.SQLite Namespace


SessionConflictCallback Delegate

This callback is invoked when there is a conflict while apply changes to a database.

public delegate SQLiteChangeSetConflictResult SessionConflictCallback(
object clientData,
SQLiteChangeSetConflictType type,
ISQLiteChangeSetMetadataItem item
);

Parameters

clientData
The optional application-defined context data that was originally passed to the Apply method. This value may be null.
type
The type of this conflict.
item
The ISQLiteChangeSetMetadataItem object associated with this conflict. This value may not be null; however, only properties that are applicable to the conflict type will be available. Further information on this is available within the descriptions of the available SQLiteChangeSetConflictType values.

Return Value

A SQLiteChangeSetConflictResult value that indicates the action to be taken in order to resolve the conflict. Throwing an exception from this callback will result in undefined behavior.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SessionTableFilterCallback Delegate

This callback is invoked when a determination must be made about whether changes to a specific table should be tracked -OR- applied. It will not be called for tables that are already attached to a ISQLiteSession.

public delegate bool SessionTableFilterCallback(
object clientData,
string name
);

Parameters

clientData
The optional application-defined context data that was originally passed to the SetTableFilter or Apply methods. This value may be null.
name
The name of the table.

Return Value

Non-zero if changes to the table should be considered; otherwise, zero. Throwing an exception from this callback will result in undefined behavior.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteAuthorizerActionCode Enumeration

The action code responsible for the current call into the authorizer.

public enum SQLiteAuthorizerActionCode

Members

Member Name | Description
None | No action is being performed. This value should not be used from external code.
Copy | No longer used.
CreateIndex | An index will be created. The action-specific arguments are the index name and the table name.
CreateTable | A table will be created. The action-specific arguments are the table name and a null value.
CreateTempIndex | A temporary index will be created. The action-specific arguments are the index name and the table name.
CreateTempTable | A temporary table will be created. The action-specific arguments are the table name and a null value.
CreateTempTrigger | A temporary trigger will be created. The action-specific arguments are the trigger name and the table name.
CreateTempView | A temporary view will be created. The action-specific arguments are the view name and a null value.
CreateTrigger | A trigger will be created. The action-specific arguments are the trigger name and the table name.
CreateView | A view will be created. The action-specific arguments are the view name and a null value.
Delete | A DELETE statement will be executed. The action-specific arguments are the table name and a null value.
DropIndex | An index will be dropped. The action-specific arguments are the index name and the table name.
DropTable | A table will be dropped. The action-specific arguments are the tables name and a null value.
DropTempIndex | A temporary index will be dropped. The action-specific arguments are the index name and the table name.
DropTempTable | A temporary table will be dropped. The action-specific arguments are the table name and a null value.
DropTempTrigger | A temporary trigger will be dropped. The action-specific arguments are the trigger name and the table name.
DropTempView | A temporary view will be dropped. The action-specific arguments are the view name and a null value.
DropTrigger | A trigger will be dropped. The action-specific arguments are the trigger name and the table name.
DropView | A view will be dropped. The action-specific arguments are the view name and a null value.
Insert | An INSERT statement will be executed. The action-specific arguments are the table name and a null value.
Pragma | A PRAGMA statement will be executed. The action-specific arguments are the name of the PRAGMA and the new value or a null value.
Read | A table column will be read. The action-specific arguments are the table name and the column name.
Select | A SELECT statement will be executed. The action-specific arguments are both null values.
Transaction | A transaction will be started, committed, or rolled back. The action-specific arguments are the name of the operation (BEGIN, COMMIT, or ROLLBACK) and a null value.
Update | An UPDATE statement will be executed. The action-specific arguments are the table name and the column name.
Attach | A database will be attached to the connection. The action-specific arguments are the database file name and a null value.
Detach | A database will be detached from the connection. The action-specific arguments are the database name and a null value.
AlterTable | The schema of a table will be altered. The action-specific arguments are the database name and the table name.
Reindex | An index will be deleted and then recreated. The action-specific arguments are the index name and a null value.
Analyze | A table will be analyzed to gathers statistics about it. The action-specific arguments are the table name and a null value.
CreateVtable | A virtual table will be created. The action-specific arguments are the table name and the module name.
DropVtable | A virtual table will be dropped. The action-specific arguments are the table name and the module name.
Function | A SQL function will be called. The action-specific arguments are a null value and the function name.
Savepoint | A savepoint will be created, released, or rolled back. The action-specific arguments are the name of the operation (BEGIN, RELEASE, or ROLLBACK) and the savepoint name.
Recursive | A recursive query will be executed. The action-specific arguments are two null values.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteAuthorizerEventHandler Delegate

Raised when authorization is required to perform an action contained within a SQL query.

public delegate void SQLiteAuthorizerEventHandler(
object sender,
AuthorizerEventArgs e
);

Parameters

sender
The connection performing the action.
e
A AuthorizerEventArgs that contains the event data.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteAuthorizerReturnCode Enumeration

The return code for the current call into the authorizer.

public enum SQLiteAuthorizerReturnCode

Members

Member Name | Description
Ok | The action will be allowed.
Deny | The overall action will be disallowed and an error message will be returned from the query preparation method.
Ignore | The specific action will be disallowed; however, the overall action will continue. The exact effects of this return code vary depending on the specific action, please refer to the SQLite core library documentation for futher details.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteBackupCallback Delegate

Raised between each backup step.

public delegate bool SQLiteBackupCallback(
SQLiteConnection source,
string sourceName,
SQLiteConnection destination,
string destinationName,
int pages,
int remainingPages,
int totalPages,
bool retry
);

Parameters

source
The source database connection.
sourceName
The source database name.
destination
The destination database connection.
destinationName
The destination database name.
pages
The number of pages copied with each step.
remainingPages
The number of pages remaining to be copied.
totalPages
The total number of pages in the source database.
retry
Set to true if the operation needs to be retried due to database locking issues; otherwise, set to false.

Return Value

True to continue with the backup process or false to halt the backup process, rolling back any changes that have been made so far.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteBindValueCallback Delegate

This represents a method that will be called in response to a request to bind a parameter to a command. If an exception is thrown, it will cause the parameter binding operation to fail -AND- it will continue to unwind the call stack.

public delegate void SQLiteBindValueCallback(
SQLiteConvert convert,
SQLiteCommand command,
SQLiteConnectionFlags flags,
SQLiteParameter parameter,
string typeName,
int index,
object userData,
out bool complete
);

Parameters

convert
The SQLiteConvert instance in use.
command
The SQLiteCommand instance in use.
flags
The flags associated with the SQLiteConnection instance in use.
parameter
The SQLiteParameter instance being bound to the command.
typeName
The database type name associated with this callback.
index
The ordinal of the parameter being bound to the command.
userData
The data originally used when registering this callback.
complete
Non-zero if the default handling for the parameter binding call should be skipped (i.e. the parameter should not be bound at all). Great care should be used when setting this to non-zero.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteBlob Class

Represents a single SQL blob in SQLite.

For a list of all members of this type, see SQLiteBlob Members .

System.Object
SQLiteBlob

public sealed class SQLiteBlob : IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteBlob Members | System.Data.SQLite Namespace


SQLiteBlob Members

SQLiteBlob overview

Public Static Methods

Create Overloaded. Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.

Public Instance Methods

Close | Closes the blob, freeing the associated resources.
Dispose | Disposes and finalizes the blob.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetCount | Queries the total number of bytes for the underlying database blob.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Read | Reads data from the underlying database blob.
Reopen | Retargets this object to an underlying database blob for a different row; the database, table, and column remain exactly the same. If this operation fails for any reason, this blob object is automatically disposed.
ToString (inherited from Object) | Returns a String that represents the current Object.
Write | Writes data into the underlying database blob.

Protected Instance Methods

Finalize | The destructor.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob Methods

The methods of the SQLiteBlob class are listed below. For a complete list of SQLiteBlob class members, see the SQLiteBlob Members topic.

Public Static Methods

Create Overloaded. Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.

Public Instance Methods

Close | Closes the blob, freeing the associated resources.
Dispose | Disposes and finalizes the blob.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetCount | Queries the total number of bytes for the underlying database blob.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Read | Reads data from the underlying database blob.
Reopen | Retargets this object to an underlying database blob for a different row; the database, table, and column remain exactly the same. If this operation fails for any reason, this blob object is automatically disposed.
ToString (inherited from Object) | Returns a String that represents the current Object.
Write | Writes data into the underlying database blob.

Protected Instance Methods

Finalize | The destructor.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.Close Method

Closes the blob, freeing the associated resources.

public void Close();

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


Create Method

SQLite ADO.NET Provider

SQLiteBlob.Create Method

Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID.

Overload List

Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID.

public static SQLiteBlob Create(SQLiteConnection,string,string,string,long,bool)

Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.

public static SQLiteBlob Create(SQLiteDataReader,int,bool)

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.Create(SQLiteConnection, String, String, String, Int64, Boolean) Method

Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID.

public static SQLiteBlob Create(
SQLiteConnection connection,
string databaseName,
string tableName,
string columnName,
long rowId,
bool readOnly
);

Parameters

connection
The connection to use when opening the blob object.
databaseName
The name of the database containing the blob object.
tableName
The name of the table containing the blob object.
columnName
The name of the column containing the blob object.
rowId
The integer identifier for the row associated with the desired blob object.
readOnly
Non-zero to open the blob object for read-only access.

Return Value

The newly created SQLiteBlob instance -OR- null if an error occurs.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace | SQLiteBlob.Create Overload List


SQLiteBlob.Create(SQLiteDataReader, Int32, Boolean) Method

Creates a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.

public static SQLiteBlob Create(
SQLiteDataReader dataReader,
int i,
bool readOnly
);

Parameters

dataReader
The SQLiteDataReader instance with a result set containing the desired blob column.
i
The index of the blob column.
readOnly
Non-zero to open the blob object for read-only access.

Return Value

The newly created SQLiteBlob instance -OR- null if an error occurs.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace | SQLiteBlob.Create Overload List


SQLiteBlob.Dispose Method

Disposes and finalizes the blob.

public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.Finalize Method

The destructor.

protected override void Finalize();

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.GetCount Method

Queries the total number of bytes for the underlying database blob.

public int GetCount();

Return Value

The total number of bytes for the underlying database blob.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.Read Method

Reads data from the underlying database blob.

public void Read(
byte[] buffer,
int count,
int offset
);

Parameters

buffer
This array will be populated with the bytes read from the underlying database blob.
count
The number of bytes to read.
offset
The byte offset, relative to the start of the underlying database blob, where the read operation will begin.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.Reopen Method

Retargets this object to an underlying database blob for a different row; the database, table, and column remain exactly the same. If this operation fails for any reason, this blob object is automatically disposed.

public void Reopen(
long rowId
);

Parameters

rowId
The integer identifier for the new row.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBlob.Write Method

Writes data into the underlying database blob.

public void Write(
byte[] buffer,
int count,
int offset
);

Parameters

buffer
This array contains the new values for the specified portion of the underlying database blob.
count
The number of bytes to write.
offset
The byte offset, relative to the start of the underlying database blob, where the write operation will begin.

See Also

SQLiteBlob Class | System.Data.SQLite Namespace


SQLiteBusyEventHandler Delegate

public delegate void SQLiteBusyEventHandler(
object sender,
BusyEventArgs e
);

Parameters

sender
The connection performing the operation.
e
A BusyEventArgs that contains the event data.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteBusyReturnCode Enumeration

The possible return codes for the busy callback.

public enum SQLiteBusyReturnCode

Members

Member Name | Description
Stop | Stop invoking the busy callback and return Busy to the caller.
Retry | Retry the associated operation and invoke the busy callback again, if necessary.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteCallback Delegate

An internal callback delegate declaration.

public delegate void SQLiteCallback(
IntPtr context,
int argc,
IntPtr argv
);

Parameters

context
Raw native context pointer for the user function.
argc
Total number of arguments to the user function.
argv
Raw native pointer to the array of raw native argument pointers.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteChangeSetConflictResult Enumeration

This enumerated type represents the result of a user-defined conflict resolution callback.

public enum SQLiteChangeSetConflictResult

Members

Member Name | Description
Omit | If a conflict callback returns this value no special action is taken. The change that caused the conflict is not applied. The application of changes continues with the next change.
Replace | This value may only be returned from a conflict callback if the type of conflict was Data or Conflict. If this is not the case, any changes applied so far are rolled back and the call to Apply will raise a SQLiteException with an error code of Misuse. If this value is returned for a Data conflict, then the conflicting row is either updated or deleted, depending on the type of change. If this value is returned for a Conflict conflict, then the conflicting row is removed from the database and a second attempt to apply the change is made. If this second attempt fails, the original row is restored to the database before continuing.
Abort | If this value is returned, any changes applied so far are rolled back and the call to Apply will raise a SQLiteException with an error code of Abort.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteChangeSetConflictType Enumeration

This enumerated type represents a type of conflict seen when apply changes from a change set or patch set.

public enum SQLiteChangeSetConflictType

Members

Member Name | Description
Data | This value is seen when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is present in the database, but one or more other (non primary-key) fields modified by the update do not contain the expected "before" values.
NotFound | This value is seen when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is not present in the database. There is no conflicting row in this case. The results of invoking the GetConflictValue method are undefined.
Conflict | This value is seen when processing an INSERT change if the operation would result in duplicate primary key values. The conflicting row in this case is the database row with the matching primary key.
Constraint | If a non-foreign key constraint violation occurs while applying a change (i.e. a UNIQUE, CHECK or NOT NULL constraint), the conflict callback will see this value. There is no conflicting row in this case. The results of invoking the GetConflictValue method are undefined.
ForeignKey | If foreign key handling is enabled, and applying a changes leaves the database in a state containing foreign key violations, this value will be seen exactly once before the changes are committed. If the conflict handler Omit, the changes, including those that caused the foreign key constraint violation, are committed. Or, if it returns Abort, the changes are rolled back. No current or conflicting row information is provided. The only method it is possible to call on the supplied ISQLiteChangeSetMetadataItem object is NumberOfForeignKeyConflicts.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteChangeSetStartFlags Enumeration

This enumerated type represents possible flags that may be passed to the appropriate overloads of various change set creation methods.

public enum SQLiteChangeSetStartFlags

Members

Member Name | Description
None | No special handling.
Invert | Invert the change set while iterating through it. This is equivalent to inverting a change set using Invert before applying it. It is an error to specify this flag with a patch set.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteCommand Class

SQLite implementation of DbCommand.

For a list of all members of this type, see SQLiteCommand Members .

System.Object
MarshalByRefObject
Component
DbCommand
SQLiteCommand

public sealed class SQLiteCommand : DbCommand, ICloneable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteCommand Members | System.Data.SQLite Namespace


SQLiteCommand Members

SQLiteCommand overview

Public Static Fields

ForceExtraReads | This integer value is used with CommandBehavior values. When set, extra Read calls are performed within the ExecuteScalar methods for all transactions. This value should be used with extreme care because it can cause unusual behavior.
GlobalCommandBehaviors | These are the extra command behavior flags that should be used for all calls into the ExecuteNonQuery, ExecuteScalar, and ExecuteReader methods.
SkipExtraReads | This integer value is used with CommandBehavior values. When set, extra Read calls are not performed within the ExecuteScalar methods for write transactions. This value should be used with extreme care because it can cause unusual behavior. It is intended for use only by legacy applications that rely on the old, incorrect behavior.

Public Static Methods

CombineBehaviors |
Execute | Overloaded. This method creates a new connection, executes the query using the given execution type, closes the connection, and returns the results. If the connection string is null, a temporary in-memory database connection will be used.

Public Instance Constructors

SQLiteCommand Overloaded. Constructs a new SQLiteCommand

Public Instance Properties

CommandText | The SQL command text associated with the command
CommandTimeout | The amount of time to wait for the connection to become available before erroring out
CommandType | The type of the command. SQLite only supports CommandType.Text
Connection | Overloaded. The connection associated with this command
Container (inherited from Component) | Gets the IContainer that contains the Component.
DesignTimeVisible | Determines if the command is visible at design time. Defaults to True.
MaximumSleepTime | The maximum amount of time to sleep when retrying a call to prepare or step for the current command.
Parameters | Overloaded. Returns the SQLiteParameterCollection for the given command
Site (inherited from Component) | Gets or sets the ISite of the Component.
Transaction | Overloaded. The transaction associated with this command. SQLite only supports one transaction per connection, so this property forwards to the command's underlying connection.
UpdatedRowSource | Sets the method the SQLiteCommandBuilder uses to determine how to update inserted or updated rows in a DataTable.

Public Instance Methods

Cancel | Not implemented
Clone | Clones a command, including all its parameters
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
CreateParameter | Create a new parameter
Dispose (inherited from Component) | Overloaded. Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
ExecuteNonQuery | Overloaded. Execute the command and return the number of rows inserted/updated affected by it.
ExecuteReader | Overloaded. Overrides the default behavior to return a SQLiteDataReader specialization class
ExecuteScalar | Overloaded. Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.
GetDiagnostics | This method attempts to build and return a string containing diagnostic information for use by the test suite. This method should not be used by application code. It is designed for use by the test suite only and may be modified or removed at any time.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
MaybeReadRemaining | Checks if extra calls to the Read method are necessary. If so, it attempts to perform them. If not, nothing is done.
Prepare | Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards.
Reset | Overloaded. This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
VerifyOnly | Verifies that all SQL queries associated with the current command text can be successfully compiled. A SQLiteException will be raised if any errors occur.

Public Instance Events

Disposed (inherited from Component) Occurs when the component is disposed by a call to the Dispose method.

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DbConnection | Forwards to the local Connection property
DbParameterCollection | Forwards to the local Parameters property
DbTransaction | Forwards to the local Transaction property
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.

Protected Instance Methods

CreateDbParameter | Forwards to the local CreateParameter() function
Dispose | Overloaded. Disposes of the command and clears all member variables
ExecuteDbDataReader | Creates a new SQLiteDataReader to execute/iterate the array of SQLite prepared statements
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand Constructor

Constructs a new SQLiteCommand

Overload List

Default constructor

public SQLiteCommand()

Initializes the command and associates it with the specified connection.

public SQLiteCommand(SQLiteConnection)

Initializes the command with the given command text

public SQLiteCommand(string)

Initializes the command with the given SQL command text and attach the command to the specified connection.

public SQLiteCommand(string,SQLiteConnection)

Initializes a command with the given SQL, connection and transaction

public SQLiteCommand(string,SQLiteConnection,SQLiteTransaction)

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand Constructor

Default constructor

SQLiteCommand();

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand Constructor Overload List


SQLiteCommand Constructor

Initializes the command with the given command text

SQLiteCommand(
string commandText
);

Parameters

commandText
The SQL command text

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand Constructor Overload List


SQLiteCommand Constructor

Initializes the command with the given SQL command text and attach the command to the specified connection.

SQLiteCommand(
string commandText,
SQLiteConnection connection
);

Parameters

commandText
The SQL command text
connection
The connection to associate with the command

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand Constructor Overload List


SQLiteCommand Constructor

Initializes the command and associates it with the specified connection.

SQLiteCommand(
SQLiteConnection connection
);

Parameters

connection
The connection to associate with the command

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand Constructor Overload List


SQLiteCommand Constructor

Initializes a command with the given SQL, connection and transaction

SQLiteCommand(
string commandText,
SQLiteConnection connection,
SQLiteTransaction transaction
);

Parameters

commandText
The SQL command text
connection
The connection to associate with the command
transaction
The transaction the command should be associated with

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand Constructor Overload List


SQLiteCommand Fields

The fields of the SQLiteCommand class are listed below. For a complete list of SQLiteCommand class members, see the SQLiteCommand Members topic.

Public Static Fields

ForceExtraReads | This integer value is used with CommandBehavior values. When set, extra Read calls are performed within the ExecuteScalar methods for all transactions. This value should be used with extreme care because it can cause unusual behavior.
GlobalCommandBehaviors | These are the extra command behavior flags that should be used for all calls into the ExecuteNonQuery, ExecuteScalar, and ExecuteReader methods.
SkipExtraReads | This integer value is used with CommandBehavior values. When set, extra Read calls are not performed within the ExecuteScalar methods for write transactions. This value should be used with extreme care because it can cause unusual behavior. It is intended for use only by legacy applications that rely on the old, incorrect behavior.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.ForceExtraReads Field

This integer value is used with CommandBehavior values. When set, extra Read calls are performed within the ExecuteScalar methods for all transactions. This value should be used with extreme care because it can cause unusual behavior.

public const CommandBehavior ForceExtraReads = CommandBehavior.536870912;

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.GlobalCommandBehaviors Field

These are the extra command behavior flags that should be used for all calls into the ExecuteNonQuery, ExecuteScalar, and ExecuteReader methods.

public static CommandBehavior? GlobalCommandBehaviors;

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.SkipExtraReads Field

This integer value is used with CommandBehavior values. When set, extra Read calls are not performed within the ExecuteScalar methods for write transactions. This value should be used with extreme care because it can cause unusual behavior. It is intended for use only by legacy applications that rely on the old, incorrect behavior.

public const CommandBehavior SkipExtraReads = CommandBehavior.268435456;

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand Properties

The properties of the SQLiteCommand class are listed below. For a complete list of SQLiteCommand class members, see the SQLiteCommand Members topic.

Public Instance Properties

CommandText | The SQL command text associated with the command
CommandTimeout | The amount of time to wait for the connection to become available before erroring out
CommandType | The type of the command. SQLite only supports CommandType.Text
Connection | Overloaded. The connection associated with this command
Container (inherited from Component) | Gets the IContainer that contains the Component.
DesignTimeVisible | Determines if the command is visible at design time. Defaults to True.
MaximumSleepTime | The maximum amount of time to sleep when retrying a call to prepare or step for the current command.
Parameters | Overloaded. Returns the SQLiteParameterCollection for the given command
Site (inherited from Component) | Gets or sets the ISite of the Component.
Transaction | Overloaded. The transaction associated with this command. SQLite only supports one transaction per connection, so this property forwards to the command's underlying connection.
UpdatedRowSource | Sets the method the SQLiteCommandBuilder uses to determine how to update inserted or updated rows in a DataTable.

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DbConnection | Forwards to the local Connection property
DbParameterCollection | Forwards to the local Parameters property
DbTransaction | Forwards to the local Transaction property
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


CommandText Property

SQLite ADO.NET Provider

SQLiteCommand.CommandText Property

The SQL command text associated with the command

public override string CommandText { public get; public set; }

Implements

IDbCommand.CommandText

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


CommandTimeout Property

SQLite ADO.NET Provider

SQLiteCommand.CommandTimeout Property

The amount of time to wait for the connection to become available before erroring out

public override int CommandTimeout { public get; public set; }

Implements

IDbCommand.CommandTimeout

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


CommandType Property

SQLite ADO.NET Provider

SQLiteCommand.CommandType Property

The type of the command. SQLite only supports CommandType.Text

public override CommandType CommandType { public get; public set; }

Implements

IDbCommand.CommandType

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


Connection Property

SQLite ADO.NET Provider

SQLiteCommand.Connection Property

The connection associated with this command

new public SQLiteConnection Connection { public get; public set; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


DbConnection Property

SQLite ADO.NET Provider

SQLiteCommand.DbConnection Property

Forwards to the local Connection property

protected override DbConnection DbConnection { protected get; protected set; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


DbParameterCollection Property

SQLite ADO.NET Provider

SQLiteCommand.DbParameterCollection Property

Forwards to the local Parameters property

protected override DbParameterCollection DbParameterCollection { protected get; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


DbTransaction Property

SQLite ADO.NET Provider

SQLiteCommand.DbTransaction Property

Forwards to the local Transaction property

protected override DbTransaction DbTransaction { protected get; protected set; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


DesignTimeVisible Property

SQLite ADO.NET Provider

SQLiteCommand.DesignTimeVisible Property

Determines if the command is visible at design time. Defaults to True.

public override bool DesignTimeVisible { public get; public set; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


MaximumSleepTime Property

SQLite ADO.NET Provider

SQLiteCommand.MaximumSleepTime Property

The maximum amount of time to sleep when retrying a call to prepare or step for the current command.

public int MaximumSleepTime { public get; public set; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


Parameters Property

SQLite ADO.NET Provider

SQLiteCommand.Parameters Property

Returns the SQLiteParameterCollection for the given command

new public SQLiteParameterCollection Parameters { public get; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


Transaction Property

SQLite ADO.NET Provider

SQLiteCommand.Transaction Property

The transaction associated with this command. SQLite only supports one transaction per connection, so this property forwards to the command's underlying connection.

new public SQLiteTransaction Transaction { public get; public set; }

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


UpdatedRowSource Property

SQLite ADO.NET Provider

SQLiteCommand.UpdatedRowSource Property

Sets the method the SQLiteCommandBuilder uses to determine how to update inserted or updated rows in a DataTable.

public override UpdateRowSource UpdatedRowSource { public get; public set; }

Implements

IDbCommand.UpdatedRowSource

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand Methods

The methods of the SQLiteCommand class are listed below. For a complete list of SQLiteCommand class members, see the SQLiteCommand Members topic.

Public Static Methods

CombineBehaviors |
Execute | Overloaded. This method creates a new connection, executes the query using the given execution type, closes the connection, and returns the results. If the connection string is null, a temporary in-memory database connection will be used.

Public Instance Methods

Cancel | Not implemented
Clone | Clones a command, including all its parameters
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
CreateParameter | Create a new parameter
Dispose (inherited from Component) | Overloaded. Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
ExecuteNonQuery | Overloaded. Execute the command and return the number of rows inserted/updated affected by it.
ExecuteReader | Overloaded. Overrides the default behavior to return a SQLiteDataReader specialization class
ExecuteScalar | Overloaded. Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.
GetDiagnostics | This method attempts to build and return a string containing diagnostic information for use by the test suite. This method should not be used by application code. It is designed for use by the test suite only and may be modified or removed at any time.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
MaybeReadRemaining | Checks if extra calls to the Read method are necessary. If so, it attempts to perform them. If not, nothing is done.
Prepare | Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards.
Reset | Overloaded. This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
VerifyOnly | Verifies that all SQL queries associated with the current command text can be successfully compiled. A SQLiteException will be raised if any errors occur.

Protected Instance Methods

CreateDbParameter | Forwards to the local CreateParameter() function
Dispose | Overloaded. Disposes of the command and clears all member variables
ExecuteDbDataReader | Creates a new SQLiteDataReader to execute/iterate the array of SQLite prepared statements
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.Cancel Method

Not implemented

public override void Cancel();

Implements

IDbCommand.Cancel

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.Clone Method

Clones a command, including all its parameters

public object Clone();

Return Value

A new SQLiteCommand with the same commandtext, connection and parameters

Implements

ICloneable.Clone

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.CombineBehaviors Method

public static CommandBehavior? CombineBehaviors(
CommandBehavior? behavior,
string flags,
out string error
);

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.CreateDbParameter Method

Forwards to the local CreateParameter() function

protected override DbParameter CreateDbParameter();

Return Value

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.CreateParameter Method

Create a new parameter

new public SQLiteParameter CreateParameter();

Return Value

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteCommand.Dispose Method

Disposes of the command and clears all member variables

Overload List

Inherited from Component.

public void Dispose()

Disposes of the command and clears all member variables

protected override void Dispose(bool)

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.Dispose(Boolean) Method

Disposes of the command and clears all member variables

protected override void Dispose(
bool disposing
);

Parameters

disposing
Whether or not the class is being explicitly or implicitly disposed

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.Dispose Overload List


Execute Method

SQLite ADO.NET Provider

SQLiteCommand.Execute Method

This method executes a query using the given execution type and command behavior and returns the results.

Overload List

This method executes a query using the given execution type and command behavior and returns the results.

public static object Execute(string,SQLiteExecuteType,CommandBehavior,SQLiteConnection,params object[])

This method creates a new connection, executes the query using the given execution type and command behavior, closes the connection unless a data reader is created, and returns the results. If the connection string is null, a temporary in-memory database connection will be used.

public static object Execute(string,SQLiteExecuteType,CommandBehavior,string,params object[])

This method creates a new connection, executes the query using the given execution type, closes the connection, and returns the results. If the connection string is null, a temporary in-memory database connection will be used.

public static object Execute(string,SQLiteExecuteType,string,params object[])

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.Execute(String, SQLiteExecuteType, CommandBehavior, SQLiteConnection, Object) Method

This method executes a query using the given execution type and command behavior and returns the results.

public static object Execute(
string commandText,
SQLiteExecuteType executeType,
CommandBehavior commandBehavior,
SQLiteConnection connection,
params object[] args
);

Parameters

commandText
The text of the command to be executed.
executeType
The execution type for the command. This is used to determine which method of the command object to call, which then determines the type of results returned, if any.
commandBehavior
The command behavior flags for the command.
connection
The connection used to create and execute the command.
args
The SQL parameter values to be used when building the command object to be executed, if any.

Return Value

The results of the query -OR- null if no results were produced from the given execution type.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.Execute Overload List


SQLiteCommand.Execute(String, SQLiteExecuteType, CommandBehavior, String, Object) Method

This method creates a new connection, executes the query using the given execution type and command behavior, closes the connection unless a data reader is created, and returns the results. If the connection string is null, a temporary in-memory database connection will be used.

public static object Execute(
string commandText,
SQLiteExecuteType executeType,
CommandBehavior commandBehavior,
string connectionString,
params object[] args
);

Parameters

commandText
The text of the command to be executed.
executeType
The execution type for the command. This is used to determine which method of the command object to call, which then determines the type of results returned, if any.
commandBehavior
The command behavior flags for the command.
connectionString
The connection string to the database to be opened, used, and closed. If this parameter is null, a temporary in-memory database will be used.
args
The SQL parameter values to be used when building the command object to be executed, if any.

Return Value

The results of the query -OR- null if no results were produced from the given execution type.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.Execute Overload List


SQLiteCommand.Execute(String, SQLiteExecuteType, String, Object) Method

This method creates a new connection, executes the query using the given execution type, closes the connection, and returns the results. If the connection string is null, a temporary in-memory database connection will be used.

public static object Execute(
string commandText,
SQLiteExecuteType executeType,
string connectionString,
params object[] args
);

Parameters

commandText
The text of the command to be executed.
executeType
The execution type for the command. This is used to determine which method of the command object to call, which then determines the type of results returned, if any.
connectionString
The connection string to the database to be opened, used, and closed. If this parameter is null, a temporary in-memory database will be used.
args
The SQL parameter values to be used when building the command object to be executed, if any.

Return Value

The results of the query -OR- null if no results were produced from the given execution type.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.Execute Overload List


SQLiteCommand.ExecuteDbDataReader Method

Creates a new SQLiteDataReader to execute/iterate the array of SQLite prepared statements

protected override DbDataReader ExecuteDbDataReader(
CommandBehavior behavior
);

Parameters

behavior
The behavior the data reader should adopt

Return Value

Returns a SQLiteDataReader object

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


ExecuteNonQuery Method

SQLite ADO.NET Provider

SQLiteCommand.ExecuteNonQuery Method

Execute the command and return the number of rows inserted/updated affected by it.

Overload List

Execute the command and return the number of rows inserted/updated affected by it.

public override int ExecuteNonQuery()

Execute the command and return the number of rows inserted/updated affected by it.

public int ExecuteNonQuery(CommandBehavior)

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.ExecuteNonQuery() Method

Execute the command and return the number of rows inserted/updated affected by it.

public override int ExecuteNonQuery();

Return Value

The number of rows inserted/updated affected by it.

Implements

IDbCommand.ExecuteNonQuery

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.ExecuteNonQuery Overload List


SQLiteCommand.ExecuteNonQuery(CommandBehavior) Method

Execute the command and return the number of rows inserted/updated affected by it.

public int ExecuteNonQuery(
CommandBehavior behavior
);

Parameters

behavior
The flags to be associated with the reader.

Return Value

The number of rows inserted/updated affected by it.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.ExecuteNonQuery Overload List


ExecuteReader Method

SQLite ADO.NET Provider

SQLiteCommand.ExecuteReader Method

Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class

Overload List

Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class

new public SQLiteDataReader ExecuteReader()

Overrides the default behavior to return a SQLiteDataReader specialization class

new public SQLiteDataReader ExecuteReader(CommandBehavior)

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.ExecuteReader() Method

Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class

new public SQLiteDataReader ExecuteReader();

Return Value

A SQLiteDataReader

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.ExecuteReader Overload List


SQLiteCommand.ExecuteReader(CommandBehavior) Method

Overrides the default behavior to return a SQLiteDataReader specialization class

new public SQLiteDataReader ExecuteReader(
CommandBehavior behavior
);

Parameters

behavior
The flags to be associated with the reader.

Return Value

A SQLiteDataReader

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.ExecuteReader Overload List


ExecuteScalar Method

SQLite ADO.NET Provider

SQLiteCommand.ExecuteScalar Method

Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.

Overload List

Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.

public override object ExecuteScalar()

Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.

public object ExecuteScalar(CommandBehavior)

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.ExecuteScalar() Method

Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.

public override object ExecuteScalar();

Return Value

The first column of the first row of the first resultset from the query.

Implements

IDbCommand.ExecuteScalar

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.ExecuteScalar Overload List


SQLiteCommand.ExecuteScalar(CommandBehavior) Method

Execute the command and return the first column of the first row of the resultset (if present), or null if no resultset was returned.

public object ExecuteScalar(
CommandBehavior behavior
);

Parameters

behavior
The flags to be associated with the reader.

Return Value

The first column of the first row of the first resultset from the query.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.ExecuteScalar Overload List


SQLiteCommand.GetDiagnostics Method

This method attempts to build and return a string containing diagnostic information for use by the test suite. This method should not be used by application code. It is designed for use by the test suite only and may be modified or removed at any time.

public string GetDiagnostics();

Return Value

A string containing information for use by the test suite -OR- null if that information is not available.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.MaybeReadRemaining Method

Checks if extra calls to the Read method are necessary. If so, it attempts to perform them. If not, nothing is done.

public int MaybeReadRemaining(
SQLiteDataReader reader,
CommandBehavior behavior
);

Parameters

reader
The data reader instance as it was received from one of the ExecuteReader methods.
behavior
The original command behavior flags as passed into one of the query execution methods.

Return Value

The number of extra calls to Read that were performed -OR- negative one to indicate they were not enabled.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.Prepare Method

Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards.

public override void Prepare();

Implements

IDbCommand.Prepare

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


Reset Method

SQLite ADO.NET Provider

SQLiteCommand.Reset Method

This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.

Overload List

This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.

public void Reset()

This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.

public void Reset(bool,bool)

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommand.Reset() Method

This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.

public void Reset();

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.Reset Overload List


SQLiteCommand.Reset(Boolean, Boolean) Method

This method resets all the prepared statements held by this instance back to their initial states, ready to be re-executed.

public void Reset(
bool clearBindings,
bool ignoreErrors
);

Parameters

clearBindings
Non-zero if the parameter bindings should be cleared as well.
ignoreErrors
If this is zero, a SQLiteException may be thrown for any unsuccessful return codes from the native library; otherwise, a SQLiteException will only be thrown if the connection or its state is invalid.

See Also

SQLiteCommand Class | System.Data.SQLite Namespace | SQLiteCommand.Reset Overload List


SQLiteCommand.VerifyOnly Method

Verifies that all SQL queries associated with the current command text can be successfully compiled. A SQLiteException will be raised if any errors occur.

public void VerifyOnly();

See Also

SQLiteCommand Class | System.Data.SQLite Namespace


SQLiteCommandBuilder Class

SQLite implementation of DbCommandBuilder.

For a list of all members of this type, see SQLiteCommandBuilder Members .

System.Object
MarshalByRefObject
Component
DbCommandBuilder
SQLiteCommandBuilder

public sealed class SQLiteCommandBuilder : DbCommandBuilder

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteCommandBuilder Members | System.Data.SQLite Namespace


SQLiteCommandBuilder Members

SQLiteCommandBuilder overview

Public Instance Constructors

SQLiteCommandBuilder Overloaded. Initializes a new instance of the SQLiteCommandBuilder class.

Public Instance Properties

CatalogLocation | Overridden to hide its property from the designer
CatalogSeparator | Overridden to hide its property from the designer
ConflictOption (inherited from DbCommandBuilder) | Specifies which ConflictOption is to be used by the DbCommandBuilder.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DataAdapter | Overloaded. Gets/sets the DataAdapter for this CommandBuilder
QuotePrefix | Overridden to hide its property from the designer
QuoteSuffix | Overridden to hide its property from the designer
SchemaSeparator | Overridden to hide its property from the designer
SetAllValues (inherited from DbCommandBuilder) | Specifies whether all column values in an update statement are included or only changed ones.
Site (inherited from Component) | Gets or sets the ISite of the Component.

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Overloaded. Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetDeleteCommand | Overloaded. Returns the automatically-generated SQLite command to delete rows from the database
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetInsertCommand | Overloaded. Returns the automatically-generated SQLite command to insert rows into the database
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
GetUpdateCommand | Overloaded. Returns the automatically-generated SQLite command to update rows in the database
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
QuoteIdentifier | Places brackets around an identifier
RefreshSchema (inherited from DbCommandBuilder) | Clears the commands associated with this DbCommandBuilder.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
UnquoteIdentifier | Removes brackets around an identifier

Public Instance Events

Disposed (inherited from Component) Occurs when the component is disposed by a call to the Dispose method.

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.

Protected Instance Methods

ApplyParameterInfo | Minimal amount of parameter processing. Primarily sets the DbType for the parameter equal to the provider type in the schema
Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetParameterName | Overloaded. Returns a valid named parameter
GetParameterPlaceholder | Returns a placeholder character for the specified parameter i.
GetSchemaTable | Override helper, which can help the base command builder choose the right keys for the given query
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
InitializeCommand (inherited from DbCommandBuilder) | Resets the CommandTimeout, Transaction, CommandType, and UpdateRowSource properties on the DbCommand.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
RowUpdatingHandler (inherited from DbCommandBuilder) | Adds an event handler for the RowUpdating event.
SetRowUpdatingHandler | Sets the handler for receiving row updating events. Used by the DbCommandBuilder to autogenerate SQL statements that may not have previously been generated.

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder Constructor

Default constructor

Overload List

Default constructor

public SQLiteCommandBuilder()

Initializes the command builder and associates it with the specified data adapter.

public SQLiteCommandBuilder(SQLiteDataAdapter)

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder Constructor

Default constructor

SQLiteCommandBuilder();

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder Constructor Overload List


SQLiteCommandBuilder Constructor

Initializes the command builder and associates it with the specified data adapter.

SQLiteCommandBuilder(
SQLiteDataAdapter adp
);

Parameters

adp

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder Constructor Overload List


SQLiteCommandBuilder Properties

The properties of the SQLiteCommandBuilder class are listed below. For a complete list of SQLiteCommandBuilder class members, see the SQLiteCommandBuilder Members topic.

Public Instance Properties

CatalogLocation | Overridden to hide its property from the designer
CatalogSeparator | Overridden to hide its property from the designer
ConflictOption (inherited from DbCommandBuilder) | Specifies which ConflictOption is to be used by the DbCommandBuilder.
Container (inherited from Component) | Gets the IContainer that contains the Component.
DataAdapter | Overloaded. Gets/sets the DataAdapter for this CommandBuilder
QuotePrefix | Overridden to hide its property from the designer
QuoteSuffix | Overridden to hide its property from the designer
SchemaSeparator | Overridden to hide its property from the designer
SetAllValues (inherited from DbCommandBuilder) | Specifies whether all column values in an update statement are included or only changed ones.
Site (inherited from Component) | Gets or sets the ISite of the Component.

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


CatalogLocation Property

SQLite ADO.NET Provider

SQLiteCommandBuilder.CatalogLocation Property

Overridden to hide its property from the designer

public override CatalogLocation CatalogLocation { public get; public set; }

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


CatalogSeparator Property

SQLite ADO.NET Provider

SQLiteCommandBuilder.CatalogSeparator Property

Overridden to hide its property from the designer

public override string CatalogSeparator { public get; public set; }

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


DataAdapter Property

SQLite ADO.NET Provider

SQLiteCommandBuilder.DataAdapter Property

Gets/sets the DataAdapter for this CommandBuilder

new public SQLiteDataAdapter DataAdapter { public get; public set; }

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


QuotePrefix Property

SQLite ADO.NET Provider

SQLiteCommandBuilder.QuotePrefix Property

Overridden to hide its property from the designer

public override string QuotePrefix { public get; public set; }

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


QuoteSuffix Property

SQLite ADO.NET Provider

SQLiteCommandBuilder.QuoteSuffix Property

Overridden to hide its property from the designer

public override string QuoteSuffix { public get; public set; }

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SchemaSeparator Property

SQLite ADO.NET Provider

SQLiteCommandBuilder.SchemaSeparator Property

Overridden to hide its property from the designer

public override string SchemaSeparator { public get; public set; }

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder Methods

The methods of the SQLiteCommandBuilder class are listed below. For a complete list of SQLiteCommandBuilder class members, see the SQLiteCommandBuilder Members topic.

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Overloaded. Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetDeleteCommand | Overloaded. Returns the automatically-generated SQLite command to delete rows from the database
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetInsertCommand | Overloaded. Returns the automatically-generated SQLite command to insert rows into the database
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
GetUpdateCommand | Overloaded. Returns the automatically-generated SQLite command to update rows in the database
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
QuoteIdentifier | Places brackets around an identifier
RefreshSchema (inherited from DbCommandBuilder) | Clears the commands associated with this DbCommandBuilder.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
UnquoteIdentifier | Removes brackets around an identifier

Protected Instance Methods

ApplyParameterInfo | Minimal amount of parameter processing. Primarily sets the DbType for the parameter equal to the provider type in the schema
Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetParameterName | Overloaded. Returns a valid named parameter
GetParameterPlaceholder | Returns a placeholder character for the specified parameter i.
GetSchemaTable | Override helper, which can help the base command builder choose the right keys for the given query
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
InitializeCommand (inherited from DbCommandBuilder) | Resets the CommandTimeout, Transaction, CommandType, and UpdateRowSource properties on the DbCommand.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
RowUpdatingHandler (inherited from DbCommandBuilder) | Adds an event handler for the RowUpdating event.
SetRowUpdatingHandler | Sets the handler for receiving row updating events. Used by the DbCommandBuilder to autogenerate SQL statements that may not have previously been generated.

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.ApplyParameterInfo Method

Minimal amount of parameter processing. Primarily sets the DbType for the parameter equal to the provider type in the schema

protected override void ApplyParameterInfo(
DbParameter parameter,
DataRow row,
StatementType statementType,
bool whereClause
);

Parameters

parameter
The parameter to use in applying custom behaviors to a row
row
The row to apply the parameter to
statementType
The type of statement
whereClause
Whether the application of the parameter is part of a WHERE clause

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteCommandBuilder.Dispose Method

Cleans up resources (native and managed) associated with the current instance.

Overload List

Inherited from Component.

public void Dispose()

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(bool)

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.Dispose(Boolean) Method

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Zero when being disposed via garbage collection; otherwise, non-zero.

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.Dispose Overload List


GetDeleteCommand Method

SQLite ADO.NET Provider

SQLiteCommandBuilder.GetDeleteCommand Method

Returns the automatically-generated SQLite command to delete rows from the database

Overload List

Returns the automatically-generated SQLite command to delete rows from the database

new public SQLiteCommand GetDeleteCommand()

Returns the automatically-generated SQLite command to delete rows from the database

new public SQLiteCommand GetDeleteCommand(bool)

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.GetDeleteCommand() Method

Returns the automatically-generated SQLite command to delete rows from the database

new public SQLiteCommand GetDeleteCommand();

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetDeleteCommand Overload List


SQLiteCommandBuilder.GetDeleteCommand(Boolean) Method

Returns the automatically-generated SQLite command to delete rows from the database

new public SQLiteCommand GetDeleteCommand(
bool useColumnsForParameterNames
);

Parameters

useColumnsForParameterNames

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetDeleteCommand Overload List


GetInsertCommand Method

SQLite ADO.NET Provider

SQLiteCommandBuilder.GetInsertCommand Method

Returns the automatically-generated SQLite command to insert rows into the database

Overload List

Returns the automatically-generated SQLite command to insert rows into the database

new public SQLiteCommand GetInsertCommand()

Returns the automatically-generated SQLite command to insert rows into the database

new public SQLiteCommand GetInsertCommand(bool)

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.GetInsertCommand() Method

Returns the automatically-generated SQLite command to insert rows into the database

new public SQLiteCommand GetInsertCommand();

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetInsertCommand Overload List


SQLiteCommandBuilder.GetInsertCommand(Boolean) Method

Returns the automatically-generated SQLite command to insert rows into the database

new public SQLiteCommand GetInsertCommand(
bool useColumnsForParameterNames
);

Parameters

useColumnsForParameterNames

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetInsertCommand Overload List


GetParameterName Method

SQLite ADO.NET Provider

SQLiteCommandBuilder.GetParameterName Method

Returns a named parameter for the given ordinal

Overload List

Returns a named parameter for the given ordinal

protected override string GetParameterName(int)

Returns a valid named parameter

protected override string GetParameterName(string)

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.GetParameterName(Int32) Method

Returns a named parameter for the given ordinal

protected override string GetParameterName(
int parameterOrdinal
);

Parameters

parameterOrdinal
The i of the parameter

Return Value

Error

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetParameterName Overload List


SQLiteCommandBuilder.GetParameterName(String) Method

Returns a valid named parameter

protected override string GetParameterName(
string parameterName
);

Parameters

parameterName
The name of the parameter

Return Value

Error

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetParameterName Overload List


SQLiteCommandBuilder.GetParameterPlaceholder Method

Returns a placeholder character for the specified parameter i.

protected override string GetParameterPlaceholder(
int parameterOrdinal
);

Parameters

parameterOrdinal
The index of the parameter to provide a placeholder for

Return Value

Returns a named parameter

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.GetSchemaTable Method

Override helper, which can help the base command builder choose the right keys for the given query

protected override DataTable GetSchemaTable(
DbCommand sourceCommand
);

Parameters

sourceCommand

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


GetUpdateCommand Method

SQLite ADO.NET Provider

SQLiteCommandBuilder.GetUpdateCommand Method

Returns the automatically-generated SQLite command to update rows in the database

Overload List

Returns the automatically-generated SQLite command to update rows in the database

new public SQLiteCommand GetUpdateCommand()

Returns the automatically-generated SQLite command to update rows in the database

new public SQLiteCommand GetUpdateCommand(bool)

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.GetUpdateCommand() Method

Returns the automatically-generated SQLite command to update rows in the database

new public SQLiteCommand GetUpdateCommand();

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetUpdateCommand Overload List


SQLiteCommandBuilder.GetUpdateCommand(Boolean) Method

Returns the automatically-generated SQLite command to update rows in the database

new public SQLiteCommand GetUpdateCommand(
bool useColumnsForParameterNames
);

Parameters

useColumnsForParameterNames

Return Value

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace | SQLiteCommandBuilder.GetUpdateCommand Overload List


SQLiteCommandBuilder.QuoteIdentifier Method

Places brackets around an identifier

public override string QuoteIdentifier(
string unquotedIdentifier
);

Parameters

unquotedIdentifier
The identifier to quote

Return Value

The bracketed identifier

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.SetRowUpdatingHandler Method

Sets the handler for receiving row updating events. Used by the DbCommandBuilder to autogenerate SQL statements that may not have previously been generated.

protected override void SetRowUpdatingHandler(
DbDataAdapter adapter
);

Parameters

adapter
A data adapter to receive events on.

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommandBuilder.UnquoteIdentifier Method

Removes brackets around an identifier

public override string UnquoteIdentifier(
string quotedIdentifier
);

Parameters

quotedIdentifier
The quoted (bracketed) identifier

Return Value

The undecorated identifier

See Also

SQLiteCommandBuilder Class | System.Data.SQLite Namespace


SQLiteCommitHandler Delegate

Raised when a transaction is about to be committed. To roll back a transaction, set the rollbackTrans boolean value to true.

public delegate void SQLiteCommitHandler(
object sender,
CommitEventArgs e
);

Parameters

sender
The connection committing the transaction
e
Event arguments on the transaction

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteCompareDelegate Delegate

This Delegate type is used with the Compare method.

public delegate int SQLiteCompareDelegate(
string param0,
string param1,
string param2
);

Parameters

param0
This is always the string literal "Compare".
param1
The first string to compare.
param2
The second strnig to compare.

Return Value

A positive integer if the param1 parameter is greater than the param2 parameter, a negative integer if the param1 parameter is less than the param2 parameter, or zero if they are equal.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteConfigDbOpsEnum Enumeration

These are the supported configuration verbs for use with the native SQLite library. They are used with the SetConfigurationOption method.

public enum SQLiteConfigDbOpsEnum

Members

Member Name | Description
SQLITE_DBCONFIG_NONE | This value represents an unknown (or invalid) option, do not use it.
SQLITE_DBCONFIG_MAINDBNAME | This option is used to change the name of the "main" database schema. The sole argument is a pointer to a constant UTF8 string which will become the new schema name in place of "main".
SQLITE_DBCONFIG_LOOKASIDE | This option is used to configure the lookaside memory allocator. The value must be an array with three elements. The second element must be an Int32 containing the size of each buffer slot. The third element must be an Int32 containing the number of slots. The first element must be an IntPtr that points to a native memory buffer of bytes equal to or greater than the product of the second and third element values.
SQLITE_DBCONFIG_ENABLE_FKEY | This option is used to enable or disable the enforcement of foreign key constraints.
SQLITE_DBCONFIG_ENABLE_TRIGGER | This option is used to enable or disable triggers.
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER | This option is used to enable or disable the two-argument version of the fts3_tokenizer() function which is part of the FTS3 full-text search engine extension.
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION | This option is used to enable or disable the loading of extensions.
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE | This option is used to enable or disable the automatic checkpointing when a WAL database is closed.
SQLITE_DBCONFIG_ENABLE_QPSG | This option is used to enable or disable the query planner stability guarantee (QPSG).
SQLITE_DBCONFIG_TRIGGER_EQP | This option is used to enable or disable the extra EXPLAIN QUERY PLAN output for trigger programs.
SQLITE_DBCONFIG_RESET_DATABASE | This option is used as part of the process to reset a database back to an empty state. Because resetting a database is destructive and irreversible, the process requires the use of this obscure flag and multiple steps to help ensure that it does not happen by accident.
SQLITE_DBCONFIG_DEFENSIVE | This option activates or deactivates the "defensive" flag for a database connection. When the defensive flag is enabled, language features that allow ordinary SQL to deliberately corrupt the database file are disabled. The disabled features include but are not limited to the following: <ul><li> The PRAGMA writable_schema=ON statement. </li><li> The PRAGMA journal_mode=OFF statement. </li><li> Writes to the sqlite_dbpage virtual table. </li><li> Direct writes to shadow tables. </li></ul>
SQLITE_DBCONFIG_WRITABLE_SCHEMA | This option activates or deactivates the "writable_schema" flag.
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE | This option activates or deactivates the legacy behavior of the ALTER TABLE RENAME command such it behaves as it did prior to version 3.24.0 (2018-06-04).
SQLITE_DBCONFIG_DQS_DML | This option activates or deactivates the legacy double-quoted string literal misfeature for DML statement only, that is DELETE, INSERT, SELECT, and UPDATE statements.
SQLITE_DBCONFIG_DQS_DDL | This option activates or deactivates the legacy double-quoted string literal misfeature for DDL statements, such as CREATE TABLE and CREATE INDEX.
SQLITE_DBCONFIG_ENABLE_VIEW | This option is used to enable or disable CREATE VIEW.
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT | This option activates or deactivates the legacy file format flag.
SQLITE_DBCONFIG_TRUSTED_SCHEMA | This option tells SQLite to assume that database schemas (i.e. the contents of the sqlite_master tables) are untainted by malicious content. When the trusted schema option is disabled, SQLite takes additional defensive steps to protect the application from harm including: <ul><li> Prohibit the use of SQL functions inside triggers, views, CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, or generated columns unless those functions are tagged with SQLITE_INNOCUOUS. </li><li> Prohibit the use of virtual tables inside of triggers or views unless those virtual tables are tagged with SQLITE_VTAB_INNOCUOUS. </ul> This setting defaults to "on" for legacy compatibility, however all applications are advised to turn it off if possible. This setting can also be controlled using the PRAGMA trusted_schema statement.
SQLITE_DBCONFIG_STMT_SCANSTATUS | This option is only useful in SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears a flag that enables collection of the sqlite3_stmt_scanstatus_v2() statistics. For statistics to be collected, the flag must be set on the database handle both when the SQL statement is prepared and when it is stepped. The flag is set (collection of statistics is enabled) by default.
SQLITE_DBCONFIG_REVERSE_SCANORDER | The SQLITE_DBCONFIG_REVERSE_SCANORDER option change the default order in which tables and indexes are scanned so that the scans start at the end and work toward the beginning rather than starting at the beginning and working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the same as setting [PRAGMA reverse_unordered_selects]. This configuration option is useful for application testing.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteConnection Class

SQLite implentation of DbConnection.

For a list of all members of this type, see SQLiteConnection Members .

System.Object
MarshalByRefObject
Component
DbConnection
SQLiteConnection

public sealed class SQLiteConnection : DbConnection, ICloneable

Remarks

The ConnectionString property can contain the following parameter(s), delimited with a semi-colon:

Parameter | Values | Required | Default
Data Source | This may be a file name, the string ":memory:", or any supported URI (starting with SQLite 3.7.7). Starting with release 1.0.86.0, in order to use more than one consecutive backslash (e.g. for a UNC path), each of the adjoining backslash characters must be doubled (e.g. "\\Network\Share\test.db" would become "\\\\Network\Share\test.db"). | Y |
Uri | If specified, this must be a file name that starts with "file://", "file:", or "/". Any leading "file://" or "file:" prefix will be stripped off and the resulting file name will be used to open the database. | N | null
FullUri | If specified, this must be a URI in a format recognized by the SQLite core library (starting with SQLite 3.7.7). It will be passed verbatim to the SQLite core library. | N | null
Version | 3 | N | 3
UseUTF16Encoding | True - The UTF-16 encoding should be used. False - The UTF-8 encoding should be used. | N | False
DefaultDbType | This is the default DbType to use when one cannot be determined based on the column metadata and the configured type mappings. | N | null
DefaultTypeName | This is the default type name to use when one cannot be determined based on the column metadata and the configured type mappings. | N | null
NoDefaultFlags | True - Do not combine the specified (or existing) connection flags with the value of the DefaultFlags property. False - Combine the specified (or existing) connection flags with the value of the DefaultFlags property. | N | False
NoSharedFlags | True - Do not combine the specified (or existing) connection flags with the value of the SharedFlags property. False - Combine the specified (or existing) connection flags with the value of the SharedFlags property. | N | False
VfsName | The name of the VFS to use when opening the database connection. If this is not specified, the default VFS will be used. | N | null
ZipVfsVersion | If non-null, this is the "version" of ZipVFS to use. This requires the System.Data.SQLite interop assembly -AND- primary managed assembly to be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this property does nothing. The valid values are "v2" and "v3". Using anyother value will cause an exception to be thrown. Please see the ZipVFS documentation for more information on how to use this parameter. | N | null
DateTimeFormat | Ticks - Use the value of DateTime.Ticks. ISO8601 - Use the ISO-8601 format. Uses the "yyyy-MM-dd HH:mm:ss.FFFFFFFK" format for UTC DateTime values and "yyyy-MM-dd HH:mm:ss.FFFFFFF" format for local DateTime values). JulianDay - The interval of time in days and fractions of a day since January 1, 4713 BC. UnixEpoch - The whole number of seconds since the Unix epoch (January 1, 1970). InvariantCulture - Any culture-independent string value that the .NET Framework can interpret as a valid DateTime. CurrentCulture - Any string value that the .NET Framework can interpret as a valid DateTime using the current culture. | N | ISO8601
DateTimeKind | Unspecified - Not specified as either UTC or local time. Utc - The time represented is UTC. Local - The time represented is local time. | N | Unspecified
DateTimeFormatString | The exact DateTime format string to use for all formatting and parsing of all DateTime values for this connection. | N | null
BaseSchemaName | Some base data classes in the framework (e.g. those that build SQL queries dynamically) assume that an ADO.NET provider cannot support an alternate catalog (i.e. database) without supporting alternate schemas as well; however, SQLite does not fit into this model. Therefore, this value is used as a placeholder and removed prior to preparing any SQL statements that may contain it. | N | sqlite_default_schema
BinaryGUID | True - Store GUID columns in binary form False - Store GUID columns as text | N | True
Cache Size | If the argument N is positive then the suggested cache size is set to N. If the argument N is negative, then the number of cache pages is adjusted to use approximately abs(N*4096) bytes of memory. Backwards compatibility note: The behavior of cache_size with a negative N was different in SQLite versions prior to 3.7.10. In version 3.7.9 and earlier, the number of pages in the cache was set to the absolute value of N. | N | -2000
Synchronous | Normal - Normal file flushing behavior Full - Full flushing after all writes Off - Underlying OS flushes I/O's | N | Full
Page Size | {size in bytes} | N | 4096
Password | {password} - Using this parameter requires that the legacy CryptoAPI based codec (or the SQLite Encryption Extension) be enabled at compile-time for both the native interop assembly and the core managed assemblies; otherwise, using this parameter may result in an exception being thrown when attempting to open the connection. | N |
HexPassword | {hexPassword} - Must contain a sequence of zero or more hexadecimal encoded byte values without a leading "0x" prefix. Using this parameter requires that the legacy CryptoAPI based codec (or the SQLite Encryption Extension) be enabled at compile-time for both the native interop assembly and the core managed assemblies; otherwise, using this parameter may result in an exception being thrown when attempting to open the connection. | N |
TextPassword | {password} - Using this parameter requires that the legacy CryptoAPI based codec (or the SQLite Encryption Extension) be enabled at compile-time for both the native interop assembly and the core managed assemblies; otherwise, using this parameter may result in an exception being thrown when attempting to open the connection. | N |
TextHexPassword | {hexPassword} - Must contain a sequence of zero or more hexadecimal encoded byte values without a leading "0x" prefix. Using this parameter requires that the legacy CryptoAPI based codec (or the SQLite Encryption Extension) be enabled at compile-time for both the native interop assembly and the core managed assemblies; otherwise, using this parameter may result in an exception being thrown when attempting to open the connection. | N |
Enlist | Y - Automatically enlist in distributed transactions N - No automatic enlistment | N | Y
Pooling | True - Use connection pooling. False - Do not use connection pooling. WARNING: When using the default connection pool implementation, setting this property to True should be avoided by applications that make use of COM (either directly or indirectly) due to possible deadlocks that can occur during the finalization of some COM objects. | N | False
FailIfMissing | True - Don't create the database if it does not exist, throw an error instead False - Automatically create the database if it does not exist | N | False
Max Page Count | {size in pages} - Limits the maximum number of pages (limits the size) of the database | N | 0
Legacy Format | True - Use the more compatible legacy 3.x database format False - Use the newer 3.3x database format which compresses numbers more effectively | N | False
Default Timeout | {time in seconds} The default command timeout | N | 30
DefaultMaximumSleepTime | {time in milliseconds} The default maximum sleep time for new commands | N | 150
BusyTimeout | {time in milliseconds} Sets the busy timeout for the core library. | N | 0
WaitTimeout | {time in milliseconds} EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set. | N | 30000
Journal Mode | Delete - Delete the journal file after a commit. Persist - Zero out and leave the journal file on disk after a commit. Off - Disable the rollback journal entirely. This saves disk I/O but at the expense of database safety and integrity. If the application using SQLite crashes in the middle of a transaction when this journaling mode is set, then the database file will very likely go corrupt. Truncate - Truncate the journal file to zero-length instead of deleting it. Memory - Store the journal in volatile RAM. This saves disk I/O but at the expense of database safety and integrity. If the application using SQLite crashes in the middle of a transaction when this journaling mode is set, then the database file will very likely go corrupt. Wal - Use a write-ahead log instead of a rollback journal. | N | Delete
Read Only | True - Open the database for read only access False - Open the database for normal read/write access | N | False
Max Pool Size | The maximum number of connections for the given connection string that can be in the connection pool | N | 100
Default IsolationLevel | The default transaciton isolation level | N | Serializable
Foreign Keys | Enable foreign key constraints | N | False
Flags | Extra behavioral flags for the connection. See the SQLiteConnectionFlags enumeration for possible values. | N | Default
SetDefaults | True - Apply the default connection settings to the opened database. False - Skip applying the default connection settings to the opened database. | N | True
ToFullPath | True - Attempt to expand the data source file name to a fully qualified path before opening. False - Skip attempting to expand the data source file name to a fully qualified path before opening. | N | True
PrepareRetries | The maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed. | N | 3
ProgressOps | The approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well. | N | 0
Recursive Triggers | True - Enable the recursive trigger capability. False - Disable the recursive trigger capability. | N | False

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteConnection Members | System.Data.SQLite Namespace


SQLiteConnection Members

SQLiteConnection overview

Public Static Properties

CloseCount | Returns the total number of Close method calls for all connections.
ConnectionPool | This property is used to obtain or set the custom connection pool implementation to use, if any. Setting this property to null will cause the default connection pool implementation to be used.
CreateCount | Returns the total number of created connections.
DefaultFlags | The default connection flags to be used for all opened connections when they are not present in the connection string.
DefineConstants | Returns a string containing the define constants (i.e. compile-time options) used to compile the core managed assembly, delimited with spaces.
DisposeCount | Returns the total number of disposed connections.
InteropCompileOptions | Returns a string containing the compile-time options used to compile the SQLite interop assembly, delimited with spaces.
InteropSourceId | This method returns the string whose value contains the unique identifier for the source checkout used to build the interop assembly. If the SQLite interop assembly is not in use or the necessary information cannot be obtained for any reason, a null value may be returned.
InteropVersion | This method returns the version of the interop SQLite assembly used. If the SQLite interop assembly is not in use or the necessary information cannot be obtained for any reason, a null value may be returned.
OpenCount | Returns the total number of Open method calls for all connections.
ProviderSourceId | This method returns the string whose value contains the unique identifier for the source checkout used to build the managed components currently executing. If the necessary information cannot be obtained for any reason, a null value may be returned.
ProviderVersion | This method returns the version of the managed components used to interact with the SQLite core library. If the necessary information cannot be obtained for any reason, a null value may be returned.
SharedFlags | The extra connection flags to be used for all opened connections.
SQLiteCompileOptions | Returns a string containing the compile-time options used to compile the SQLite core native library, delimited with spaces.
SQLiteSourceId | This method returns the string whose value is the same as the SQLITE_SOURCE_ID C preprocessor macro used when compiling the SQLite core library.
SQLiteVersion | Returns the version of the underlying SQLite core library.

Public Static Methods

ClearAllPools | Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed.
ClearPool | Clears the connection pool associated with the connection. Any other active connections using the same database file will be discarded instead of returned to the pool when they are closed.
CreateFile | Creates a database file. This just creates a zero-byte file which SQLite will turn into a database when the file is opened properly.
CreateHandle | Creates and returns a new managed database connection handle. This method is intended to be used by implementations of the ISQLiteConnectionPool interface only. In theory, it could be used by other classes; however, that usage is not supported.
CreatePool | Attempts to create and return the specified built-in implementation of the ISQLiteConnectionPool interface. If there is no such built-in implementation, NotImplementedException will be thrown.
GetMemoryStatistics | Returns various global memory statistics for the SQLite core library via a dictionary of key/value pairs. Currently, only the "MemoryUsed" and "MemoryHighwater" keys are returned and they have values that correspond to the values that could be obtained via the MemoryUsed and MemoryHighwater connection properties.
ParseConnectionString | Parses a connection string into component parts using the custom connection string parser. An exception may be thrown if the syntax of the connection string is incorrect.
ReleaseMemory | Overloaded. Attempts to free N bytes of heap memory by deallocating non-essential memory allocations held by the database library. Memory used to cache database pages to improve performance is an example of non-essential memory. This is a no-op returning zero if the SQLite core library was not compiled with the compile-time option SQLITE_ENABLE_MEMORY_MANAGEMENT. Optionally, attempts to reset and/or compact the Win32 native heap, if applicable.
SetMemoryStatus | Sets the status of the memory usage tracking subsystem in the SQLite core library. By default, this is enabled. If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is global to the process.
Shutdown | Overloaded. Passes a shutdown request to the SQLite core library. Throws an exception if the shutdown request fails and the no-throw parameter is non-zero.

Public Static Events

Changed This event is raised when events related to the lifecycle of a SQLiteConnection object occur.

Public Instance Constructors

SQLiteConnection Overloaded. Constructs a new SQLiteConnection object

Public Instance Properties

AutoCommit | Returns non-zero if the given database connection is in autocommit mode. Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
BusyTimeout | Gets/sets the default busy timeout to use with the SQLite core library. This is only used when opening a connection.
Changes | Returns the number of rows changed by the last INSERT, UPDATE, or DELETE statement executed on this connection.
ConnectionString | The connection string containing the parameters for the connection
ConnectionTimeout (inherited from DbConnection) | Gets the time to wait while establishing a connection before terminating the attempt and generating an error.
Container (inherited from Component) | Gets the IContainer that contains the Component.
Database | Returns the string "main".
DataSource | Returns the data source file name without extension or path.
DefaultDbType | Gets/sets the default database type for this connection. This value will only be used when not null.
DefaultMaximumSleepTime | Gets/sets the default maximum sleep time for newly-created commands. This can also be set in the ConnectionString with "DefaultMaximumSleepTime"
DefaultTimeout | Gets/sets the default command timeout for newly-created commands. This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible. This can also be set in the ConnectionString with "Default Timeout"
DefaultTypeName | Gets/sets the default database type name for this connection. This value will only be used when not null.
FileName | Returns the fully qualified path and file name for the currently open database, if any.
Flags | Gets/sets the extra behavioral flags for this connection. See the SQLiteConnectionFlags enumeration for a list of possible values.
LastInsertRowId | Returns the rowid of the most recent successful INSERT into the database from this connection.
MemoryHighwater | Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
MemoryUsed | Returns the amount of memory (in bytes) currently in use by the SQLite core library.
OwnHandle | Returns non-zero if the underlying native connection handle is owned by this instance.
ParseViaFramework | Non-zero if the built-in (i.e. framework provided) connection string parser should be used when opening the connection.
PoolCount | Returns the number of pool entries for the file name associated with this connection.
PrepareRetries | The maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed.
ProgressOps | The approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well. This value will only be used when the underlying native progress callback needs to be changed.
ServerVersion | Returns the version of the underlying SQLite database engine
Site (inherited from Component) | Gets or sets the ISite of the Component.
State | Returns the state of the connection.
StepRetries | The maximum number of retries when stepping SQL to be executed. This normally only applies to stepping errors resulting from the database being locked.
TraceFlags | This property is used to configure the set of events that may be raised from the Trace2 event. The value of this property cannot be changed while an event handler is registered.
VfsName | Gets/sets the VFS name for this connection. This value will only be used when opening the database.
WaitTimeout | EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set.

Public Instance Methods

AddTypeMapping | Adds a per-connection type mapping, possibly replacing one or more that already exist.
BackupDatabase | Backs up the database, using the specified database connection as the destination.
BeginTransaction | Overloaded. OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.
BindFunction | Overloaded. Attempts to bind the specified SQLiteFunction object instance to this connection.
Cancel | This method causes any pending database operation to abort and return at its earliest opportunity. This routine is typically called in response to a user action such as pressing "Cancel" or Ctrl-C where the user wants a long query operation to halt immediately. It is safe to call this routine from any thread. However, it is not safe to call this routine with a database connection that is closed or might close before this method returns.
ChangeDatabase | This method is not implemented; however, the Changed event will still be raised.
ChangePassword Overloaded.
WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.
ClearCachedSettings | Clears the per-connection cached settings.
ClearTypeCallbacks | Clears the per-connection type callbacks.
ClearTypeMappings | Clears the per-connection type mappings.
Clone | Creates a clone of the connection. All attached databases and user-defined functions are cloned. If the existing connection is open, the cloned connection will also be opened.
Close | When the database connection is closed, all commands linked to this connection are automatically reset.
CreateChangeGroup | Attempts to create a new ISQLiteChangeGroup object instance using this connection.
CreateChangeSet | Overloaded. Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified stream.
CreateCommand | Create a new SQLiteCommand and associate it with this connection.
CreateModule | Creates a disposable module containing the implementation of a virtual table.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
CreateSession | Attempts to create a new ISQLiteSession object instance using this connection and the specified database name.
Dispose | Overloaded. Disposes and finalizes the connection, if applicable.
EnableExtensions | Enables or disables extension loading.
EnlistTransaction | Manual distributed transaction enlistment support
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
ExtendedResultCode | Enables or disables extended result codes returned by SQLite
GetCriticalHandle Attempts to obtain and return the underlying CriticalHandle derived object associated with this connection. This method should only be used by the thread that created this connection; otherwise, the results are undefined.
WARNING: This method is not officially supported for external callers and
         should be considered "experimental", even though it is "public".
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetSchema Overloaded. The following commands are used to extract schema information out of the database. Valid schema types are:
  • MetaDataCollections
  • DataSourceInformation
  • Catalogs
  • Columns
  • ForeignKeys
  • Indexes
  • IndexColumns
  • Tables
  • Views
  • ViewColumns
GetType (inherited from Object) | Gets the Type of the current instance.
GetTypeMappings | Returns the per-connection type mappings.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
IsCanceled | This method checks if the database operation for this connection has been interrupted.
IsReadOnly | Checks if this connection to the specified database should be considered read-only. An exception will be thrown if the database name specified via name cannot be found.
LoadExtension | Overloaded. Loads a SQLite extension library from the named dynamic link library file.
LogMessage | Overloaded. Add a log message via the SQLite sqlite3_log interface.
Open | Opens the connection using the parameters found in the ConnectionString.
OpenAndReturn | Opens the connection using the parameters found in the ConnectionString and then returns it.
ReleaseMemory | Overloaded. Attempts to free as much heap memory as possible for this database connection.
ResultCode | Enables or disables extended result codes returned by SQLite
SetAvRetry | Queries or modifies the number of retries or the retry interval (in milliseconds) for certain I/O operations that may fail due to anti-virus software.
SetChunkSize | Sets the chunk size for the primary file associated with this database connection.
SetConfigurationOption | Change a configuration option value for the database.
SetExtendedResultCodes | Enables or disables extended result codes returned by SQLite
SetLimitOption | Change a limit value for the database.
SetPassword Overloaded.
WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.
SetTypeCallbacks | Sets, resets, or clears the per-connection type callbacks for the specified database type name.
Shutdown | Overloaded. Passes a shutdown request to the SQLite core library. Does not throw an exception if the shutdown request fails.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
TryGetTypeCallbacks | Attempts to get the per-connection type callbacks for the specified database type name.
UnbindAllFunctions | This method unbinds all registered (known) functions -OR- all previously bound user-defined functions from this connection.
UnbindFunction | Attempts to unbind the specified SQLiteFunction object instance to this connection.
WaitForEnlistmentReset | EXPERIMENTAL -- Waits for the enlistment associated with this connection to be reset. This method always throws NotImplementedException when running on the .NET Compact Framework.

Public Instance Events

Authorize | This event is raised whenever SQLite encounters an action covered by the authorizer during query preparation. Changing the value of the ReturnCode property will determine if the specific action will be allowed, ignored, or denied. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.
Busy | This event is raised periodically during long running queries. Changing the value of the ReturnCode property will determine if the database operation will be retried or stopped. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.
Commit | This event is raised whenever SQLite is committing a transaction. Return non-zero to trigger a rollback.
Disposed (inherited from Component) | Occurs when the component is disposed by a call to the Dispose method.
Progress | This event is raised periodically during long running queries. Changing the value of the ReturnCode property will determine if the operation in progress will continue or be interrupted. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.
RollBack | This event is raised whenever SQLite is rolling back a transaction.
StateChange | This event is raised whenever the database is opened or closed.
Trace | This event is raised whenever SQLite statement first begins executing on this connection. It only applies to the given connection.
Trace2 | This event is raised when events matching the configured mask are raised for this connection.
Update | This event is raised whenever SQLite makes an update/delete/insert into the database on this connection. It only applies to the given connection.

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DbProviderFactory | Returns the SQLiteFactory instance.
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.

Protected Instance Methods

BeginDbTransaction | Forwards to the local BeginTransaction function
CreateDbCommand | Forwards to the local CreateCommand function.
Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
OnStateChange (inherited from DbConnection) | Raises the StateChange event.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection Constructor

Constructs a new SQLiteConnection object

Overload List

Default constructor

public SQLiteConnection()

Clones the settings and connection string from an existing connection. If the existing connection is already open, this function will open its own connection, enumerate any attached databases of the original connection, and automatically attach to them.

public SQLiteConnection(SQLiteConnection)

Initializes the connection with the specified connection string.

public SQLiteConnection(string)

Initializes the connection with the specified connection string.

public SQLiteConnection(string,bool)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection Constructor

Default constructor

SQLiteConnection();

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection Constructor Overload List


SQLiteConnection Constructor

Initializes the connection with the specified connection string.

SQLiteConnection(
string connectionString
);

Parameters

connectionString
The connection string to use.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection Constructor Overload List


SQLiteConnection Constructor

Initializes the connection with the specified connection string.

SQLiteConnection(
string connectionString,
bool parseViaFramework
);

Parameters

connectionString
The connection string to use.
parseViaFramework
Non-zero to parse the connection string using the built-in (i.e. framework provided) parser when opening the connection.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection Constructor Overload List


SQLiteConnection Constructor

Clones the settings and connection string from an existing connection. If the existing connection is already open, this function will open its own connection, enumerate any attached databases of the original connection, and automatically attach to them.

SQLiteConnection(
SQLiteConnection connection
);

Parameters

connection
The connection to copy the settings from.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection Constructor Overload List


SQLiteConnection Properties

The properties of the SQLiteConnection class are listed below. For a complete list of SQLiteConnection class members, see the SQLiteConnection Members topic.

Public Static Properties

CloseCount | Returns the total number of Close method calls for all connections.
ConnectionPool | This property is used to obtain or set the custom connection pool implementation to use, if any. Setting this property to null will cause the default connection pool implementation to be used.
CreateCount | Returns the total number of created connections.
DefaultFlags | The default connection flags to be used for all opened connections when they are not present in the connection string.
DefineConstants | Returns a string containing the define constants (i.e. compile-time options) used to compile the core managed assembly, delimited with spaces.
DisposeCount | Returns the total number of disposed connections.
InteropCompileOptions | Returns a string containing the compile-time options used to compile the SQLite interop assembly, delimited with spaces.
InteropSourceId | This method returns the string whose value contains the unique identifier for the source checkout used to build the interop assembly. If the SQLite interop assembly is not in use or the necessary information cannot be obtained for any reason, a null value may be returned.
InteropVersion | This method returns the version of the interop SQLite assembly used. If the SQLite interop assembly is not in use or the necessary information cannot be obtained for any reason, a null value may be returned.
OpenCount | Returns the total number of Open method calls for all connections.
ProviderSourceId | This method returns the string whose value contains the unique identifier for the source checkout used to build the managed components currently executing. If the necessary information cannot be obtained for any reason, a null value may be returned.
ProviderVersion | This method returns the version of the managed components used to interact with the SQLite core library. If the necessary information cannot be obtained for any reason, a null value may be returned.
SharedFlags | The extra connection flags to be used for all opened connections.
SQLiteCompileOptions | Returns a string containing the compile-time options used to compile the SQLite core native library, delimited with spaces.
SQLiteSourceId | This method returns the string whose value is the same as the SQLITE_SOURCE_ID C preprocessor macro used when compiling the SQLite core library.
SQLiteVersion | Returns the version of the underlying SQLite core library.

Public Instance Properties

AutoCommit | Returns non-zero if the given database connection is in autocommit mode. Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
BusyTimeout | Gets/sets the default busy timeout to use with the SQLite core library. This is only used when opening a connection.
Changes | Returns the number of rows changed by the last INSERT, UPDATE, or DELETE statement executed on this connection.
ConnectionString | The connection string containing the parameters for the connection
ConnectionTimeout (inherited from DbConnection) | Gets the time to wait while establishing a connection before terminating the attempt and generating an error.
Container (inherited from Component) | Gets the IContainer that contains the Component.
Database | Returns the string "main".
DataSource | Returns the data source file name without extension or path.
DefaultDbType | Gets/sets the default database type for this connection. This value will only be used when not null.
DefaultMaximumSleepTime | Gets/sets the default maximum sleep time for newly-created commands. This can also be set in the ConnectionString with "DefaultMaximumSleepTime"
DefaultTimeout | Gets/sets the default command timeout for newly-created commands. This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible. This can also be set in the ConnectionString with "Default Timeout"
DefaultTypeName | Gets/sets the default database type name for this connection. This value will only be used when not null.
FileName | Returns the fully qualified path and file name for the currently open database, if any.
Flags | Gets/sets the extra behavioral flags for this connection. See the SQLiteConnectionFlags enumeration for a list of possible values.
LastInsertRowId | Returns the rowid of the most recent successful INSERT into the database from this connection.
MemoryHighwater | Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.
MemoryUsed | Returns the amount of memory (in bytes) currently in use by the SQLite core library.
OwnHandle | Returns non-zero if the underlying native connection handle is owned by this instance.
ParseViaFramework | Non-zero if the built-in (i.e. framework provided) connection string parser should be used when opening the connection.
PoolCount | Returns the number of pool entries for the file name associated with this connection.
PrepareRetries | The maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed.
ProgressOps | The approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well. This value will only be used when the underlying native progress callback needs to be changed.
ServerVersion | Returns the version of the underlying SQLite database engine
Site (inherited from Component) | Gets or sets the ISite of the Component.
State | Returns the state of the connection.
StepRetries | The maximum number of retries when stepping SQL to be executed. This normally only applies to stepping errors resulting from the database being locked.
TraceFlags | This property is used to configure the set of events that may be raised from the Trace2 event. The value of this property cannot be changed while an event handler is registered.
VfsName | Gets/sets the VFS name for this connection. This value will only be used when opening the database.
WaitTimeout | EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set.

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DbProviderFactory | Returns the SQLiteFactory instance.
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


AutoCommit Property

SQLite ADO.NET Provider

SQLiteConnection.AutoCommit Property

Returns non-zero if the given database connection is in autocommit mode. Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.

public bool AutoCommit { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


BusyTimeout Property

SQLite ADO.NET Provider

SQLiteConnection.BusyTimeout Property

Gets/sets the default busy timeout to use with the SQLite core library. This is only used when opening a connection.

public int BusyTimeout { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


Changes Property

SQLite ADO.NET Provider

SQLiteConnection.Changes Property

Returns the number of rows changed by the last INSERT, UPDATE, or DELETE statement executed on this connection.

public int Changes { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


CloseCount Property

SQLite ADO.NET Provider

SQLiteConnection.CloseCount Property

Returns the total number of Close method calls for all connections.

public static long CloseCount { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ConnectionPool Property

SQLite ADO.NET Provider

SQLiteConnection.ConnectionPool Property

This property is used to obtain or set the custom connection pool implementation to use, if any. Setting this property to null will cause the default connection pool implementation to be used.

public static ISQLiteConnectionPool ConnectionPool { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ConnectionString Property

SQLite ADO.NET Provider

SQLiteConnection.ConnectionString Property

The connection string containing the parameters for the connection

public override string ConnectionString { public get; public set; }

Implements

IDbConnection.ConnectionString

Remarks

For the complete list of supported connection string properties, please see SQLiteConnection.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


CreateCount Property

SQLite ADO.NET Provider

SQLiteConnection.CreateCount Property

Returns the total number of created connections.

public static long CreateCount { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


Database Property

SQLite ADO.NET Provider

SQLiteConnection.Database Property

Returns the string "main".

public override string Database { public get; }

Implements

IDbConnection.Database

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DataSource Property

SQLite ADO.NET Provider

SQLiteConnection.DataSource Property

Returns the data source file name without extension or path.

public override string DataSource { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DbProviderFactory Property

SQLite ADO.NET Provider

SQLiteConnection.DbProviderFactory Property

Returns the SQLiteFactory instance.

protected override DbProviderFactory DbProviderFactory { protected get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DefaultDbType Property

SQLite ADO.NET Provider

SQLiteConnection.DefaultDbType Property

Gets/sets the default database type for this connection. This value will only be used when not null.

public DbType? DefaultDbType { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DefaultFlags Property

SQLite ADO.NET Provider

SQLiteConnection.DefaultFlags Property

The default connection flags to be used for all opened connections when they are not present in the connection string.

public static SQLiteConnectionFlags DefaultFlags { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DefaultMaximumSleepTime Property

SQLite ADO.NET Provider

SQLiteConnection.DefaultMaximumSleepTime Property

Gets/sets the default maximum sleep time for newly-created commands. This can also be set in the ConnectionString with "DefaultMaximumSleepTime"

public int DefaultMaximumSleepTime { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DefaultTimeout Property

SQLite ADO.NET Provider

SQLiteConnection.DefaultTimeout Property

Gets/sets the default command timeout for newly-created commands. This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible. This can also be set in the ConnectionString with "Default Timeout"

public int DefaultTimeout { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DefaultTypeName Property

SQLite ADO.NET Provider

SQLiteConnection.DefaultTypeName Property

Gets/sets the default database type name for this connection. This value will only be used when not null.

public string DefaultTypeName { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DefineConstants Property

SQLite ADO.NET Provider

SQLiteConnection.DefineConstants Property

Returns a string containing the define constants (i.e. compile-time options) used to compile the core managed assembly, delimited with spaces.

public static string DefineConstants { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


DisposeCount Property

SQLite ADO.NET Provider

SQLiteConnection.DisposeCount Property

Returns the total number of disposed connections.

public static long DisposeCount { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


FileName Property

SQLite ADO.NET Provider

SQLiteConnection.FileName Property

Returns the fully qualified path and file name for the currently open database, if any.

public string FileName { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


Flags Property

SQLite ADO.NET Provider

SQLiteConnection.Flags Property

Gets/sets the extra behavioral flags for this connection. See the SQLiteConnectionFlags enumeration for a list of possible values.

public SQLiteConnectionFlags Flags { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


InteropCompileOptions Property

SQLite ADO.NET Provider

SQLiteConnection.InteropCompileOptions Property

Returns a string containing the compile-time options used to compile the SQLite interop assembly, delimited with spaces.

public static string InteropCompileOptions { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


InteropSourceId Property

SQLite ADO.NET Provider

SQLiteConnection.InteropSourceId Property

This method returns the string whose value contains the unique identifier for the source checkout used to build the interop assembly. If the SQLite interop assembly is not in use or the necessary information cannot be obtained for any reason, a null value may be returned.

public static string InteropSourceId { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


InteropVersion Property

SQLite ADO.NET Provider

SQLiteConnection.InteropVersion Property

This method returns the version of the interop SQLite assembly used. If the SQLite interop assembly is not in use or the necessary information cannot be obtained for any reason, a null value may be returned.

public static string InteropVersion { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


LastInsertRowId Property

SQLite ADO.NET Provider

SQLiteConnection.LastInsertRowId Property

Returns the rowid of the most recent successful INSERT into the database from this connection.

public long LastInsertRowId { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


MemoryHighwater Property

SQLite ADO.NET Provider

SQLiteConnection.MemoryHighwater Property

Returns the maximum amount of memory (in bytes) used by the SQLite core library since the high-water mark was last reset.

public long MemoryHighwater { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


MemoryUsed Property

SQLite ADO.NET Provider

SQLiteConnection.MemoryUsed Property

Returns the amount of memory (in bytes) currently in use by the SQLite core library.

public long MemoryUsed { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


OpenCount Property

SQLite ADO.NET Provider

SQLiteConnection.OpenCount Property

Returns the total number of Open method calls for all connections.

public static long OpenCount { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


OwnHandle Property

SQLite ADO.NET Provider

SQLiteConnection.OwnHandle Property

Returns non-zero if the underlying native connection handle is owned by this instance.

public bool OwnHandle { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ParseViaFramework Property

SQLite ADO.NET Provider

SQLiteConnection.ParseViaFramework Property

Non-zero if the built-in (i.e. framework provided) connection string parser should be used when opening the connection.

public bool ParseViaFramework { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


PoolCount Property

SQLite ADO.NET Provider

SQLiteConnection.PoolCount Property

Returns the number of pool entries for the file name associated with this connection.

public int PoolCount { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


PrepareRetries Property

SQLite ADO.NET Provider

SQLiteConnection.PrepareRetries Property

The maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed.

public int PrepareRetries { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ProgressOps Property

SQLite ADO.NET Provider

SQLiteConnection.ProgressOps Property

The approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well. This value will only be used when the underlying native progress callback needs to be changed.

public int ProgressOps { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ProviderSourceId Property

SQLite ADO.NET Provider

SQLiteConnection.ProviderSourceId Property

This method returns the string whose value contains the unique identifier for the source checkout used to build the managed components currently executing. If the necessary information cannot be obtained for any reason, a null value may be returned.

public static string ProviderSourceId { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ProviderVersion Property

SQLite ADO.NET Provider

SQLiteConnection.ProviderVersion Property

This method returns the version of the managed components used to interact with the SQLite core library. If the necessary information cannot be obtained for any reason, a null value may be returned.

public static string ProviderVersion { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ServerVersion Property

SQLite ADO.NET Provider

SQLiteConnection.ServerVersion Property

Returns the version of the underlying SQLite database engine

public override string ServerVersion { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SharedFlags Property

SQLite ADO.NET Provider

SQLiteConnection.SharedFlags Property

The extra connection flags to be used for all opened connections.

public static SQLiteConnectionFlags SharedFlags { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteCompileOptions Property

SQLite ADO.NET Provider

SQLiteConnection.SQLiteCompileOptions Property

Returns a string containing the compile-time options used to compile the SQLite core native library, delimited with spaces.

public static string SQLiteCompileOptions { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteSourceId Property

SQLite ADO.NET Provider

SQLiteConnection.SQLiteSourceId Property

This method returns the string whose value is the same as the SQLITE_SOURCE_ID C preprocessor macro used when compiling the SQLite core library.

public static string SQLiteSourceId { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteVersion Property

SQLite ADO.NET Provider

SQLiteConnection.SQLiteVersion Property

Returns the version of the underlying SQLite core library.

public static string SQLiteVersion { public get; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


State Property

SQLite ADO.NET Provider

SQLiteConnection.State Property

Returns the state of the connection.

public override ConnectionState State { public get; }

Implements

IDbConnection.State

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


StepRetries Property

SQLite ADO.NET Provider

SQLiteConnection.StepRetries Property

The maximum number of retries when stepping SQL to be executed. This normally only applies to stepping errors resulting from the database being locked.

public int StepRetries { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


TraceFlags Property

SQLite ADO.NET Provider

SQLiteConnection.TraceFlags Property

This property is used to configure the set of events that may be raised from the Trace2 event. The value of this property cannot be changed while an event handler is registered.

public SQLiteTraceFlags TraceFlags { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


VfsName Property

SQLite ADO.NET Provider

SQLiteConnection.VfsName Property

Gets/sets the VFS name for this connection. This value will only be used when opening the database.

public string VfsName { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


WaitTimeout Property

SQLite ADO.NET Provider

SQLiteConnection.WaitTimeout Property

EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set.

public int WaitTimeout { public get; public set; }

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection Methods

The methods of the SQLiteConnection class are listed below. For a complete list of SQLiteConnection class members, see the SQLiteConnection Members topic.

Public Static Methods

ClearAllPools | Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed.
ClearPool | Clears the connection pool associated with the connection. Any other active connections using the same database file will be discarded instead of returned to the pool when they are closed.
CreateFile | Creates a database file. This just creates a zero-byte file which SQLite will turn into a database when the file is opened properly.
CreateHandle | Creates and returns a new managed database connection handle. This method is intended to be used by implementations of the ISQLiteConnectionPool interface only. In theory, it could be used by other classes; however, that usage is not supported.
CreatePool | Attempts to create and return the specified built-in implementation of the ISQLiteConnectionPool interface. If there is no such built-in implementation, NotImplementedException will be thrown.
GetMemoryStatistics | Returns various global memory statistics for the SQLite core library via a dictionary of key/value pairs. Currently, only the "MemoryUsed" and "MemoryHighwater" keys are returned and they have values that correspond to the values that could be obtained via the MemoryUsed and MemoryHighwater connection properties.
ParseConnectionString | Parses a connection string into component parts using the custom connection string parser. An exception may be thrown if the syntax of the connection string is incorrect.
ReleaseMemory | Overloaded. Attempts to free N bytes of heap memory by deallocating non-essential memory allocations held by the database library. Memory used to cache database pages to improve performance is an example of non-essential memory. This is a no-op returning zero if the SQLite core library was not compiled with the compile-time option SQLITE_ENABLE_MEMORY_MANAGEMENT. Optionally, attempts to reset and/or compact the Win32 native heap, if applicable.
SetMemoryStatus | Sets the status of the memory usage tracking subsystem in the SQLite core library. By default, this is enabled. If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is global to the process.
Shutdown | Overloaded. Passes a shutdown request to the SQLite core library. Throws an exception if the shutdown request fails and the no-throw parameter is non-zero.

Public Instance Methods

AddTypeMapping | Adds a per-connection type mapping, possibly replacing one or more that already exist.
BackupDatabase | Backs up the database, using the specified database connection as the destination.
BeginTransaction | Overloaded. OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.
BindFunction | Overloaded. Attempts to bind the specified SQLiteFunction object instance to this connection.
Cancel | This method causes any pending database operation to abort and return at its earliest opportunity. This routine is typically called in response to a user action such as pressing "Cancel" or Ctrl-C where the user wants a long query operation to halt immediately. It is safe to call this routine from any thread. However, it is not safe to call this routine with a database connection that is closed or might close before this method returns.
ChangeDatabase | This method is not implemented; however, the Changed event will still be raised.
ChangePassword Overloaded.
WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.
ClearCachedSettings | Clears the per-connection cached settings.
ClearTypeCallbacks | Clears the per-connection type callbacks.
ClearTypeMappings | Clears the per-connection type mappings.
Clone | Creates a clone of the connection. All attached databases and user-defined functions are cloned. If the existing connection is open, the cloned connection will also be opened.
Close | When the database connection is closed, all commands linked to this connection are automatically reset.
CreateChangeGroup | Attempts to create a new ISQLiteChangeGroup object instance using this connection.
CreateChangeSet | Overloaded. Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified stream.
CreateCommand | Create a new SQLiteCommand and associate it with this connection.
CreateModule | Creates a disposable module containing the implementation of a virtual table.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
CreateSession | Attempts to create a new ISQLiteSession object instance using this connection and the specified database name.
Dispose | Overloaded. Disposes and finalizes the connection, if applicable.
EnableExtensions | Enables or disables extension loading.
EnlistTransaction | Manual distributed transaction enlistment support
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
ExtendedResultCode | Enables or disables extended result codes returned by SQLite
GetCriticalHandle Attempts to obtain and return the underlying CriticalHandle derived object associated with this connection. This method should only be used by the thread that created this connection; otherwise, the results are undefined.
WARNING: This method is not officially supported for external callers and
         should be considered "experimental", even though it is "public".
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetSchema Overloaded. The following commands are used to extract schema information out of the database. Valid schema types are:
  • MetaDataCollections
  • DataSourceInformation
  • Catalogs
  • Columns
  • ForeignKeys
  • Indexes
  • IndexColumns
  • Tables
  • Views
  • ViewColumns
GetType (inherited from Object) | Gets the Type of the current instance.
GetTypeMappings | Returns the per-connection type mappings.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
IsCanceled | This method checks if the database operation for this connection has been interrupted.
IsReadOnly | Checks if this connection to the specified database should be considered read-only. An exception will be thrown if the database name specified via name cannot be found.
LoadExtension | Overloaded. Loads a SQLite extension library from the named dynamic link library file.
LogMessage | Overloaded. Add a log message via the SQLite sqlite3_log interface.
Open | Opens the connection using the parameters found in the ConnectionString.
OpenAndReturn | Opens the connection using the parameters found in the ConnectionString and then returns it.
ReleaseMemory | Overloaded. Attempts to free as much heap memory as possible for this database connection.
ResultCode | Enables or disables extended result codes returned by SQLite
SetAvRetry | Queries or modifies the number of retries or the retry interval (in milliseconds) for certain I/O operations that may fail due to anti-virus software.
SetChunkSize | Sets the chunk size for the primary file associated with this database connection.
SetConfigurationOption | Change a configuration option value for the database.
SetExtendedResultCodes | Enables or disables extended result codes returned by SQLite
SetLimitOption | Change a limit value for the database.
SetPassword Overloaded.
WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.
SetTypeCallbacks | Sets, resets, or clears the per-connection type callbacks for the specified database type name.
Shutdown | Overloaded. Passes a shutdown request to the SQLite core library. Does not throw an exception if the shutdown request fails.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
TryGetTypeCallbacks | Attempts to get the per-connection type callbacks for the specified database type name.
UnbindAllFunctions | This method unbinds all registered (known) functions -OR- all previously bound user-defined functions from this connection.
UnbindFunction | Attempts to unbind the specified SQLiteFunction object instance to this connection.
WaitForEnlistmentReset | EXPERIMENTAL -- Waits for the enlistment associated with this connection to be reset. This method always throws NotImplementedException when running on the .NET Compact Framework.

Protected Instance Methods

BeginDbTransaction | Forwards to the local BeginTransaction function
CreateDbCommand | Forwards to the local CreateCommand function.
Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
OnStateChange (inherited from DbConnection) | Raises the StateChange event.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.AddTypeMapping Method

Adds a per-connection type mapping, possibly replacing one or more that already exist.

public int AddTypeMapping(
string typeName,
DbType dataType,
bool primary
);

Parameters

typeName
The case-insensitive database type name (e.g. "MYDATE"). The value of this parameter cannot be null. Using an empty string value (or a string value consisting entirely of whitespace) for this parameter is not recommended.
dataType
The DbType value that should be associated with the specified type name.
primary
Non-zero if this mapping should be considered to be the primary one for the specified DbType.

Return Value

A negative value if nothing was done. Zero if no per-connection type mappings were replaced (i.e. it was a pure add operation). More than zero if some per-connection type mappings were replaced.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.BackupDatabase Method

Backs up the database, using the specified database connection as the destination.

public void BackupDatabase(
SQLiteConnection destination,
string destinationName,
string sourceName,
int pages,
SQLiteBackupCallback callback,
int retryMilliseconds
);

Parameters

destination
The destination database connection.
destinationName
The destination database name.
sourceName
The source database name.
pages
The number of pages to copy at a time -OR- a negative value to copy all pages. When a negative value is used, the callback may never be invoked.
callback
The method to invoke between each step of the backup process. This parameter may be null (i.e. no callbacks will be performed). If the callback returns false -OR- throws an exception, the backup is canceled.
retryMilliseconds
The number of milliseconds to sleep after encountering a locking error during the backup process. A value less than zero means that no sleep should be performed.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.BeginDbTransaction Method

Forwards to the local BeginTransaction function

protected override DbTransaction BeginDbTransaction(
IsolationLevel isolationLevel
);

Parameters

isolationLevel
Supported isolation levels are Unspecified, Serializable, and ReadCommitted

Return Value

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


BeginTransaction Method

SQLite ADO.NET Provider

SQLiteConnection.BeginTransaction Method

Creates a new SQLiteTransaction if one isn't already active on the connection.

Overload List

Creates a new SQLiteTransaction if one isn't already active on the connection.

new public SQLiteTransaction BeginTransaction()

Obsolete. OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.

public SQLiteTransaction BeginTransaction(bool)

Creates a new SQLiteTransaction if one isn't already active on the connection.

new public SQLiteTransaction BeginTransaction(IsolationLevel)

Obsolete. OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.

public SQLiteTransaction BeginTransaction(IsolationLevel,bool)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.BeginTransaction() Method

Creates a new SQLiteTransaction if one isn't already active on the connection.

new public SQLiteTransaction BeginTransaction();

Return Value

Returns the new transaction object.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.BeginTransaction Overload List


SQLiteConnection.BeginTransaction(Boolean) Method

NOTE: This method is now obsolete.

Use one of the standard BeginTransaction methods, this one will be removed soon

OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.

public SQLiteTransaction BeginTransaction(
bool deferredLock
);

Parameters

deferredLock
When TRUE, SQLite defers obtaining a write lock until a write operation is requested. When FALSE, a writelock is obtained immediately. The default is false, but in a multi-threaded multi-writer environment, one may instead choose to lock the database immediately to avoid any possible writer deadlock.

Return Value

Returns a SQLiteTransaction object.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.BeginTransaction Overload List


SQLiteConnection.BeginTransaction(IsolationLevel) Method

Creates a new SQLiteTransaction if one isn't already active on the connection.

new public SQLiteTransaction BeginTransaction(
IsolationLevel isolationLevel
);

Parameters

isolationLevel
Supported isolation levels are Serializable, ReadCommitted and Unspecified.

Return Value

Returns a SQLiteTransaction object.

Remarks

Unspecified will use the default isolation level specified in the connection string. If no isolation level is specified in the connection string, Serializable is used. Serializable transactions are the default. In this mode, the engine gets an immediate lock on the database, and no other threads may begin a transaction. Other threads may read from the database, but not write. With a ReadCommitted isolation level, locks are deferred and elevated as needed. It is possible for multiple threads to start a transaction in ReadCommitted mode, but if a thread attempts to commit a transaction while another thread has a ReadCommitted lock, it may timeout or cause a deadlock on both threads until both threads' CommandTimeout's are reached.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.BeginTransaction Overload List


SQLiteConnection.BeginTransaction(IsolationLevel, Boolean) Method

NOTE: This method is now obsolete.

Use one of the standard BeginTransaction methods, this one will be removed soon

OBSOLETE. Creates a new SQLiteTransaction if one isn't already active on the connection.

public SQLiteTransaction BeginTransaction(
IsolationLevel isolationLevel,
bool deferredLock
);

Parameters

isolationLevel
This parameter is ignored.
deferredLock
When TRUE, SQLite defers obtaining a write lock until a write operation is requested. When FALSE, a writelock is obtained immediately. The default is TRUE, but in a multi-threaded multi-writer environment, one may instead choose to lock the database immediately to avoid any possible writer deadlock.

Return Value

Returns a SQLiteTransaction object.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.BeginTransaction Overload List


BindFunction Method

SQLite ADO.NET Provider

SQLiteConnection.BindFunction Method

Attempts to bind the specified SQLiteFunction object instance to this connection.

Overload List

Attempts to bind the specified SQLiteFunction object instance to this connection.

public void BindFunction(SQLiteFunctionAttribute,SQLiteFunction)

Attempts to bind the specified SQLiteFunction object instance to this connection.

public void BindFunction(SQLiteFunctionAttribute,Delegate,Delegate)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.BindFunction(SQLiteFunctionAttribute, SQLiteFunction) Method

Attempts to bind the specified SQLiteFunction object instance to this connection.

public void BindFunction(
SQLiteFunctionAttribute functionAttribute,
SQLiteFunction function
);

Parameters

functionAttribute
The SQLiteFunctionAttribute object instance containing the metadata for the function to be bound.
function
The SQLiteFunction object instance that implements the function to be bound.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.BindFunction Overload List


SQLiteConnection.BindFunction(SQLiteFunctionAttribute, Delegate, Delegate) Method

Attempts to bind the specified SQLiteFunction object instance to this connection.

public void BindFunction(
SQLiteFunctionAttribute functionAttribute,
Delegate callback1,
Delegate callback2
);

Parameters

functionAttribute
The SQLiteFunctionAttribute object instance containing the metadata for the function to be bound.
callback1
A Delegate object instance that helps implement the function to be bound. For scalar functions, this corresponds to the SQLiteInvokeDelegate type. For aggregate functions, this corresponds to the SQLiteStepDelegate type. For collation functions, this corresponds to the SQLiteCompareDelegate type.
callback2
A Delegate object instance that helps implement the function to be bound. For aggregate functions, this corresponds to the SQLiteFinalDelegate type. For other callback types, it is not used and must be null.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.BindFunction Overload List


SQLiteConnection.Cancel Method

This method causes any pending database operation to abort and return at its earliest opportunity. This routine is typically called in response to a user action such as pressing "Cancel" or Ctrl-C where the user wants a long query operation to halt immediately. It is safe to call this routine from any thread. However, it is not safe to call this routine with a database connection that is closed or might close before this method returns.

public void Cancel();

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ChangeDatabase Method

This method is not implemented; however, the Changed event will still be raised.

public override void ChangeDatabase(
string databaseName
);

Parameters

databaseName

Implements

IDbConnection.ChangeDatabase

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ChangePassword Method

SQLite ADO.NET Provider

SQLiteConnection.ChangePassword Method

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.

Overload List

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.

public void ChangePassword(byte[])

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.

public void ChangePassword(string)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ChangePassword(Byte) Method

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.

public void ChangePassword(
byte[] newPassword
);

Parameters

newPassword
The new password to assign to the open database.

Remarks

No readers or writers may be active for this process. The database must already be open and if it already was password protected, the existing password must already have been supplied.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.ChangePassword Overload List


SQLiteConnection.ChangePassword(String) Method

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Change the password (or assign a password) to the open database.

public void ChangePassword(
string newPassword
);

Parameters

newPassword
The new password to assign to the open database.

Remarks

No readers or writers may be active for this process. The database must already be open and if it already was password protected, the existing password must already have been supplied.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.ChangePassword Overload List


SQLiteConnection.ClearAllPools Method

Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed.

public static void ClearAllPools();

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ClearCachedSettings Method

Clears the per-connection cached settings.

public int ClearCachedSettings();

Return Value

The total number of per-connection settings cleared.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ClearPool Method

Clears the connection pool associated with the connection. Any other active connections using the same database file will be discarded instead of returned to the pool when they are closed.

public static void ClearPool(
SQLiteConnection connection
);

Parameters

connection

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ClearTypeCallbacks Method

Clears the per-connection type callbacks.

public int ClearTypeCallbacks();

Return Value

The total number of per-connection type callbacks cleared.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ClearTypeMappings Method

Clears the per-connection type mappings.

public int ClearTypeMappings();

Return Value

The total number of per-connection type mappings cleared.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Clone Method

Creates a clone of the connection. All attached databases and user-defined functions are cloned. If the existing connection is open, the cloned connection will also be opened.

public object Clone();

Return Value

Implements

ICloneable.Clone

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Close Method

When the database connection is closed, all commands linked to this connection are automatically reset.

public override void Close();

Implements

IDbConnection.Close

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateChangeGroup Method

Attempts to create a new ISQLiteChangeGroup object instance using this connection.

public ISQLiteChangeGroup CreateChangeGroup();

Return Value

The newly created change group -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


CreateChangeSet Method

SQLite ADO.NET Provider

SQLiteConnection.CreateChangeSet Method

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified raw data.

Overload List

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified raw data.

public ISQLiteChangeSet CreateChangeSet(byte[])

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified raw data.

public ISQLiteChangeSet CreateChangeSet(byte[],SQLiteChangeSetStartFlags)

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified stream.

public ISQLiteChangeSet CreateChangeSet(Stream,Stream)

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified stream.

public ISQLiteChangeSet CreateChangeSet(Stream,Stream,SQLiteChangeSetStartFlags)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateChangeSet(Byte) Method

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified raw data.

public ISQLiteChangeSet CreateChangeSet(
byte[] rawData
);

Parameters

rawData
The raw data that contains a change set (or patch set).

Return Value

The newly created change set -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.CreateChangeSet Overload List


SQLiteConnection.CreateChangeSet(Byte, SQLiteChangeSetStartFlags) Method

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified raw data.

public ISQLiteChangeSet CreateChangeSet(
byte[] rawData,
SQLiteChangeSetStartFlags flags
);

Parameters

rawData
The raw data that contains a change set (or patch set).
flags
The flags used to create the change set iterator.

Return Value

The newly created change set -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.CreateChangeSet Overload List


SQLiteConnection.CreateChangeSet(Stream, Stream) Method

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified stream.

public ISQLiteChangeSet CreateChangeSet(
Stream inputStream,
Stream outputStream
);

Parameters

inputStream
The stream where the raw data that contains a change set (or patch set) may be read.
outputStream
The stream where the raw data that contains a change set (or patch set) may be written.

Return Value

The newly created change set -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.CreateChangeSet Overload List


SQLiteConnection.CreateChangeSet(Stream, Stream, SQLiteChangeSetStartFlags) Method

Attempts to create a new ISQLiteChangeSet object instance using this connection and the specified stream.

public ISQLiteChangeSet CreateChangeSet(
Stream inputStream,
Stream outputStream,
SQLiteChangeSetStartFlags flags
);

Parameters

inputStream
The stream where the raw data that contains a change set (or patch set) may be read.
outputStream
The stream where the raw data that contains a change set (or patch set) may be written.
flags
The flags used to create the change set iterator.

Return Value

The newly created change set -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.CreateChangeSet Overload List


SQLiteConnection.CreateCommand Method

Create a new SQLiteCommand and associate it with this connection.

new public SQLiteCommand CreateCommand();

Return Value

Returns a new command object already assigned to this connection.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateDbCommand Method

Forwards to the local CreateCommand function.

protected override DbCommand CreateDbCommand();

Return Value

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateFile Method

Creates a database file. This just creates a zero-byte file which SQLite will turn into a database when the file is opened properly.

public static void CreateFile(
string databaseFileName
);

Parameters

databaseFileName
The file to create

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateHandle Method

Creates and returns a new managed database connection handle. This method is intended to be used by implementations of the ISQLiteConnectionPool interface only. In theory, it could be used by other classes; however, that usage is not supported.

public static object CreateHandle(
IntPtr nativeHandle
);

Parameters

nativeHandle
This must be a native database connection handle returned by the SQLite core library and it must remain valid and open during the entire duration of the calling method.

Return Value

The new managed database connection handle or null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateModule Method

Creates a disposable module containing the implementation of a virtual table.

public void CreateModule(
SQLiteModule module
);

Parameters

module
The module object to be used when creating the disposable module.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreatePool Method

Attempts to create and return the specified built-in implementation of the ISQLiteConnectionPool interface. If there is no such built-in implementation, NotImplementedException will be thrown.

public static ISQLiteConnectionPool CreatePool(
string typeName,
object argument
);

Parameters

typeName
The short name of the ISQLiteConnectionPool interface implementation to create.
argument
The single argument to pass into the constructor of the ISQLiteConnectionPool interface implementation to create, if any.

Return Value

The built-in implementation of the ISQLiteConnectionPool interface -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.CreateSession Method

Attempts to create a new ISQLiteSession object instance using this connection and the specified database name.

public ISQLiteSession CreateSession(
string databaseName
);

Parameters

databaseName
The name of the database for the newly created session.

Return Value

The newly created session -OR- null if it cannot be created.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteConnection.Dispose Method

Disposes and finalizes the connection, if applicable.

Overload List

Disposes and finalizes the connection, if applicable.

new public void Dispose()

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(bool)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Dispose() Method

Disposes and finalizes the connection, if applicable.

new public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.Dispose Overload List


SQLiteConnection.Dispose(Boolean) Method

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Zero when being disposed via garbage collection; otherwise, non-zero.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.Dispose Overload List


SQLiteConnection.EnableExtensions Method

Enables or disables extension loading.

public void EnableExtensions(
bool enable
);

Parameters

enable
True to enable loading of extensions, false to disable.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.EnlistTransaction Method

Manual distributed transaction enlistment support

public override void EnlistTransaction(
Transaction transaction
);

Parameters

transaction
The distributed transaction to enlist in

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ExtendedResultCode Method

Enables or disables extended result codes returned by SQLite

public SQLiteErrorCode ExtendedResultCode();

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.GetCriticalHandle Method

Attempts to obtain and return the underlying CriticalHandle derived object associated with this connection. This method should only be used by the thread that created this connection; otherwise, the results are undefined.

WARNING: This method is not officially supported for external callers and
         should be considered "experimental", even though it is "public".

public object GetCriticalHandle();

Return Value

The underlying CriticalHandle derived object associated with this connection -OR- null if it is unavailable.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.GetMemoryStatistics Method

Returns various global memory statistics for the SQLite core library via a dictionary of key/value pairs. Currently, only the "MemoryUsed" and "MemoryHighwater" keys are returned and they have values that correspond to the values that could be obtained via the MemoryUsed and MemoryHighwater connection properties.

public static void GetMemoryStatistics(
ref IDictionary<string, long> statistics
);

Parameters

statistics
This dictionary will be populated with the global memory statistics. It will be created if necessary.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


GetSchema Method

SQLite ADO.NET Provider

SQLiteConnection.GetSchema Method

The following commands are used to extract schema information out of the database. Valid schema types are:

  • MetaDataCollections
  • DataSourceInformation
  • Catalogs
  • Columns
  • ForeignKeys
  • Indexes
  • IndexColumns
  • Tables
  • Views
  • ViewColumns

Overload List

Returns the MetaDataCollections schema

public override DataTable GetSchema()

Returns schema information of the specified collection

public override DataTable GetSchema(string)

Retrieves schema information using the specified constraint(s) for the specified collection

public override DataTable GetSchema(string,string[])

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.GetSchema() Method

Returns the MetaDataCollections schema

public override DataTable GetSchema();

Return Value

A DataTable of the MetaDataCollections schema

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.GetSchema Overload List


SQLiteConnection.GetSchema(String) Method

Returns schema information of the specified collection

public override DataTable GetSchema(
string collectionName
);

Parameters

collectionName
The schema collection to retrieve

Return Value

A DataTable of the specified collection

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.GetSchema Overload List


SQLiteConnection.GetSchema(String, String) Method

Retrieves schema information using the specified constraint(s) for the specified collection

public override DataTable GetSchema(
string collectionName,
string[] restrictionValues
);

Parameters

collectionName
The collection to retrieve.
restrictionValues
The restrictions to impose. Typically, this may include:
restrictionValues element index | usage
0 | The database (or catalog) name, if applicable.
1 | The schema name. This is not used by this provider.
2 | The table name, if applicable.
3 | Depends on collectionName. When "IndexColumns", it is the index name; otherwise, it is the column name.
4 | Depends on collectionName. When "IndexColumns", it is the column name; otherwise, it is not used.

Return Value

A DataTable of the specified collection

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.GetSchema Overload List


SQLiteConnection.GetTypeMappings Method

Returns the per-connection type mappings.

public Dictionary<string, object> GetTypeMappings();

Return Value

The per-connection type mappings -OR- null if they are unavailable.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.IsCanceled Method

This method checks if the database operation for this connection has been interrupted.

public bool IsCanceled();

Return Value

Non-zero if the database operation for this connection has been interrupted; otherwise, zero.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.IsReadOnly Method

Checks if this connection to the specified database should be considered read-only. An exception will be thrown if the database name specified via name cannot be found.

public bool IsReadOnly(
string name
);

Parameters

name
The name of a database associated with this connection -OR- null for the main database.

Return Value

Non-zero if this connection to the specified database should be considered read-only.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


LoadExtension Method

SQLite ADO.NET Provider

SQLiteConnection.LoadExtension Method

Loads a SQLite extension library from the named dynamic link library file.

Overload List

Loads a SQLite extension library from the named dynamic link library file.

public void LoadExtension(string)

Loads a SQLite extension library from the named dynamic link library file.

public void LoadExtension(string,string)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.LoadExtension(String) Method

Loads a SQLite extension library from the named dynamic link library file.

public void LoadExtension(
string fileName
);

Parameters

fileName
The name of the dynamic link library file containing the extension.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.LoadExtension Overload List


SQLiteConnection.LoadExtension(String, String) Method

Loads a SQLite extension library from the named dynamic link library file.

public void LoadExtension(
string fileName,
string procName
);

Parameters

fileName
The name of the dynamic link library file containing the extension.
procName
The name of the exported function used to initialize the extension. If null, the default "sqlite3_extension_init" will be used.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.LoadExtension Overload List


LogMessage Method

SQLite ADO.NET Provider

SQLiteConnection.LogMessage Method

Add a log message via the SQLite sqlite3_log interface.

Overload List

Add a log message via the SQLite sqlite3_log interface.

public void LogMessage(SQLiteErrorCode,string)

Add a log message via the SQLite sqlite3_log interface.

public void LogMessage(int,string)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.LogMessage(SQLiteErrorCode, String) Method

Add a log message via the SQLite sqlite3_log interface.

public void LogMessage(
SQLiteErrorCode iErrCode,
string zMessage
);

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.LogMessage Overload List


SQLiteConnection.LogMessage(Int32, String) Method

Add a log message via the SQLite sqlite3_log interface.

public void LogMessage(
int iErrCode,
string zMessage
);

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.LogMessage Overload List


SQLiteConnection.Open Method

Opens the connection using the parameters found in the ConnectionString.

public override void Open();

Implements

IDbConnection.Open

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.OpenAndReturn Method

Opens the connection using the parameters found in the ConnectionString and then returns it.

public SQLiteConnection OpenAndReturn();

Return Value

The current connection object.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ParseConnectionString Method

Parses a connection string into component parts using the custom connection string parser. An exception may be thrown if the syntax of the connection string is incorrect.

public static SortedList<string, string> ParseConnectionString(
SQLiteConnection connection,
string connectionString,
bool parseViaFramework,
bool allowNameOnly,
bool strict
);

Parameters

connection
The connection that will be using the parsed connection string.
connectionString
The connection string to parse.
parseViaFramework
Non-zero to parse the connection string using the algorithm provided by the framework itself. This is not applicable when running on the .NET Compact Framework.
allowNameOnly
Non-zero if names are allowed without values.
strict
Non-zero to throw an exception if any connection string values are not of the String type. This is not applicable when running on the .NET Compact Framework.

Return Value

The list of key/value pairs corresponding to the parameters specified within the connection string.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


ReleaseMemory Method

SQLite ADO.NET Provider

SQLiteConnection.ReleaseMemory Method

Attempts to free as much heap memory as possible for this database connection.

Overload List

Attempts to free as much heap memory as possible for this database connection.

public void ReleaseMemory()

Attempts to free N bytes of heap memory by deallocating non-essential memory allocations held by the database library. Memory used to cache database pages to improve performance is an example of non-essential memory. This is a no-op returning zero if the SQLite core library was not compiled with the compile-time option SQLITE_ENABLE_MEMORY_MANAGEMENT. Optionally, attempts to reset and/or compact the Win32 native heap, if applicable.

public static SQLiteErrorCode ReleaseMemory(int,bool,bool,ref int,ref bool,ref uint)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.ReleaseMemory() Method

Attempts to free as much heap memory as possible for this database connection.

public void ReleaseMemory();

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.ReleaseMemory Overload List


SQLiteConnection.ReleaseMemory(Int32, Boolean, Boolean, Int32, Boolean, UInt32) Method

Attempts to free N bytes of heap memory by deallocating non-essential memory allocations held by the database library. Memory used to cache database pages to improve performance is an example of non-essential memory. This is a no-op returning zero if the SQLite core library was not compiled with the compile-time option SQLITE_ENABLE_MEMORY_MANAGEMENT. Optionally, attempts to reset and/or compact the Win32 native heap, if applicable.

public static SQLiteErrorCode ReleaseMemory(
int nBytes,
bool reset,
bool compact,
ref int nFree,
ref bool resetOk,
ref uint nLargest
);

Parameters

nBytes
The requested number of bytes to free.
reset
Non-zero to attempt a heap reset.
compact
Non-zero to attempt heap compaction.
nFree
The number of bytes actually freed. This value may be zero.
resetOk
This value will be non-zero if the heap reset was successful.
nLargest
The size of the largest committed free block in the heap, in bytes. This value will be zero unless heap compaction is enabled.

Return Value

A standard SQLite return code (i.e. zero for success and non-zero for failure).

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.ReleaseMemory Overload List


SQLiteConnection.ResultCode Method

Enables or disables extended result codes returned by SQLite

public SQLiteErrorCode ResultCode();

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetAvRetry Method

Queries or modifies the number of retries or the retry interval (in milliseconds) for certain I/O operations that may fail due to anti-virus software.

public SQLiteErrorCode SetAvRetry(
ref int count,
ref int interval
);

Parameters

count
The number of times to retry the I/O operation. A negative value will cause the current count to be queried and replace that negative value.
interval
The number of milliseconds to wait before retrying the I/O operation. This number is multiplied by the number of retry attempts so far to come up with the final number of milliseconds to wait. A negative value will cause the current interval to be queried and replace that negative value.

Return Value

Zero for success, non-zero for error.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetChunkSize Method

Sets the chunk size for the primary file associated with this database connection.

public SQLiteErrorCode SetChunkSize(
int size
);

Parameters

size
The new chunk size for the main database, in bytes.

Return Value

Zero for success, non-zero for error.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetConfigurationOption Method

Change a configuration option value for the database.

public void SetConfigurationOption(
SQLiteConfigDbOpsEnum option,
object value
);

Parameters

option
The database configuration option to change.
value
The new value for the specified configuration option.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetExtendedResultCodes Method

Enables or disables extended result codes returned by SQLite

public void SetExtendedResultCodes(
bool bOnOff
);

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetLimitOption Method

Change a limit value for the database.

public int SetLimitOption(
SQLiteLimitOpsEnum option,
int value
);

Parameters

option
The database limit to change.
value
The new value for the specified limit.

Return Value

The old value for the specified limit -OR- negative one if an error occurs.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetMemoryStatus Method

Sets the status of the memory usage tracking subsystem in the SQLite core library. By default, this is enabled. If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is global to the process.

public static SQLiteErrorCode SetMemoryStatus(
bool value
);

Parameters

value
Non-zero to enable memory usage tracking, zero otherwise.

Return Value

A standard SQLite return code (i.e. zero for success and non-zero for failure).

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SetPassword Method

SQLite ADO.NET Provider

SQLiteConnection.SetPassword Method

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.

Overload List

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.

public void SetPassword(byte[])

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.

public void SetPassword(string)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.SetPassword(Byte) Method

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.

public void SetPassword(
byte[] databasePassword
);

Parameters

databasePassword
The password for the database.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.SetPassword Overload List


SQLiteConnection.SetPassword(String) Method

WARNING: This method always throws an exception unless the library
         has been built with encryption support.
Sets existing password for a closed password-protected database. Password-protected databases are unusable for any other operation until the password has been set. Generally, this is accomplished via setting one of the "*Password" connection string properties, because it must be done prior to opening the database.

public void SetPassword(
string databasePassword
);

Parameters

databasePassword
The password for the database.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.SetPassword Overload List


SQLiteConnection.SetTypeCallbacks Method

Sets, resets, or clears the per-connection type callbacks for the specified database type name.

public bool SetTypeCallbacks(
string typeName,
SQLiteTypeCallbacks callbacks
);

Parameters

typeName
The database type name.
callbacks
The object holding the callbacks for the database type name. If this parameter is null, any callbacks for the database type name will be removed if they are present.

Return Value

Non-zero if callbacks were set or removed; otherwise, zero.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


Shutdown Method

SQLite ADO.NET Provider

SQLiteConnection.Shutdown Method

Passes a shutdown request to the SQLite core library. Does not throw an exception if the shutdown request fails.

Overload List

Passes a shutdown request to the SQLite core library. Does not throw an exception if the shutdown request fails.

public SQLiteErrorCode Shutdown()

Passes a shutdown request to the SQLite core library. Throws an exception if the shutdown request fails and the no-throw parameter is non-zero.

public static void Shutdown(bool,bool)

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Shutdown() Method

Passes a shutdown request to the SQLite core library. Does not throw an exception if the shutdown request fails.

public SQLiteErrorCode Shutdown();

Return Value

A standard SQLite return code (i.e. zero for success and non-zero for failure).

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.Shutdown Overload List


SQLiteConnection.Shutdown(Boolean, Boolean) Method

Passes a shutdown request to the SQLite core library. Throws an exception if the shutdown request fails and the no-throw parameter is non-zero.

public static void Shutdown(
bool directories,
bool noThrow
);

Parameters

directories
Non-zero to reset the database and temporary directories to their default values, which should be null for both.
noThrow
When non-zero, throw an exception if the shutdown request fails.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace | SQLiteConnection.Shutdown Overload List


SQLiteConnection.TryGetTypeCallbacks Method

Attempts to get the per-connection type callbacks for the specified database type name.

public bool TryGetTypeCallbacks(
string typeName,
out SQLiteTypeCallbacks callbacks
);

Parameters

typeName
The database type name.
callbacks
Upon success, this parameter will contain the object holding the callbacks for the database type name. Upon failure, this parameter will be null.

Return Value

Non-zero upon success; otherwise, zero.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.UnbindAllFunctions Method

This method unbinds all registered (known) functions -OR- all previously bound user-defined functions from this connection.

public bool UnbindAllFunctions(
bool registered
);

Parameters

registered
Non-zero to unbind all registered (known) functions -OR- zero to unbind all functions currently bound to the connection.

Return Value

Non-zero if all the specified user-defined functions were unbound.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.UnbindFunction Method

Attempts to unbind the specified SQLiteFunction object instance to this connection.

public bool UnbindFunction(
SQLiteFunctionAttribute functionAttribute
);

Parameters

functionAttribute
The SQLiteFunctionAttribute object instance containing the metadata for the function to be unbound.

Return Value

Non-zero if the function was unbound.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.WaitForEnlistmentReset Method

EXPERIMENTAL -- Waits for the enlistment associated with this connection to be reset. This method always throws NotImplementedException when running on the .NET Compact Framework.

public bool WaitForEnlistmentReset(
int timeoutMilliseconds,
bool? returnOnDisposed
);

Parameters

timeoutMilliseconds
The approximate maximum number of milliseconds to wait before timing out the wait operation.
returnOnDisposed
The return value to use if the connection has been disposed; if this value is null, ObjectDisposedException will be raised if the connection has been disposed.

Return Value

Non-zero if the enlistment assciated with this connection was reset; otherwise, zero. It should be noted that this method returning a non-zero value does not necessarily guarantee that the connection can enlist in a new transaction (i.e. due to potentical race with other threads); therefore, callers should generally use try/catch when calling the EnlistTransaction method.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection Events

The events of the SQLiteConnection class are listed below. For a complete list of SQLiteConnection class members, see the SQLiteConnection Members topic.

Public Static Events

Changed This event is raised when events related to the lifecycle of a SQLiteConnection object occur.

Public Instance Events

Authorize | This event is raised whenever SQLite encounters an action covered by the authorizer during query preparation. Changing the value of the ReturnCode property will determine if the specific action will be allowed, ignored, or denied. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.
Busy | This event is raised periodically during long running queries. Changing the value of the ReturnCode property will determine if the database operation will be retried or stopped. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.
Commit | This event is raised whenever SQLite is committing a transaction. Return non-zero to trigger a rollback.
Disposed (inherited from Component) | Occurs when the component is disposed by a call to the Dispose method.
Progress | This event is raised periodically during long running queries. Changing the value of the ReturnCode property will determine if the operation in progress will continue or be interrupted. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.
RollBack | This event is raised whenever SQLite is rolling back a transaction.
StateChange | This event is raised whenever the database is opened or closed.
Trace | This event is raised whenever SQLite statement first begins executing on this connection. It only applies to the given connection.
Trace2 | This event is raised when events matching the configured mask are raised for this connection.
Update | This event is raised whenever SQLite makes an update/delete/insert into the database on this connection. It only applies to the given connection.

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Authorize Event

This event is raised whenever SQLite encounters an action covered by the authorizer during query preparation. Changing the value of the ReturnCode property will determine if the specific action will be allowed, ignored, or denied. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.

public event SQLiteAuthorizerEventHandler Authorize;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Busy Event

This event is raised periodically during long running queries. Changing the value of the ReturnCode property will determine if the database operation will be retried or stopped. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.

public event SQLiteBusyEventHandler Busy;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Changed Event

This event is raised when events related to the lifecycle of a SQLiteConnection object occur.

public static event SQLiteConnectionEventHandler Changed;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Commit Event

This event is raised whenever SQLite is committing a transaction. Return non-zero to trigger a rollback.

public event SQLiteCommitHandler Commit;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Progress Event

This event is raised periodically during long running queries. Changing the value of the ReturnCode property will determine if the operation in progress will continue or be interrupted. For the entire duration of the event, the associated connection and statement objects must not be modified, either directly or indirectly, by the called code.

public event SQLiteProgressEventHandler Progress;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.RollBack Event

This event is raised whenever SQLite is rolling back a transaction.

public event EventHandler RollBack;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.StateChange Event

This event is raised whenever the database is opened or closed.

public event StateChangeEventHandler StateChange;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Trace Event

This event is raised whenever SQLite statement first begins executing on this connection. It only applies to the given connection.

public event SQLiteTraceEventHandler Trace;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Trace2 Event

This event is raised when events matching the configured mask are raised for this connection.

public event SQLiteTraceEventHandler Trace2;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnection.Update Event

This event is raised whenever SQLite makes an update/delete/insert into the database on this connection. It only applies to the given connection.

public event SQLiteUpdateEventHandler Update;

See Also

SQLiteConnection Class | System.Data.SQLite Namespace


SQLiteConnectionEventHandler Delegate

Raised when an event pertaining to a connection occurs.

public delegate void SQLiteConnectionEventHandler(
object sender,
ConnectionEventArgs e
);

Parameters

sender
The connection involved.
e
Extra information about the event.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteConnectionEventType Enumeration

These are the event types associated with the SQLiteConnectionEventHandler delegate (and its corresponding event) and the ConnectionEventArgs class.

public enum SQLiteConnectionEventType

Members

Member Name | Description
Invalid | Not used.
Unknown | Not used.
Opening | The connection is being opened.
ConnectionString | The connection string has been parsed.
Opened | The connection was opened.
ChangeDatabase | The ChangeDatabase method was called on the connection.
NewTransaction | A transaction was created using the connection.
EnlistTransaction | The connection was enlisted into a transaction.
NewCommand | A command was created using the connection.
NewDataReader | A data reader was created using the connection.
NewCriticalHandle | An instance of a CriticalHandle derived class has been created to wrap a native resource.
Closing | The connection is being closed.
Closed | The connection was closed.
DisposingCommand | A command is being disposed.
DisposingDataReader | A data reader is being disposed.
ClosingDataReader | A data reader is being closed.
OpenedFromPool | A native resource was opened (i.e. obtained) from the pool.
ClosedToPool | A native resource was closed (i.e. released) to the pool.
DisposingConnection | The connection is being disposed.
DisposedConnection | The connection was disposed.
FinalizingConnection | The connection is being finalized.
FinalizedConnection | The connection was finalized.
NothingToDo | The closing of the object had no effect, e.g. because the underlying resource was not actually allocated or opened.
ConnectionStringPreview | The connection string may be changed.
SqlStringPreview | The SQL string may be changed.
Canceled | The Cancel method was invoked.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteConnectionFlags Enumeration

The extra behavioral flags that can be applied to a connection.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum SQLiteConnectionFlags : long

Members

Member Name | Description | Value
None | No extra flags. | 0
LogPrepare | Enable logging of all SQL statements to be prepared. | 1
LogPreBind | Enable logging of all bound parameter types and raw values. | 2
LogBind | Enable logging of all bound parameter strongly typed values. | 4
LogCallbackException | Enable logging of all exceptions caught from user-provided managed code called from native code via delegates. | 8
LogBackup | Enable logging of backup API errors. | 16
NoExtensionFunctions | Skip adding the extension functions provided by the native interop assembly. | 32
BindUInt32AsInt64 | When binding parameter values with the UInt32 type, use the interop method that accepts an Int64 value. | 64
BindAllAsText | When binding parameter values, always bind them as though they were plain text (i.e. no numeric, date/time, or other conversions should be attempted). | 128
GetAllAsText | When returning column values, always return them as though they were plain text (i.e. no numeric, date/time, or other conversions should be attempted). | 256
NoLoadExtension | Prevent this SQLiteConnection object instance from loading extensions. | 512
NoCreateModule | Prevent this SQLiteConnection object instance from creating virtual table modules. | 1024
NoBindFunctions | Skip binding any functions provided by other managed assemblies when opening the connection. | 2048
NoLogModule | Skip setting the logging related properties of the SQLiteModule object instance that was passed to the CreateModule method. | 4096
LogModuleError | Enable logging of all virtual table module errors seen by the SetTableError method. | 8192
LogModuleException | Enable logging of certain virtual table module exceptions that cannot be easily discovered via other means. | 16384
TraceWarning | Enable tracing of potentially important [non-fatal] error conditions that cannot be easily reported through other means. | 32768
ConvertInvariantText | When binding parameter values, always use the invariant culture when converting their values from strings. | 65536
BindInvariantText | When binding parameter values, always use the invariant culture when converting their values to strings. | 131072
NoConnectionPool | Disable using the connection pool by default. If the "Pooling" connection string property is specified, its value will override this flag. The precise outcome of combining this flag with the UseConnectionPool flag is unspecified; however, one of the flags will be in effect. | 262144
UseConnectionPool | Enable using the connection pool by default. If the "Pooling" connection string property is specified, its value will override this flag. The precise outcome of combining this flag with the NoConnectionPool flag is unspecified; however, one of the flags will be in effect. | 524288
UseConnectionTypes | Enable using per-connection mappings between type names and DbType values. Also see the ClearTypeMappings, GetTypeMappings, and AddTypeMapping methods. These per-connection mappings, when present, override the corresponding global mappings. | 1048576
NoGlobalTypes | Disable using global mappings between type names and DbType values. This may be useful in some very narrow cases; however, if there are no per-connection type mappings, the fallback defaults will be used for both type names and their associated DbType values. Therefore, use of this flag is not recommended. | 2097152
StickyHasRows | When the HasRows property is used, it should return non-zero if there were ever any rows in the associated result sets. | 4194304
StrictEnlistment | Enable "strict" transaction enlistment semantics. Setting this flag will cause an exception to be thrown if an attempt is made to enlist in a transaction with an unavailable or unsupported isolation level. In the future, more extensive checks may be enabled by this flag as well. | 8388608
MapIsolationLevels | Enable mapping of unsupported transaction isolation levels to the closest supported transaction isolation level. | 16777216
DetectTextAffinity | When returning column values, attempt to detect the affinity of textual values by checking if they fully conform to those of the Null, Int64, Double, or DateTime types. | 33554432
DetectStringType | When returning column values, attempt to detect the type of string values by checking if they fully conform to those of the Null, Int64, Double, or DateTime types. | 67108864
NoConvertSettings | Skip querying runtime configuration settings for use by the SQLiteConvert class, including the default DbType value and default database type name. NOTE: If the DefaultDbType and/or DefaultTypeName properties are not set explicitly nor set via their connection string properties and repeated calls to determine these runtime configuration settings are seen to be a problem, this flag should be set. | 134217728
BindDateTimeWithKind | When binding parameter values with the DateTime type, take their DateTimeKind into account as well as that of the associated SQLiteConnection. | 268435456
RollbackOnException | If an exception is caught when raising the Commit event, the transaction should be rolled back. If this is not specified, the transaction will continue the commit process instead. | 536870912
DenyOnException | If an exception is caught when raising the Authorize event, the action should should be denied. If this is not specified, the action will be allowed instead. | 1073741824
InterruptOnException | If an exception is caught when raising the Progress event, the operation should be interrupted. If this is not specified, the operation will simply continue. | 2147483648
UnbindFunctionsOnClose | Attempt to unbind all functions provided by other managed assemblies when closing the connection. | 4294967296
NoVerifyTextAffinity | When returning column values as a String, skip verifying their affinity. | 8589934592
UseConnectionBindValueCallbacks | Enable using per-connection mappings between type names and SQLiteBindValueCallback values. Also see the ClearTypeCallbacks, TryGetTypeCallbacks, and SetTypeCallbacks methods. | 17179869184
UseConnectionReadValueCallbacks | Enable using per-connection mappings between type names and SQLiteReadValueCallback values. Also see the ClearTypeCallbacks, TryGetTypeCallbacks, and SetTypeCallbacks methods. | 34359738368
UseParameterNameForTypeName | If the database type name has not been explicitly set for the parameter specified, fallback to using the parameter name. | 68719476736
UseParameterDbTypeForTypeName | If the database type name has not been explicitly set for the parameter specified, fallback to using the database type name associated with the DbType value. | 137438953472
NoVerifyTypeAffinity | When returning column values, skip verifying their affinity. | 274877906944
AllowNestedTransactions | Allow transactions to be nested. The outermost transaction still controls whether or not any changes are ultimately committed or rolled back. All non-outermost transactions are implemented using the SAVEPOINT construct. | 549755813888
BindDecimalAsText | When binding parameter values, always bind Decimal values as though they were plain text (i.e. not Decimal, which is the legacy behavior). | 1099511627776
GetDecimalAsText | When returning column values, always return Decimal values as though they were plain text (i.e. not Double, which is the legacy behavior). | 2199023255552
BindInvariantDecimal | When binding Decimal parameter values, always use the invariant culture when converting their values to strings. | 4398046511104
GetInvariantDecimal | When returning Decimal column values, always use the invariant culture when converting their values from strings. | 8796093022208
WaitForEnlistmentReset | EXPERIMENTAL -- Enable waiting for the enlistment to be reset prior to attempting to create a new enlistment. This may be necessary due to the semantics used by distributed transactions, which complete asynchronously. | 17592186044416
GetInvariantInt64 | When returning Int64 column values, always use the invariant culture when converting their values from strings. | 35184372088832
GetInvariantDouble | When returning Double column values, always use the invariant culture when converting their values from strings. | 70368744177664
StrictConformance | EXPERIMENTAL -- Enable strict conformance to the ADO.NET standard, e.g. use of thrown exceptions to indicate common error conditions. | 140737488355328
HidePassword | EXPERIMENTAL -- When opening a connection, attempt to hide the password from the connection string, etc. Given the memory architecture of the CLR, (and P/Invoke) this is not 100% reliable and should not be relied upon for security critical uses or applications. | 281474976710656
NoCoreFunctions | Skip adding the extension functions provided by the native interop assembly if they would conflict with a function provided by the SQLite core library. | 562949953421312
StopOnException | If an exception is caught when raising the Busy event, the operation should be stopped. If this is not specified, the operation will be retried. | 1125899906842624
LogRetry | Enable logging of internal retries during statment preparation and stepping. | 2251799813685248
BindAndGetAllAsText | When binding parameter values or returning column values, always treat them as though they were plain text (i.e. no numeric, date/time, or other conversions should be attempted). | 384
ConvertAndBindInvariantText | When binding parameter values, always use the invariant culture when converting their values to strings or from strings. | 196608
BindAndGetAllAsInvariantText | When binding parameter values or returning column values, always treat them as though they were plain text (i.e. no numeric, date/time, or other conversions should be attempted) and always use the invariant culture when converting their values to strings. | 131456
ConvertAndBindAndGetAllAsInvariantText | When binding parameter values or returning column values, always treat them as though they were plain text (i.e. no numeric, date/time, or other conversions should be attempted) and always use the invariant culture when converting their values to strings or from strings. | 196992
UseConnectionAllValueCallbacks | Enables use of all per-connection value handling callbacks. | 51539607552
UseParameterAnythingForTypeName | Enables use of all applicable SQLiteParameter properties as fallbacks for the database type name. | 206158430208
LogAll | Enable all logging. | 2251799813709855
LogDefault | The default logging related flags for new connections. | 16392
Default | The default extra flags for new connections. | 13194139549704
DefaultAndLogAll | The default extra flags for new connections with all logging enabled. | 2264993953243167

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteConnectionStringBuilder Class

SQLite implementation of DbConnectionStringBuilder.

For a list of all members of this type, see SQLiteConnectionStringBuilder Members .

System.Object
DbConnectionStringBuilder
SQLiteConnectionStringBuilder

public sealed class SQLiteConnectionStringBuilder : DbConnectionStringBuilder

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteConnectionStringBuilder Members | System.Data.SQLite Namespace


SQLiteConnectionStringBuilder Members

SQLiteConnectionStringBuilder overview

Public Instance Constructors

SQLiteConnectionStringBuilder Overloaded. Constructs a new instance of the class

Public Instance Properties

BaseSchemaName | Gets/Sets the placeholder base schema name used for .NET Framework compatibility purposes.
BinaryGUID | Gets/Sets whethor not to store GUID's in binary format. The default is True which saves space in the database.
BrowsableConnectionString (inherited from DbConnectionStringBuilder) | Gets or sets a value that indicates whether the ConnectionString property is visible in Visual Studio designers.
BusyTimeout | Gets/sets the busy timeout to use with the SQLite core library.
CacheSize | Gets/Sets the cache size for the connection.
ConnectionString (inherited from DbConnectionStringBuilder) | Gets or sets the connection string associated with the DbConnectionStringBuilder.
Count (inherited from DbConnectionStringBuilder) | Gets the current number of keys that are contained within the ConnectionString property.
DataSource | Gets/Sets the filename to open on the connection string.
DateTimeFormat | Gets/Sets the DateTime format for the connection.
DateTimeFormatString | Gets/sets the DateTime format string used for formatting and parsing purposes.
DateTimeKind | Gets/Sets the DateTime kind for the connection.
DefaultDbType | Gets/sets the default database type for the connection.
DefaultIsolationLevel | Sets the default isolation level for transactions on the connection.
DefaultMaximumSleepTime | Gets/sets the default maximum sleep time for newly-created commands.
DefaultTimeout | Gets/sets the default command timeout for newly-created commands. This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible.
DefaultTypeName | Gets/sets the default type name for the connection.
Enlist | Determines whether or not the connection will automatically participate in the current distributed transaction (if one exists)
FailIfMissing | If set to true, will throw an exception if the database specified in the connection string does not exist. If false, the database will be created automatically.
Flags | Gets/Sets the extra behavioral flags.
ForeignKeys | If enabled, use foreign key constraints
FullUri | An alternate to the data source property that uses the SQLite URI syntax.
HexPassword | Gets/sets the database encryption hexadecimal password
IsFixedSize (inherited from DbConnectionStringBuilder) | Gets a value that indicates whether the DbConnectionStringBuilder has a fixed size.
IsReadOnly (inherited from DbConnectionStringBuilder) | Gets a value that indicates whether the DbConnectionStringBuilder is read-only.
Item (inherited from DbConnectionStringBuilder) | Gets or sets the value associated with the specified key.
JournalMode | Determines how SQLite handles the transaction journal file.
Keys (inherited from DbConnectionStringBuilder) | Gets an ICollection that contains the keys in the DbConnectionStringBuilder.
LegacyFormat | If enabled, uses the legacy 3.xx format for maximum compatibility, but results in larger database sizes.
MaxPageCount | Gets/Sets the maximum number of pages the database may hold
NoDefaultFlags | If enabled, skip using the configured default connection flags.
NoSharedFlags | If enabled, skip using the configured shared connection flags.
PageSize | Gets/Sets the page size for the connection.
Password | Gets/sets the database encryption password
Pooling | Gets/Sets whether or not to use connection pooling. The default is "False"
PrepareRetries | Gets/sets the maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed.
ProgressOps | Gets/sets the approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well.
ReadOnly | When enabled, the database will be opened for read-only access and writing will be disabled.
RecursiveTriggers | Enable or disable the recursive trigger capability.
SetDefaults | If enabled, apply the default connection settings to opened databases.
StepRetries | Gets/sets the maximum number of retries when stepping SQL to be executed. This normally only applies to stepping errors resulting from the database being locked.
SyncMode | Gets/Sets the synchronization mode (file flushing) of the connection string. Default is "Normal".
TextHexPassword | Gets/sets the database encryption textual password in hexadecimal
TextPassword | Gets/sets the database encryption textual password
ToFullPath | If enabled, attempt to resolve the provided data source file name to a full path before opening.
Uri | An alternate to the data source property
UseUTF16Encoding | Gets/Sets the encoding for the connection string. The default is "False" which indicates UTF-8 encoding.
Values (inherited from DbConnectionStringBuilder) | Gets an ICollection that contains the values in the DbConnectionStringBuilder.
Version | Gets/Sets the default version of the SQLite engine to instantiate. Currently the only valid value is 3, indicating version 3 of the sqlite library.
VfsName | Gets/sets the VFS name for the connection.
WaitTimeout | EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set.
ZipVfsVersion | If non-null, this is the version of ZipVFS to use. This requires the System.Data.SQLite interop assembly -AND- primary managed assembly to be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this property does nothing.

Public Instance Methods

Add (inherited from DbConnectionStringBuilder) | Adds an entry with the specified key and value into the DbConnectionStringBuilder.
Clear (inherited from DbConnectionStringBuilder) | Clears the contents of the DbConnectionStringBuilder instance.
ContainsKey (inherited from DbConnectionStringBuilder) | Determines whether the DbConnectionStringBuilder contains a specific key.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
EquivalentTo (inherited from DbConnectionStringBuilder) | Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Remove (inherited from DbConnectionStringBuilder) | Removes the entry with the specified key from the DbConnectionStringBuilder instance.
ShouldSerialize (inherited from DbConnectionStringBuilder) | Indicates whether the specified key exists in this DbConnectionStringBuilder instance.
ToString (inherited from DbConnectionStringBuilder) | Returns the connection string associated with this DbConnectionStringBuilder.
TryGetValue | Helper function for retrieving values from the connectionstring

Protected Instance Methods

ClearPropertyDescriptors (inherited from DbConnectionStringBuilder) | Clears the collection of PropertyDescriptor objects on the associated DbConnectionStringBuilder.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetProperties (inherited from DbConnectionStringBuilder) | Fills a supplied Hashtable with information about all the properties of this DbConnectionStringBuilder.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SQLiteConnectionStringBuilder Constructor

Constructs a new instance of the class

Overload List

Default constructor

public SQLiteConnectionStringBuilder()

Constructs a new instance of the class using the specified connection string.

public SQLiteConnectionStringBuilder(string)

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SQLiteConnectionStringBuilder Constructor

Default constructor

SQLiteConnectionStringBuilder();

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace | SQLiteConnectionStringBuilder Constructor Overload List


SQLiteConnectionStringBuilder Constructor

Constructs a new instance of the class using the specified connection string.

SQLiteConnectionStringBuilder(
string connectionString
);

Parameters

connectionString
The connection string to parse

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace | SQLiteConnectionStringBuilder Constructor Overload List


SQLiteConnectionStringBuilder Properties

The properties of the SQLiteConnectionStringBuilder class are listed below. For a complete list of SQLiteConnectionStringBuilder class members, see the SQLiteConnectionStringBuilder Members topic.

Public Instance Properties

BaseSchemaName | Gets/Sets the placeholder base schema name used for .NET Framework compatibility purposes.
BinaryGUID | Gets/Sets whethor not to store GUID's in binary format. The default is True which saves space in the database.
BrowsableConnectionString (inherited from DbConnectionStringBuilder) | Gets or sets a value that indicates whether the ConnectionString property is visible in Visual Studio designers.
BusyTimeout | Gets/sets the busy timeout to use with the SQLite core library.
CacheSize | Gets/Sets the cache size for the connection.
ConnectionString (inherited from DbConnectionStringBuilder) | Gets or sets the connection string associated with the DbConnectionStringBuilder.
Count (inherited from DbConnectionStringBuilder) | Gets the current number of keys that are contained within the ConnectionString property.
DataSource | Gets/Sets the filename to open on the connection string.
DateTimeFormat | Gets/Sets the DateTime format for the connection.
DateTimeFormatString | Gets/sets the DateTime format string used for formatting and parsing purposes.
DateTimeKind | Gets/Sets the DateTime kind for the connection.
DefaultDbType | Gets/sets the default database type for the connection.
DefaultIsolationLevel | Sets the default isolation level for transactions on the connection.
DefaultMaximumSleepTime | Gets/sets the default maximum sleep time for newly-created commands.
DefaultTimeout | Gets/sets the default command timeout for newly-created commands. This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible.
DefaultTypeName | Gets/sets the default type name for the connection.
Enlist | Determines whether or not the connection will automatically participate in the current distributed transaction (if one exists)
FailIfMissing | If set to true, will throw an exception if the database specified in the connection string does not exist. If false, the database will be created automatically.
Flags | Gets/Sets the extra behavioral flags.
ForeignKeys | If enabled, use foreign key constraints
FullUri | An alternate to the data source property that uses the SQLite URI syntax.
HexPassword | Gets/sets the database encryption hexadecimal password
IsFixedSize (inherited from DbConnectionStringBuilder) | Gets a value that indicates whether the DbConnectionStringBuilder has a fixed size.
IsReadOnly (inherited from DbConnectionStringBuilder) | Gets a value that indicates whether the DbConnectionStringBuilder is read-only.
Item (inherited from DbConnectionStringBuilder) | Gets or sets the value associated with the specified key.
JournalMode | Determines how SQLite handles the transaction journal file.
Keys (inherited from DbConnectionStringBuilder) | Gets an ICollection that contains the keys in the DbConnectionStringBuilder.
LegacyFormat | If enabled, uses the legacy 3.xx format for maximum compatibility, but results in larger database sizes.
MaxPageCount | Gets/Sets the maximum number of pages the database may hold
NoDefaultFlags | If enabled, skip using the configured default connection flags.
NoSharedFlags | If enabled, skip using the configured shared connection flags.
PageSize | Gets/Sets the page size for the connection.
Password | Gets/sets the database encryption password
Pooling | Gets/Sets whether or not to use connection pooling. The default is "False"
PrepareRetries | Gets/sets the maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed.
ProgressOps | Gets/sets the approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well.
ReadOnly | When enabled, the database will be opened for read-only access and writing will be disabled.
RecursiveTriggers | Enable or disable the recursive trigger capability.
SetDefaults | If enabled, apply the default connection settings to opened databases.
StepRetries | Gets/sets the maximum number of retries when stepping SQL to be executed. This normally only applies to stepping errors resulting from the database being locked.
SyncMode | Gets/Sets the synchronization mode (file flushing) of the connection string. Default is "Normal".
TextHexPassword | Gets/sets the database encryption textual password in hexadecimal
TextPassword | Gets/sets the database encryption textual password
ToFullPath | If enabled, attempt to resolve the provided data source file name to a full path before opening.
Uri | An alternate to the data source property
UseUTF16Encoding | Gets/Sets the encoding for the connection string. The default is "False" which indicates UTF-8 encoding.
Values (inherited from DbConnectionStringBuilder) | Gets an ICollection that contains the values in the DbConnectionStringBuilder.
Version | Gets/Sets the default version of the SQLite engine to instantiate. Currently the only valid value is 3, indicating version 3 of the sqlite library.
VfsName | Gets/sets the VFS name for the connection.
WaitTimeout | EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set.
ZipVfsVersion | If non-null, this is the version of ZipVFS to use. This requires the System.Data.SQLite interop assembly -AND- primary managed assembly to be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this property does nothing.

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


BaseSchemaName Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.BaseSchemaName Property

Gets/Sets the placeholder base schema name used for .NET Framework compatibility purposes.

public string BaseSchemaName { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


BinaryGUID Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.BinaryGUID Property

Gets/Sets whethor not to store GUID's in binary format. The default is True which saves space in the database.

public bool BinaryGUID { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


BusyTimeout Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.BusyTimeout Property

Gets/sets the busy timeout to use with the SQLite core library.

public int BusyTimeout { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


CacheSize Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.CacheSize Property

Gets/Sets the cache size for the connection.

public int CacheSize { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DataSource Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DataSource Property

Gets/Sets the filename to open on the connection string.

public string DataSource { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DateTimeFormat Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DateTimeFormat Property

Gets/Sets the DateTime format for the connection.

public SQLiteDateFormats DateTimeFormat { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DateTimeFormatString Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DateTimeFormatString Property

Gets/sets the DateTime format string used for formatting and parsing purposes.

public string DateTimeFormatString { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DateTimeKind Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DateTimeKind Property

Gets/Sets the DateTime kind for the connection.

public DateTimeKind DateTimeKind { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DefaultDbType Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DefaultDbType Property

Gets/sets the default database type for the connection.

public DbType DefaultDbType { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DefaultIsolationLevel Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DefaultIsolationLevel Property

Sets the default isolation level for transactions on the connection.

public IsolationLevel DefaultIsolationLevel { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DefaultMaximumSleepTime Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DefaultMaximumSleepTime Property

Gets/sets the default maximum sleep time for newly-created commands.

public int DefaultMaximumSleepTime { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DefaultTimeout Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DefaultTimeout Property

Gets/sets the default command timeout for newly-created commands. This is especially useful for commands used internally such as inside a SQLiteTransaction, where setting the timeout is not possible.

public int DefaultTimeout { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


DefaultTypeName Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.DefaultTypeName Property

Gets/sets the default type name for the connection.

public string DefaultTypeName { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


Enlist Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.Enlist Property

Determines whether or not the connection will automatically participate in the current distributed transaction (if one exists)

public bool Enlist { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


FailIfMissing Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.FailIfMissing Property

If set to true, will throw an exception if the database specified in the connection string does not exist. If false, the database will be created automatically.

public bool FailIfMissing { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


Flags Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.Flags Property

Gets/Sets the extra behavioral flags.

public SQLiteConnectionFlags Flags { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


ForeignKeys Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.ForeignKeys Property

If enabled, use foreign key constraints

public bool ForeignKeys { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


FullUri Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.FullUri Property

An alternate to the data source property that uses the SQLite URI syntax.

public string FullUri { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


HexPassword Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.HexPassword Property

Gets/sets the database encryption hexadecimal password

public byte[] HexPassword { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


JournalMode Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.JournalMode Property

Determines how SQLite handles the transaction journal file.

public SQLiteJournalModeEnum JournalMode { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


LegacyFormat Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.LegacyFormat Property

If enabled, uses the legacy 3.xx format for maximum compatibility, but results in larger database sizes.

public bool LegacyFormat { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


MaxPageCount Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.MaxPageCount Property

Gets/Sets the maximum number of pages the database may hold

public int MaxPageCount { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


NoDefaultFlags Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.NoDefaultFlags Property

If enabled, skip using the configured default connection flags.

public bool NoDefaultFlags { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


NoSharedFlags Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.NoSharedFlags Property

If enabled, skip using the configured shared connection flags.

public bool NoSharedFlags { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


PageSize Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.PageSize Property

Gets/Sets the page size for the connection.

public int PageSize { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


Password Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.Password Property

Gets/sets the database encryption password

public string Password { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


Pooling Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.Pooling Property

Gets/Sets whether or not to use connection pooling. The default is "False"

public bool Pooling { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


PrepareRetries Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.PrepareRetries Property

Gets/sets the maximum number of retries when preparing SQL to be executed. This normally only applies to preparation errors resulting from the database schema being changed.

public int PrepareRetries { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


ProgressOps Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.ProgressOps Property

Gets/sets the approximate number of virtual machine instructions between progress events. In order for progress events to actually fire, the event handler must be added to the Progress event as well.

public int ProgressOps { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


ReadOnly Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.ReadOnly Property

When enabled, the database will be opened for read-only access and writing will be disabled.

public bool ReadOnly { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


RecursiveTriggers Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.RecursiveTriggers Property

Enable or disable the recursive trigger capability.

public bool RecursiveTriggers { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SetDefaults Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.SetDefaults Property

If enabled, apply the default connection settings to opened databases.

public bool SetDefaults { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


StepRetries Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.StepRetries Property

Gets/sets the maximum number of retries when stepping SQL to be executed. This normally only applies to stepping errors resulting from the database being locked.

public int StepRetries { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SyncMode Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.SyncMode Property

Gets/Sets the synchronization mode (file flushing) of the connection string. Default is "Normal".

public SynchronizationModes SyncMode { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


TextHexPassword Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.TextHexPassword Property

Gets/sets the database encryption textual password in hexadecimal

public byte[] TextHexPassword { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


TextPassword Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.TextPassword Property

Gets/sets the database encryption textual password

public string TextPassword { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


ToFullPath Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.ToFullPath Property

If enabled, attempt to resolve the provided data source file name to a full path before opening.

public bool ToFullPath { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


Uri Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.Uri Property

An alternate to the data source property

public string Uri { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


UseUTF16Encoding Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.UseUTF16Encoding Property

Gets/Sets the encoding for the connection string. The default is "False" which indicates UTF-8 encoding.

public bool UseUTF16Encoding { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


Version Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.Version Property

Gets/Sets the default version of the SQLite engine to instantiate. Currently the only valid value is 3, indicating version 3 of the sqlite library.

public int Version { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


VfsName Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.VfsName Property

Gets/sets the VFS name for the connection.

public string VfsName { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


WaitTimeout Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.WaitTimeout Property

EXPERIMENTAL -- The wait timeout to use with WaitForEnlistmentReset method. This is only used when waiting for the enlistment to be reset prior to enlisting in a transaction, and then only when the appropriate connection flag is set.

public int WaitTimeout { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


ZipVfsVersion Property

SQLite ADO.NET Provider

SQLiteConnectionStringBuilder.ZipVfsVersion Property

If non-null, this is the version of ZipVFS to use. This requires the System.Data.SQLite interop assembly -AND- primary managed assembly to be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this property does nothing.

public string ZipVfsVersion { public get; public set; }

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SQLiteConnectionStringBuilder Methods

The methods of the SQLiteConnectionStringBuilder class are listed below. For a complete list of SQLiteConnectionStringBuilder class members, see the SQLiteConnectionStringBuilder Members topic.

Public Instance Methods

Add (inherited from DbConnectionStringBuilder) | Adds an entry with the specified key and value into the DbConnectionStringBuilder.
Clear (inherited from DbConnectionStringBuilder) | Clears the contents of the DbConnectionStringBuilder instance.
ContainsKey (inherited from DbConnectionStringBuilder) | Determines whether the DbConnectionStringBuilder contains a specific key.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
EquivalentTo (inherited from DbConnectionStringBuilder) | Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Remove (inherited from DbConnectionStringBuilder) | Removes the entry with the specified key from the DbConnectionStringBuilder instance.
ShouldSerialize (inherited from DbConnectionStringBuilder) | Indicates whether the specified key exists in this DbConnectionStringBuilder instance.
ToString (inherited from DbConnectionStringBuilder) | Returns the connection string associated with this DbConnectionStringBuilder.
TryGetValue | Helper function for retrieving values from the connectionstring

Protected Instance Methods

ClearPropertyDescriptors (inherited from DbConnectionStringBuilder) | Clears the collection of PropertyDescriptor objects on the associated DbConnectionStringBuilder.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetProperties (inherited from DbConnectionStringBuilder) | Fills a supplied Hashtable with information about all the properties of this DbConnectionStringBuilder.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SQLiteConnectionStringBuilder.TryGetValue Method

Helper function for retrieving values from the connectionstring

public override bool TryGetValue(
string keyword,
out object value
);

Parameters

keyword
The keyword to retrieve settings for
value
The resulting parameter value

Return Value

Returns true if the value was found and returned

See Also

SQLiteConnectionStringBuilder Class | System.Data.SQLite Namespace


SQLiteContext Class

This class represents a context from the SQLite core library that can be passed to the sqlite3_result_*() and associated functions.

For a list of all members of this type, see SQLiteContext Members .

System.Object
SQLiteContext

public sealed class SQLiteContext : ISQLiteNativeHandle

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteContext Members | System.Data.SQLite Namespace


SQLiteContext Members

SQLiteContext overview

Public Instance Properties

NativeHandle Returns the underlying SQLite native handle associated with this object instance.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
NoChange | Attempts to determine if a specific column being fetched via the xColumn method as part of an UPDATE operation will not change. Use of this method is invalid in any other context.
SetBlob | Sets the context result to the specified Byte array value.
SetDouble | Sets the context result to the specified Double value.
SetError | Sets the context result to the specified String value containing an error message.
SetErrorCode | Sets the context result to the specified SQLiteErrorCode value.
SetErrorNoMemory | Sets the context result to contain the error code SQLITE_NOMEM.
SetErrorTooBig | Sets the context result to contain the error code SQLITE_TOOBIG.
SetInt | Sets the context result to the specified Int32 value.
SetInt64 | Sets the context result to the specified Int64 value.
SetNull | Sets the context result to NULL.
SetString | Sets the context result to the specified String value.
SetSubType | Sets the context result sub-type to the desired value.
SetValue | Sets the context result to the specified SQLiteValue.
SetZeroBlob | Sets the context result to a BLOB of zeros of the specified size.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext Properties

The properties of the SQLiteContext class are listed below. For a complete list of SQLiteContext class members, see the SQLiteContext Members topic.

Public Instance Properties

NativeHandle Returns the underlying SQLite native handle associated with this object instance.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


NativeHandle Property

SQLite ADO.NET Provider

SQLiteContext.NativeHandle Property

Returns the underlying SQLite native handle associated with this object instance.

public IntPtr NativeHandle { public get; }

Implements

ISQLiteNativeHandle.NativeHandle

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext Methods

The methods of the SQLiteContext class are listed below. For a complete list of SQLiteContext class members, see the SQLiteContext Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
NoChange | Attempts to determine if a specific column being fetched via the xColumn method as part of an UPDATE operation will not change. Use of this method is invalid in any other context.
SetBlob | Sets the context result to the specified Byte array value.
SetDouble | Sets the context result to the specified Double value.
SetError | Sets the context result to the specified String value containing an error message.
SetErrorCode | Sets the context result to the specified SQLiteErrorCode value.
SetErrorNoMemory | Sets the context result to contain the error code SQLITE_NOMEM.
SetErrorTooBig | Sets the context result to contain the error code SQLITE_TOOBIG.
SetInt | Sets the context result to the specified Int32 value.
SetInt64 | Sets the context result to the specified Int64 value.
SetNull | Sets the context result to NULL.
SetString | Sets the context result to the specified String value.
SetSubType | Sets the context result sub-type to the desired value.
SetValue | Sets the context result to the specified SQLiteValue.
SetZeroBlob | Sets the context result to a BLOB of zeros of the specified size.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.NoChange Method

Attempts to determine if a specific column being fetched via the xColumn method as part of an UPDATE operation will not change. Use of this method is invalid in any other context.

public int NoChange();

Return Value

Non-zero if the column being fetched via a pending call to the xColumn method as part of an UPDATE operation during which the column value will not change. The virtual table implementation can use this hint as permission to substitute a return value that is less expensive to compute and that the corresponding xUpdate method understands as a "no-change" value.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetBlob Method

Sets the context result to the specified Byte array value.

public void SetBlob(
byte[] value
);

Parameters

value
The Byte array value to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetDouble Method

Sets the context result to the specified Double value.

public void SetDouble(
double value
);

Parameters

value
The Double value to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetError Method

Sets the context result to the specified String value containing an error message.

public void SetError(
string value
);

Parameters

value
The String value containing the error message text. This value will be converted to the UTF-8 encoding prior to being used.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetErrorCode Method

Sets the context result to the specified SQLiteErrorCode value.

public void SetErrorCode(
SQLiteErrorCode value
);

Parameters

value
The SQLiteErrorCode value to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetErrorNoMemory Method

Sets the context result to contain the error code SQLITE_NOMEM.

public void SetErrorNoMemory();

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetErrorTooBig Method

Sets the context result to contain the error code SQLITE_TOOBIG.

public void SetErrorTooBig();

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetInt Method

Sets the context result to the specified Int32 value.

public void SetInt(
int value
);

Parameters

value
The Int32 value to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetInt64 Method

Sets the context result to the specified Int64 value.

public void SetInt64(
long value
);

Parameters

value
The Int64 value to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetNull Method

Sets the context result to NULL.

public void SetNull();

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetString Method

Sets the context result to the specified String value.

public void SetString(
string value
);

Parameters

value
The String value to use. This value will be converted to the UTF-8 encoding prior to being used.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetSubType Method

Sets the context result sub-type to the desired value.

public void SetSubType(
uint value
);

Parameters

value
The sub-type value to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetValue Method

Sets the context result to the specified SQLiteValue.

public void SetValue(
SQLiteValue value
);

Parameters

value
The SQLiteValue to use.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteContext.SetZeroBlob Method

Sets the context result to a BLOB of zeros of the specified size.

public void SetZeroBlob(
int value
);

Parameters

value
The number of zero bytes to use for the BLOB context result.

See Also

SQLiteContext Class | System.Data.SQLite Namespace


SQLiteConvert Class

This base class provides datatype conversion services for the SQLite provider.

For a list of all members of this type, see SQLiteConvert Members .

System.Object
SQLiteConvert

public abstract class SQLiteConvert

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteConvert Members | System.Data.SQLite Namespace


SQLiteConvert Members

SQLiteConvert overview

Public Static Methods

GetStringOrNull | Converts the object value, which is assumed to have originated from a DataRow, to a string value.
Split | Smart method of splitting a string. Skips quoted elements, removes the quotes.
ToBoolean | Overloaded. Convert a value to true or false.
ToDateTime | Overloaded. Converts a string into a DateTime, using the specified DateTimeFormat, DateTimeKind and DateTimeFormatString.
ToJulianDay | Converts a DateTime struct to a JulianDay double
ToString | Overloaded. Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.
ToStringWithProvider | Queries and returns the string representation for an object, using the specified (or current) format provider.
ToUnixEpoch | Converts a DateTime struct to the whole number of seconds since the Unix epoch.
ToUTF8 | Overloaded. Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.
UTF8ToString | Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

Protected Static Fields

UnixEpoch The value for the Unix epoch (e.g. January 1, 1970 at midnight, in UTC).

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToDateTime | Overloaded. Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.
ToString | Overloaded. Converts a UTF-8 encoded IntPtr of the specified length into a .NET string
ToString (inherited from Object) | Overloaded. Returns a String that represents the current Object.
ToUTF8 | Overloaded. Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert Fields

The fields of the SQLiteConvert class are listed below. For a complete list of SQLiteConvert class members, see the SQLiteConvert Members topic.

Protected Static Fields

UnixEpoch The value for the Unix epoch (e.g. January 1, 1970 at midnight, in UTC).

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.UnixEpoch Field

The value for the Unix epoch (e.g. January 1, 1970 at midnight, in UTC).

protected static readonly DateTime UnixEpoch;

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert Methods

The methods of the SQLiteConvert class are listed below. For a complete list of SQLiteConvert class members, see the SQLiteConvert Members topic.

Public Static Methods

GetStringOrNull | Converts the object value, which is assumed to have originated from a DataRow, to a string value.
Split | Smart method of splitting a string. Skips quoted elements, removes the quotes.
ToBoolean | Overloaded. Convert a value to true or false.
ToDateTime | Overloaded. Converts a string into a DateTime, using the specified DateTimeFormat, DateTimeKind and DateTimeFormatString.
ToJulianDay | Converts a DateTime struct to a JulianDay double
ToString | Overloaded. Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.
ToStringWithProvider | Queries and returns the string representation for an object, using the specified (or current) format provider.
ToUnixEpoch | Converts a DateTime struct to the whole number of seconds since the Unix epoch.
ToUTF8 | Overloaded. Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.
UTF8ToString | Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToDateTime | Overloaded. Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.
ToString | Overloaded. Converts a UTF-8 encoded IntPtr of the specified length into a .NET string
ToString (inherited from Object) | Overloaded. Returns a String that represents the current Object.
ToUTF8 | Overloaded. Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.GetStringOrNull Method

Converts the object value, which is assumed to have originated from a DataRow, to a string value.

public static string GetStringOrNull(
object value
);

Parameters

value
The value to be converted to a string.

Return Value

A null value will be returned if the original value is null -OR- the original value is Value. Otherwise, the original value will be converted to a string, using its (possibly overridden) ToString method and then returned.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.Split Method

Smart method of splitting a string. Skips quoted elements, removes the quotes.

public static string[] Split(
string source,
char separator
);

Parameters

source
Source string to split apart
separator
Separator character

Return Value

A string array of the split up elements

Remarks

This split function works somewhat like the String.Split() function in that it breaks apart a string into pieces and returns the pieces as an array. The primary differences are:

  • Only one character can be provided as a separator character
  • Quoted text inside the string is skipped over when searching for the separator, and the quotes are removed.
Thus, if splitting the following string looking for a comma:
One,Two, "Three, Four", Five

The resulting array would contain
[0] One
[1] Two
[2] Three, Four
[3] Five

Note that the leading and trailing spaces were removed from each item during the split.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


ToBoolean Method

SQLite ADO.NET Provider

SQLiteConvert.ToBoolean Method

Convert a value to true or false.

Overload List

Convert a value to true or false.

public static bool ToBoolean(object)

Attempts to convert a String into a Boolean.

public static bool ToBoolean(string)

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.ToBoolean(Object) Method

Convert a value to true or false.

public static bool ToBoolean(
object source
);

Parameters

source
A string or number representing true or false

Return Value

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToBoolean Overload List


SQLiteConvert.ToBoolean(String) Method

Attempts to convert a String into a Boolean.

public static bool ToBoolean(
string source
);

Parameters

source
The String to convert, cannot be null.

Return Value

The converted Boolean value.

Remarks

The supported strings are "yes", "no", "y", "n", "on", "off", "0", "1", as well as any prefix of the strings FalseString and TrueString. All strings are treated in a case-insensitive manner.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToBoolean Overload List


ToDateTime Method

SQLite ADO.NET Provider

SQLiteConvert.ToDateTime Method

Converts a julianday value into a DateTime

Overload List

Converts a julianday value into a DateTime

public DateTime ToDateTime(double)

Converts a julianday value into a DateTime

public static DateTime ToDateTime(double,DateTimeKind)

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

public DateTime ToDateTime(string)

Converts a string into a DateTime, using the specified DateTimeFormat, DateTimeKind and DateTimeFormatString.

public static DateTime ToDateTime(string,SQLiteDateFormats,DateTimeKind,string)

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.ToDateTime(Double) Method

Converts a julianday value into a DateTime

public DateTime ToDateTime(
double julianDay
);

Parameters

julianDay
The value to convert

Return Value

A .NET DateTime

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToDateTime Overload List


SQLiteConvert.ToDateTime(Double, DateTimeKind) Method

Converts a julianday value into a DateTime

public static DateTime ToDateTime(
double julianDay,
DateTimeKind kind
);

Parameters

julianDay
The value to convert
kind
The DateTimeKind to use.

Return Value

A .NET DateTime

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToDateTime Overload List


SQLiteConvert.ToDateTime(String) Method

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

public DateTime ToDateTime(
string dateText
);

Parameters

dateText
The string containing either a long integer number of 100-nanosecond units since System.DateTime.MinValue, a Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time string, a formatted date and time string in the current culture, or an ISO8601-format string.

Return Value

A DateTime value

Remarks

Acceptable ISO8601 DateTime formats are:

  • THHmmssK
  • THHmmK
  • HH:mm:ss.FFFFFFFK
  • HH:mm:ssK
  • HH:mmK
  • yyyy-MM-dd HH:mm:ss.FFFFFFFK
  • yyyy-MM-dd HH:mm:ssK
  • yyyy-MM-dd HH:mmK
  • yyyy-MM-ddTHH:mm:ss.FFFFFFFK
  • yyyy-MM-ddTHH:mmK
  • yyyy-MM-ddTHH:mm:ssK
  • yyyyMMddHHmmssK
  • yyyyMMddHHmmK
  • yyyyMMddTHHmmssFFFFFFFK
  • THHmmss
  • THHmm
  • HH:mm:ss.FFFFFFF
  • HH:mm:ss
  • HH:mm
  • yyyy-MM-dd HH:mm:ss.FFFFFFF
  • yyyy-MM-dd HH:mm:ss
  • yyyy-MM-dd HH:mm
  • yyyy-MM-ddTHH:mm:ss.FFFFFFF
  • yyyy-MM-ddTHH:mm
  • yyyy-MM-ddTHH:mm:ss
  • yyyyMMddHHmmss
  • yyyyMMddHHmm
  • yyyyMMddTHHmmssFFFFFFF
  • yyyy-MM-dd
  • yyyyMMdd
  • yy-MM-dd
If the string cannot be matched to one of the above formats -OR- the DateTimeFormatString if one was provided, an exception will be thrown.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToDateTime Overload List


SQLiteConvert.ToDateTime(String, SQLiteDateFormats, DateTimeKind, String) Method

Converts a string into a DateTime, using the specified DateTimeFormat, DateTimeKind and DateTimeFormatString.

public static DateTime ToDateTime(
string dateText,
SQLiteDateFormats format,
DateTimeKind kind,
string formatString
);

Parameters

dateText
The string containing either a long integer number of 100-nanosecond units since System.DateTime.MinValue, a Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time string, a formatted date and time string in the current culture, or an ISO8601-format string.
format
The SQLiteDateFormats to use.
kind
The DateTimeKind to use.
formatString
The DateTime format string to use.

Return Value

A DateTime value

Remarks

Acceptable ISO8601 DateTime formats are:

  • THHmmssK
  • THHmmK
  • HH:mm:ss.FFFFFFFK
  • HH:mm:ssK
  • HH:mmK
  • yyyy-MM-dd HH:mm:ss.FFFFFFFK
  • yyyy-MM-dd HH:mm:ssK
  • yyyy-MM-dd HH:mmK
  • yyyy-MM-ddTHH:mm:ss.FFFFFFFK
  • yyyy-MM-ddTHH:mmK
  • yyyy-MM-ddTHH:mm:ssK
  • yyyyMMddHHmmssK
  • yyyyMMddHHmmK
  • yyyyMMddTHHmmssFFFFFFFK
  • THHmmss
  • THHmm
  • HH:mm:ss.FFFFFFF
  • HH:mm:ss
  • HH:mm
  • yyyy-MM-dd HH:mm:ss.FFFFFFF
  • yyyy-MM-dd HH:mm:ss
  • yyyy-MM-dd HH:mm
  • yyyy-MM-ddTHH:mm:ss.FFFFFFF
  • yyyy-MM-ddTHH:mm
  • yyyy-MM-ddTHH:mm:ss
  • yyyyMMddHHmmss
  • yyyyMMddHHmm
  • yyyyMMddTHHmmssFFFFFFF
  • yyyy-MM-dd
  • yyyyMMdd
  • yy-MM-dd
If the string cannot be matched to one of the above formats -OR- the DateTimeFormatString if one was provided, an exception will be thrown.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToDateTime Overload List


SQLiteConvert.ToJulianDay Method

Converts a DateTime struct to a JulianDay double

public static double ToJulianDay(
DateTime? value
);

Parameters

value
The DateTime to convert

Return Value

The JulianDay value the Datetime represents

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


ToString Method

SQLite ADO.NET Provider

SQLiteConvert.ToString Method

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

Overload List

Inherited from Object.

public virtual string ToString()

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

public string ToString(DateTime)

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

public static string ToString(DateTime,SQLiteDateFormats,DateTimeKind,string)

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

public virtual string ToString(IntPtr,int)

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.ToString(DateTime) Method

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

public string ToString(
DateTime dateValue
);

Parameters

dateValue
The DateTime value to convert

Return Value

Either a string containing the long integer number of 100-nanosecond units since System.DateTime.MinValue, a Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time string, a formatted date and time string in the current culture, or an ISO8601-format date/time string.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToString Overload List


SQLiteConvert.ToString(DateTime, SQLiteDateFormats, DateTimeKind, String) Method

Converts a string into a DateTime, using the DateTimeFormat, DateTimeKind, and DateTimeFormatString specified for the connection when it was opened.

public static string ToString(
DateTime dateValue,
SQLiteDateFormats format,
DateTimeKind kind,
string formatString
);

Parameters

dateValue
The DateTime value to convert
format
The SQLiteDateFormats to use.
kind
The DateTimeKind to use.
formatString
The DateTime format string to use.

Return Value

Either a string containing the long integer number of 100-nanosecond units since System.DateTime.MinValue, a Julian day double, an integer number of seconds since the Unix epoch, a culture-independent formatted date and time string, a formatted date and time string in the current culture, or an ISO8601-format date/time string.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToString Overload List


SQLiteConvert.ToString(IntPtr, Int32) Method

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

public virtual string ToString(
IntPtr nativestring,
int nativestringlen
);

Parameters

nativestring
The pointer to the memory where the UTF-8 string is encoded
nativestringlen
The number of bytes to decode

Return Value

A string containing the translated character(s)

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToString Overload List


SQLiteConvert.ToStringWithProvider Method

Queries and returns the string representation for an object, using the specified (or current) format provider.

public static string ToStringWithProvider(
object obj,
IFormatProvider provider
);

Parameters

obj
The object instance to return the string representation for.
provider
The format provider to use -OR- null if the current format provider for the thread should be used instead.

Return Value

The string representation for the object instance -OR- null if the object instance is also null.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.ToUnixEpoch Method

Converts a DateTime struct to the whole number of seconds since the Unix epoch.

public static long ToUnixEpoch(
DateTime value
);

Parameters

value
The DateTime to convert

Return Value

The whole number of seconds since the Unix epoch

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


ToUTF8 Method

SQLite ADO.NET Provider

SQLiteConvert.ToUTF8 Method

Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.

Overload List

Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.

public byte[] ToUTF8(DateTime)

Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.

public static byte[] ToUTF8(string)

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteConvert.ToUTF8(DateTime) Method

Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.

public byte[] ToUTF8(
DateTime dateTimeValue
);

Parameters

dateTimeValue
The DateTime to convert.

Return Value

The UTF-8 encoded string, including a 0 terminating byte at the end of the array.

Remarks

This function is a convenience function, which first calls ToString() on the DateTime, and then calls ToUTF8() with the string result.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToUTF8 Overload List


SQLiteConvert.ToUTF8(String) Method

Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.

public static byte[] ToUTF8(
string sourceText
);

Parameters

sourceText
The string to convert to UTF-8

Return Value

A byte array containing the converted string plus an extra 0 terminating byte at the end of the array.

See Also

SQLiteConvert Class | System.Data.SQLite Namespace | SQLiteConvert.ToUTF8 Overload List


SQLiteConvert.UTF8ToString Method

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

public static string UTF8ToString(
IntPtr nativestring,
int nativestringlen
);

Parameters

nativestring
The pointer to the memory where the UTF-8 string is encoded
nativestringlen
The number of bytes to decode

Return Value

A string containing the translated character(s)

See Also

SQLiteConvert Class | System.Data.SQLite Namespace


SQLiteDataAdapter Class

SQLite implementation of DbDataAdapter.

For a list of all members of this type, see SQLiteDataAdapter Members .

System.Object
MarshalByRefObject
Component
DataAdapter
DbDataAdapter
SQLiteDataAdapter

public sealed class SQLiteDataAdapter : DbDataAdapter

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteDataAdapter Members | System.Data.SQLite Namespace


SQLiteDataAdapter Members

SQLiteDataAdapter overview

Public Instance Constructors

SQLiteDataAdapter Overloaded. This class is just a shell around the DbDataAdapter. Nothing from DbDataAdapter is overridden here, just a few constructors are defined.

Public Instance Properties

AcceptChangesDuringFill (inherited from DataAdapter) | Gets or sets a value indicating whether AcceptChanges is called on a DataRow after it is added to the DataTable during any of the Fill operations.
AcceptChangesDuringUpdate (inherited from DataAdapter) | Gets or sets whether AcceptChanges is called during a Update.
Container (inherited from Component) | Gets the IContainer that contains the Component.
ContinueUpdateOnError (inherited from DataAdapter) | Gets or sets a value that specifies whether to generate an exception when an error is encountered during a row update.
DeleteCommand | Overloaded. Gets/sets the delete command for this DataAdapter
FillLoadOption (inherited from DataAdapter) | Gets or sets the LoadOption that determines how the adapter fills the DataTable from the DbDataReader.
InsertCommand | Overloaded. Gets/sets the insert command for this DataAdapter
MissingMappingAction (inherited from DataAdapter) | Determines the action to take when incoming data does not have a matching table or column.
MissingSchemaAction (inherited from DataAdapter) | Determines the action to take when existing DataSet schema does not match incoming data.
ReturnProviderSpecificTypes (inherited from DataAdapter) | Gets or sets whether the Fill method should return provider-specific values or common CLS-compliant values.
SelectCommand | Overloaded. Gets/sets the select command for this DataAdapter
Site (inherited from Component) | Gets or sets the ISite of the Component.
TableMappings (inherited from DataAdapter) | Gets a collection that provides the master mapping between a source table and a DataTable.
UpdateBatchSize (inherited from DbDataAdapter) | Gets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch.
UpdateCommand | Overloaded. Gets/sets the update command for this DataAdapter

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Overloaded. Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Fill (inherited from DbDataAdapter) | Overloaded. Adds or refreshes rows in the DataSet to match those in the data source using the DataSet and DataTable names.
FillSchema (inherited from DbDataAdapter) | Overloaded. Configures the schema of the specified DataTable based on the specified SchemaType.
GetFillParameters (inherited from DbDataAdapter) | Gets the parameters set by the user when executing an SQL SELECT statement.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ResetFillLoadOption (inherited from DataAdapter) | Resets FillLoadOption to its default state and causes Fill to honor AcceptChangesDuringFill.
ShouldSerializeAcceptChangesDuringFill (inherited from DataAdapter) | Determines whether the AcceptChangesDuringFill property should be persisted.
ShouldSerializeFillLoadOption (inherited from DataAdapter) | Determines whether the FillLoadOption property should be persisted.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
Update (inherited from DbDataAdapter) | Overloaded. Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet.

Public Instance Events

Disposed (inherited from Component) | Occurs when the component is disposed by a call to the Dispose method.
FillError (inherited from DataAdapter) | Returned when an error occurs during a fill operation.
RowUpdated | Row updated event handler
RowUpdating | Row updating event handler

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.
FillCommandBehavior (inherited from DbDataAdapter) | Gets or sets the behavior of the command used to fill the data adapter.

Protected Instance Methods

AddToBatch (inherited from DbDataAdapter) | Adds a IDbCommand to the current batch.
ClearBatch (inherited from DbDataAdapter) | Removes all IDbCommand objects from the batch.
CloneInternals (inherited from DataAdapter) | Obsolete. Creates a copy of this instance of DataAdapter.
CreateRowUpdatedEvent (inherited from DbDataAdapter) | Initializes a new instance of the RowUpdatedEventArgs class.
CreateRowUpdatingEvent (inherited from DbDataAdapter) | Initializes a new instance of the RowUpdatingEventArgs class.
CreateTableMappings (inherited from DataAdapter) | Creates a new DataTableMappingCollection.
Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
ExecuteBatch (inherited from DbDataAdapter) | Executes the current batch.
Fill (inherited from DbDataAdapter) | Overloaded. Adds or refreshes rows in a DataTable to match those in the data source using the specified DataTable, IDbCommand and CommandBehavior.
Fill (inherited from DataAdapter) | Overloaded. Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.
FillSchema (inherited from DbDataAdapter) | Overloaded. Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.
FillSchema (inherited from DataAdapter) | Overloaded. Adds a DataTable to the specified DataSet.
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetBatchedParameter (inherited from DbDataAdapter) | Returns a IDataParameter from one of the commands in the current batch.
GetBatchedRecordsAffected (inherited from DbDataAdapter) | Returns information about an individual update attempt within a larger batched update.
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
HasTableMappings (inherited from DataAdapter) | Indicates whether a DataTableMappingCollection has been created.
InitializeBatching (inherited from DbDataAdapter) | Initializes batching for the DbDataAdapter.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
OnFillError (inherited from DataAdapter) | Invoked when an error occurs during a Fill.
OnRowUpdated | Raised by DbDataAdapter after a row is updated
OnRowUpdating | Raised by the underlying DbDataAdapter when a row is being updated
ShouldSerializeTableMappings (inherited from DataAdapter) | Determines whether one or more DataTableMapping objects exist and they should be persisted.
TerminateBatching (inherited from DbDataAdapter) | Ends batching for the DbDataAdapter.
Update (inherited from DbDataAdapter) | Overloaded. Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array of DataRow objects.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter Constructor

This class is just a shell around the DbDataAdapter. Nothing from DbDataAdapter is overridden here, just a few constructors are defined.

Overload List

Default constructor.

public SQLiteDataAdapter()

Constructs a data adapter using the specified select command.

public SQLiteDataAdapter(SQLiteCommand)

Constructs a data adapter with the supplied select command text and associated with the specified connection.

public SQLiteDataAdapter(string,SQLiteConnection)

Constructs a data adapter with the specified select command text, and using the specified database connection string.

public SQLiteDataAdapter(string,string)

Constructs a data adapter with the specified select command text, and using the specified database connection string.

public SQLiteDataAdapter(string,string,bool)

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter Constructor

Default constructor.

SQLiteDataAdapter();

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace | SQLiteDataAdapter Constructor Overload List


SQLiteDataAdapter Constructor

Constructs a data adapter using the specified select command.

SQLiteDataAdapter(
SQLiteCommand cmd
);

Parameters

cmd
The select command to associate with the adapter.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace | SQLiteDataAdapter Constructor Overload List


SQLiteDataAdapter Constructor

Constructs a data adapter with the supplied select command text and associated with the specified connection.

SQLiteDataAdapter(
string commandText,
SQLiteConnection connection
);

Parameters

commandText
The select command text to associate with the data adapter.
connection
The connection to associate with the select command.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace | SQLiteDataAdapter Constructor Overload List


SQLiteDataAdapter Constructor

Constructs a data adapter with the specified select command text, and using the specified database connection string.

SQLiteDataAdapter(
string commandText,
string connectionString
);

Parameters

commandText
The select command text to use to construct a select command.
connectionString
A connection string suitable for passing to a new SQLiteConnection, which is associated with the select command.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace | SQLiteDataAdapter Constructor Overload List


SQLiteDataAdapter Constructor

Constructs a data adapter with the specified select command text, and using the specified database connection string.

SQLiteDataAdapter(
string commandText,
string connectionString,
bool parseViaFramework
);

Parameters

commandText
The select command text to use to construct a select command.
connectionString
A connection string suitable for passing to a new SQLiteConnection, which is associated with the select command.
parseViaFramework
Non-zero to parse the connection string using the built-in (i.e. framework provided) parser when opening the connection.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace | SQLiteDataAdapter Constructor Overload List


SQLiteDataAdapter Properties

The properties of the SQLiteDataAdapter class are listed below. For a complete list of SQLiteDataAdapter class members, see the SQLiteDataAdapter Members topic.

Public Instance Properties

AcceptChangesDuringFill (inherited from DataAdapter) | Gets or sets a value indicating whether AcceptChanges is called on a DataRow after it is added to the DataTable during any of the Fill operations.
AcceptChangesDuringUpdate (inherited from DataAdapter) | Gets or sets whether AcceptChanges is called during a Update.
Container (inherited from Component) | Gets the IContainer that contains the Component.
ContinueUpdateOnError (inherited from DataAdapter) | Gets or sets a value that specifies whether to generate an exception when an error is encountered during a row update.
DeleteCommand | Overloaded. Gets/sets the delete command for this DataAdapter
FillLoadOption (inherited from DataAdapter) | Gets or sets the LoadOption that determines how the adapter fills the DataTable from the DbDataReader.
InsertCommand | Overloaded. Gets/sets the insert command for this DataAdapter
MissingMappingAction (inherited from DataAdapter) | Determines the action to take when incoming data does not have a matching table or column.
MissingSchemaAction (inherited from DataAdapter) | Determines the action to take when existing DataSet schema does not match incoming data.
ReturnProviderSpecificTypes (inherited from DataAdapter) | Gets or sets whether the Fill method should return provider-specific values or common CLS-compliant values.
SelectCommand | Overloaded. Gets/sets the select command for this DataAdapter
Site (inherited from Component) | Gets or sets the ISite of the Component.
TableMappings (inherited from DataAdapter) | Gets a collection that provides the master mapping between a source table and a DataTable.
UpdateBatchSize (inherited from DbDataAdapter) | Gets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch.
UpdateCommand | Overloaded. Gets/sets the update command for this DataAdapter

Protected Instance Properties

CanRaiseEvents (inherited from Component) | Gets a value indicating whether the component can raise an event.
DesignMode (inherited from Component) | Gets a value that indicates whether the Component is currently in design mode.
Events (inherited from Component) | Gets the list of event handlers that are attached to this Component.
FillCommandBehavior (inherited from DbDataAdapter) | Gets or sets the behavior of the command used to fill the data adapter.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


DeleteCommand Property

SQLite ADO.NET Provider

SQLiteDataAdapter.DeleteCommand Property

Gets/sets the delete command for this DataAdapter

new public SQLiteCommand DeleteCommand { public get; public set; }

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


InsertCommand Property

SQLite ADO.NET Provider

SQLiteDataAdapter.InsertCommand Property

Gets/sets the insert command for this DataAdapter

new public SQLiteCommand InsertCommand { public get; public set; }

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SelectCommand Property

SQLite ADO.NET Provider

SQLiteDataAdapter.SelectCommand Property

Gets/sets the select command for this DataAdapter

new public SQLiteCommand SelectCommand { public get; public set; }

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


UpdateCommand Property

SQLite ADO.NET Provider

SQLiteDataAdapter.UpdateCommand Property

Gets/sets the update command for this DataAdapter

new public SQLiteCommand UpdateCommand { public get; public set; }

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter Methods

The methods of the SQLiteDataAdapter class are listed below. For a complete list of SQLiteDataAdapter class members, see the SQLiteDataAdapter Members topic.

Public Instance Methods

CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from Component) | Overloaded. Releases all resources used by the Component.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Fill (inherited from DbDataAdapter) | Overloaded. Adds or refreshes rows in the DataSet to match those in the data source using the DataSet and DataTable names.
FillSchema (inherited from DbDataAdapter) | Overloaded. Configures the schema of the specified DataTable based on the specified SchemaType.
GetFillParameters (inherited from DbDataAdapter) | Gets the parameters set by the user when executing an SQL SELECT statement.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ResetFillLoadOption (inherited from DataAdapter) | Resets FillLoadOption to its default state and causes Fill to honor AcceptChangesDuringFill.
ShouldSerializeAcceptChangesDuringFill (inherited from DataAdapter) | Determines whether the AcceptChangesDuringFill property should be persisted.
ShouldSerializeFillLoadOption (inherited from DataAdapter) | Determines whether the FillLoadOption property should be persisted.
ToString (inherited from Component) | Returns a String containing the name of the Component, if any. This method should not be overridden.
Update (inherited from DbDataAdapter) | Overloaded. Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet.

Protected Instance Methods

AddToBatch (inherited from DbDataAdapter) | Adds a IDbCommand to the current batch.
ClearBatch (inherited from DbDataAdapter) | Removes all IDbCommand objects from the batch.
CloneInternals (inherited from DataAdapter) | Obsolete. Creates a copy of this instance of DataAdapter.
CreateRowUpdatedEvent (inherited from DbDataAdapter) | Initializes a new instance of the RowUpdatedEventArgs class.
CreateRowUpdatingEvent (inherited from DbDataAdapter) | Initializes a new instance of the RowUpdatingEventArgs class.
CreateTableMappings (inherited from DataAdapter) | Creates a new DataTableMappingCollection.
Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
ExecuteBatch (inherited from DbDataAdapter) | Executes the current batch.
Fill (inherited from DbDataAdapter) | Overloaded. Adds or refreshes rows in a DataTable to match those in the data source using the specified DataTable, IDbCommand and CommandBehavior.
Fill (inherited from DataAdapter) | Overloaded. Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.
FillSchema (inherited from DbDataAdapter) | Overloaded. Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.
FillSchema (inherited from DataAdapter) | Overloaded. Adds a DataTable to the specified DataSet.
Finalize (inherited from Component) | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
GetBatchedParameter (inherited from DbDataAdapter) | Returns a IDataParameter from one of the commands in the current batch.
GetBatchedRecordsAffected (inherited from DbDataAdapter) | Returns information about an individual update attempt within a larger batched update.
GetService (inherited from Component) | Returns an object that represents a service provided by the Component or by its Container.
HasTableMappings (inherited from DataAdapter) | Indicates whether a DataTableMappingCollection has been created.
InitializeBatching (inherited from DbDataAdapter) | Initializes batching for the DbDataAdapter.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
OnFillError (inherited from DataAdapter) | Invoked when an error occurs during a Fill.
OnRowUpdated | Raised by DbDataAdapter after a row is updated
OnRowUpdating | Raised by the underlying DbDataAdapter when a row is being updated
ShouldSerializeTableMappings (inherited from DataAdapter) | Determines whether one or more DataTableMapping objects exist and they should be persisted.
TerminateBatching (inherited from DbDataAdapter) | Ends batching for the DbDataAdapter.
Update (inherited from DbDataAdapter) | Overloaded. Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array of DataRow objects.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteDataAdapter.Dispose Method

Cleans up resources (native and managed) associated with the current instance.

Overload List

Inherited from Component.

public void Dispose()

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(bool)

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter.Dispose(Boolean) Method

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Zero when being disposed via garbage collection; otherwise, non-zero.

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace | SQLiteDataAdapter.Dispose Overload List


SQLiteDataAdapter.OnRowUpdated Method

Raised by DbDataAdapter after a row is updated

protected override void OnRowUpdated(
RowUpdatedEventArgs value
);

Parameters

value
The event's specifics

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter.OnRowUpdating Method

Raised by the underlying DbDataAdapter when a row is being updated

protected override void OnRowUpdating(
RowUpdatingEventArgs value
);

Parameters

value
The event's specifics

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter Events

The events of the SQLiteDataAdapter class are listed below. For a complete list of SQLiteDataAdapter class members, see the SQLiteDataAdapter Members topic.

Public Instance Events

Disposed (inherited from Component) | Occurs when the component is disposed by a call to the Dispose method.
FillError (inherited from DataAdapter) | Returned when an error occurs during a fill operation.
RowUpdated | Row updated event handler
RowUpdating | Row updating event handler

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter.RowUpdated Event

Row updated event handler

public event EventHandler<RowUpdatedEventArgs> RowUpdated;

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataAdapter.RowUpdating Event

Row updating event handler

public event EventHandler<RowUpdatingEventArgs> RowUpdating;

See Also

SQLiteDataAdapter Class | System.Data.SQLite Namespace


SQLiteDataReader Class

SQLite implementation of DbDataReader.

For a list of all members of this type, see SQLiteDataReader Members .

System.Object
MarshalByRefObject
DbDataReader
SQLiteDataReader

public sealed class SQLiteDataReader : DbDataReader

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteDataReader Members | System.Data.SQLite Namespace


SQLiteDataReader Members

SQLiteDataReader overview

Public Instance Properties

Depth | Not implemented. Returns 0
FieldCount | Returns the number of columns in the current resultset
HasRows | Returns True if the resultset has rows that can be fetched
IsClosed | Returns True if the data reader is closed
Item | Overloaded. Indexer to retrieve data from a column given its name
RecordsAffected | Returns the number of rows affected by the statement being executed. The value returned may not be accurate for DDL statements. Also, it will be -1 for any statement that does not modify the database (e.g. SELECT). If an otherwise read-only statement modifies the database indirectly (e.g. via a virtual table or user-defined function), the value returned is undefined.
StepCount | Returns the number of rows seen so far in the current result set.
VisibleFieldCount | Returns the number of visible fields in the current resultset

Public Instance Methods

Close | Closes the datareader, potentially closing the connection as well if CommandBehavior.CloseConnection was specified.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbDataReader) | Overloaded. Releases all resources used by the current instance of the DbDataReader class.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBlob | Retrieves the column as a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.
GetBoolean | Retrieves the column as a boolean value
GetByte | Retrieves the column as a single byte value
GetBytes | Retrieves a column as an array of bytes (blob)
GetChar | Returns the column as a single character
GetChars | Retrieves a column as an array of chars (blob)
GetData (inherited from DbDataReader) | Returns a DbDataReader object for the requested column ordinal.
GetDatabaseName | Returns the name of the database associated with the specified column.
GetDataTypeName | Retrieves the name of the back-end datatype of the column
GetDateTime | Retrieve the column as a date/time value
GetDecimal | Retrieve the column as a decimal value
GetDouble | Returns the column as a double
GetEnumerator | Enumerator support
GetFieldAffinity | Determines and returns the TypeAffinity of the specified column.
GetFieldType | Returns the .NET type of a given column
GetFloat | Returns a column as a float value
GetGuid | Returns the column as a Guid
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetInt16 | Returns the column as a short
GetInt32 | Retrieves the column as an int
GetInt64 | Retrieves the column as a long
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetName | Retrieves the name of the column
GetOrdinal | Retrieves the i of a column, given its name
GetOriginalName | Returns the original name of the specified column.
GetProviderSpecificFieldType (inherited from DbDataReader) | Returns the provider-specific field type of the specified column.
GetProviderSpecificValue (inherited from DbDataReader) | Gets the value of the specified column as an instance of Object.
GetProviderSpecificValues (inherited from DbDataReader) | Gets all provider-specific attribute columns in the collection for the current row.
GetSchemaTable | Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done to gather the necessary information so it can be represented in an ADO.NET manner.
GetString | Retrieves the column as a string
GetTableName | Returns the name of the table associated with the specified column.
GetType (inherited from Object) | Gets the Type of the current instance.
GetValue | Retrieves the column as an object corresponding to the underlying datatype of the column
GetValues | Overloaded. Retreives the values of multiple columns, up to the size of the supplied array
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
IsDBNull | Returns True if the specified column is null
NextResult | Moves to the next resultset in multiple row-returning SQL command.
Read | Attempts to read the next row from the current result set.
RefreshFlags | Forces the connection flags cached by this data reader to be refreshed from the underlying connection.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Dispose of all resources used by this datareader.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetDbDataReader (inherited from DbDataReader) | Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader Properties

The properties of the SQLiteDataReader class are listed below. For a complete list of SQLiteDataReader class members, see the SQLiteDataReader Members topic.

Public Instance Properties

Depth | Not implemented. Returns 0
FieldCount | Returns the number of columns in the current resultset
HasRows | Returns True if the resultset has rows that can be fetched
IsClosed | Returns True if the data reader is closed
Item | Overloaded. Indexer to retrieve data from a column given its name
RecordsAffected | Returns the number of rows affected by the statement being executed. The value returned may not be accurate for DDL statements. Also, it will be -1 for any statement that does not modify the database (e.g. SELECT). If an otherwise read-only statement modifies the database indirectly (e.g. via a virtual table or user-defined function), the value returned is undefined.
StepCount | Returns the number of rows seen so far in the current result set.
VisibleFieldCount | Returns the number of visible fields in the current resultset

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


Depth Property

SQLite ADO.NET Provider

SQLiteDataReader.Depth Property

Not implemented. Returns 0

public override int Depth { public get; }

Implements

IDataReader.Depth

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


FieldCount Property

SQLite ADO.NET Provider

SQLiteDataReader.FieldCount Property

Returns the number of columns in the current resultset

public override int FieldCount { public get; }

Implements

IDataRecord.FieldCount

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


HasRows Property

SQLite ADO.NET Provider

SQLiteDataReader.HasRows Property

Returns True if the resultset has rows that can be fetched

public override bool HasRows { public get; }

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


IsClosed Property

SQLite ADO.NET Provider

SQLiteDataReader.IsClosed Property

Returns True if the data reader is closed

public override bool IsClosed { public get; }

Implements

IDataReader.IsClosed

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


Object Property

SQLite ADO.NET Provider

SQLiteDataReader.Object Property

Indexer to retrieve data from a column given its i

Overload List

Indexer to retrieve data from a column given its i

public override object this[ int] { public get; }

Indexer to retrieve data from a column given its name

public override object this[ string] { public get; }

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


Item Property

SQLite ADO.NET Provider

SQLiteDataReader.Item Property

Indexer to retrieve data from a column given its i

public override object this[
int i
] { public get; }

Parameters

i
The index of the column.

Implements

IDataRecord.Item

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace | SQLiteDataReader.Item Overload List


Item Property

SQLite ADO.NET Provider

SQLiteDataReader.Item Property

Indexer to retrieve data from a column given its name

public override object this[
string name
] { public get; }

Parameters

name
The name of the column to retrieve data for

Implements

IDataRecord.Item

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace | SQLiteDataReader.Item Overload List


RecordsAffected Property

SQLite ADO.NET Provider

SQLiteDataReader.RecordsAffected Property

Returns the number of rows affected by the statement being executed. The value returned may not be accurate for DDL statements. Also, it will be -1 for any statement that does not modify the database (e.g. SELECT). If an otherwise read-only statement modifies the database indirectly (e.g. via a virtual table or user-defined function), the value returned is undefined.

public override int RecordsAffected { public get; }

Implements

IDataReader.RecordsAffected

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


StepCount Property

SQLite ADO.NET Provider

SQLiteDataReader.StepCount Property

Returns the number of rows seen so far in the current result set.

public int StepCount { public get; }

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


VisibleFieldCount Property

SQLite ADO.NET Provider

SQLiteDataReader.VisibleFieldCount Property

Returns the number of visible fields in the current resultset

public override int VisibleFieldCount { public get; }

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader Methods

The methods of the SQLiteDataReader class are listed below. For a complete list of SQLiteDataReader class members, see the SQLiteDataReader Members topic.

Public Instance Methods

Close | Closes the datareader, potentially closing the connection as well if CommandBehavior.CloseConnection was specified.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbDataReader) | Overloaded. Releases all resources used by the current instance of the DbDataReader class.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBlob | Retrieves the column as a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.
GetBoolean | Retrieves the column as a boolean value
GetByte | Retrieves the column as a single byte value
GetBytes | Retrieves a column as an array of bytes (blob)
GetChar | Returns the column as a single character
GetChars | Retrieves a column as an array of chars (blob)
GetData (inherited from DbDataReader) | Returns a DbDataReader object for the requested column ordinal.
GetDatabaseName | Returns the name of the database associated with the specified column.
GetDataTypeName | Retrieves the name of the back-end datatype of the column
GetDateTime | Retrieve the column as a date/time value
GetDecimal | Retrieve the column as a decimal value
GetDouble | Returns the column as a double
GetEnumerator | Enumerator support
GetFieldAffinity | Determines and returns the TypeAffinity of the specified column.
GetFieldType | Returns the .NET type of a given column
GetFloat | Returns a column as a float value
GetGuid | Returns the column as a Guid
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetInt16 | Returns the column as a short
GetInt32 | Retrieves the column as an int
GetInt64 | Retrieves the column as a long
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetName | Retrieves the name of the column
GetOrdinal | Retrieves the i of a column, given its name
GetOriginalName | Returns the original name of the specified column.
GetProviderSpecificFieldType (inherited from DbDataReader) | Returns the provider-specific field type of the specified column.
GetProviderSpecificValue (inherited from DbDataReader) | Gets the value of the specified column as an instance of Object.
GetProviderSpecificValues (inherited from DbDataReader) | Gets all provider-specific attribute columns in the collection for the current row.
GetSchemaTable | Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done to gather the necessary information so it can be represented in an ADO.NET manner.
GetString | Retrieves the column as a string
GetTableName | Returns the name of the table associated with the specified column.
GetType (inherited from Object) | Gets the Type of the current instance.
GetValue | Retrieves the column as an object corresponding to the underlying datatype of the column
GetValues | Overloaded. Retreives the values of multiple columns, up to the size of the supplied array
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
IsDBNull | Returns True if the specified column is null
NextResult | Moves to the next resultset in multiple row-returning SQL command.
Read | Attempts to read the next row from the current result set.
RefreshFlags | Forces the connection flags cached by this data reader to be refreshed from the underlying connection.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Dispose of all resources used by this datareader.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetDbDataReader (inherited from DbDataReader) | Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.Close Method

Closes the datareader, potentially closing the connection as well if CommandBehavior.CloseConnection was specified.

public override void Close();

Implements

IDataReader.Close

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteDataReader.Dispose Method

Dispose of all resources used by this datareader.

Overload List

Inherited from DbDataReader.

public void Dispose()

Dispose of all resources used by this datareader.

protected override void Dispose(bool)

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.Dispose(Boolean) Method

Dispose of all resources used by this datareader.

protected override void Dispose(
bool disposing
);

Parameters

disposing

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace | SQLiteDataReader.Dispose Overload List


SQLiteDataReader.GetBlob Method

Retrieves the column as a SQLiteBlob object. This will not work for tables that were created WITHOUT ROWID -OR- if the query does not include the "rowid" column or one of its aliases -OR- if the SQLiteDataReader was not created with the KeyInfo flag.

public SQLiteBlob GetBlob(
int i,
bool readOnly
);

Parameters

i
The index of the column.
readOnly
Non-zero to open the blob object for read-only access.

Return Value

A new SQLiteBlob object.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetBoolean Method

Retrieves the column as a boolean value

public override bool GetBoolean(
int i
);

Parameters

i
The index of the column.

Return Value

bool

Implements

IDataRecord.GetBoolean

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetByte Method

Retrieves the column as a single byte value

public override byte GetByte(
int i
);

Parameters

i
The index of the column.

Return Value

byte

Implements

IDataRecord.GetByte

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetBytes Method

Retrieves a column as an array of bytes (blob)

public override long GetBytes(
int i,
long fieldOffset,
byte[] buffer,
int bufferoffset,
int length
);

Parameters

i
The index of the column.
fieldOffset
The zero-based index of where to begin reading the data
buffer
The buffer to write the bytes into
bufferoffset
The zero-based index of where to begin writing into the array
length
The number of bytes to retrieve

Return Value

The actual number of bytes written into the array

Implements

IDataRecord.GetBytes

Remarks

To determine the number of bytes in the column, pass a null value for the buffer. The total length will be returned.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetChar Method

Returns the column as a single character

public override char GetChar(
int i
);

Parameters

i
The index of the column.

Return Value

char

Implements

IDataRecord.GetChar

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetChars Method

Retrieves a column as an array of chars (blob)

public override long GetChars(
int i,
long fieldoffset,
char[] buffer,
int bufferoffset,
int length
);

Parameters

i
The index of the column.
fieldoffset
The zero-based index of where to begin reading the data
buffer
The buffer to write the characters into
bufferoffset
The zero-based index of where to begin writing into the array
length
The number of bytes to retrieve

Return Value

The actual number of characters written into the array

Implements

IDataRecord.GetChars

Remarks

To determine the number of characters in the column, pass a null value for the buffer. The total length will be returned.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetDatabaseName Method

Returns the name of the database associated with the specified column.

public string GetDatabaseName(
int i
);

Parameters

i
The index of the column.

Return Value

string

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetDataTypeName Method

Retrieves the name of the back-end datatype of the column

public override string GetDataTypeName(
int i
);

Parameters

i
The index of the column.

Return Value

string

Implements

IDataRecord.GetDataTypeName

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetDateTime Method

Retrieve the column as a date/time value

public override DateTime GetDateTime(
int i
);

Parameters

i
The index of the column.

Return Value

DateTime

Implements

IDataRecord.GetDateTime

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetDecimal Method

Retrieve the column as a decimal value

public override decimal GetDecimal(
int i
);

Parameters

i
The index of the column.

Return Value

decimal

Implements

IDataRecord.GetDecimal

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetDouble Method

Returns the column as a double

public override double GetDouble(
int i
);

Parameters

i
The index of the column.

Return Value

double

Implements

IDataRecord.GetDouble

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetEnumerator Method

Enumerator support

public override IEnumerator GetEnumerator();

Return Value

Returns a DbEnumerator object.

Implements

IEnumerable.GetEnumerator

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetFieldAffinity Method

Determines and returns the TypeAffinity of the specified column.

public TypeAffinity GetFieldAffinity(
int i
);

Parameters

i
The index of the column.

Return Value

The TypeAffinity associated with the specified column, if any.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetFieldType Method

Returns the .NET type of a given column

public override Type GetFieldType(
int i
);

Parameters

i
The index of the column.

Return Value

Type

Implements

IDataRecord.GetFieldType

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetFloat Method

Returns a column as a float value

public override float GetFloat(
int i
);

Parameters

i
The index of the column.

Return Value

float

Implements

IDataRecord.GetFloat

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetGuid Method

Returns the column as a Guid

public override Guid GetGuid(
int i
);

Parameters

i
The index of the column.

Return Value

Guid

Implements

IDataRecord.GetGuid

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetInt16 Method

Returns the column as a short

public override short GetInt16(
int i
);

Parameters

i
The index of the column.

Return Value

Int16

Implements

IDataRecord.GetInt16

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetInt32 Method

Retrieves the column as an int

public override int GetInt32(
int i
);

Parameters

i
The index of the column.

Return Value

Int32

Implements

IDataRecord.GetInt32

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetInt64 Method

Retrieves the column as a long

public override long GetInt64(
int i
);

Parameters

i
The index of the column.

Return Value

Int64

Implements

IDataRecord.GetInt64

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetName Method

Retrieves the name of the column

public override string GetName(
int i
);

Parameters

i
The index of the column.

Return Value

string

Implements

IDataRecord.GetName

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetOrdinal Method

Retrieves the i of a column, given its name

public override int GetOrdinal(
string name
);

Parameters

name
The name of the column to retrieve

Return Value

The int i of the column

Implements

IDataRecord.GetOrdinal

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetOriginalName Method

Returns the original name of the specified column.

public string GetOriginalName(
int i
);

Parameters

i
The index of the column.

Return Value

string

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetSchemaTable Method

Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done to gather the necessary information so it can be represented in an ADO.NET manner.

public override DataTable GetSchemaTable();

Return Value

Returns a DataTable containing the schema information for the active SELECT statement being processed.

Implements

IDataReader.GetSchemaTable

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetString Method

Retrieves the column as a string

public override string GetString(
int i
);

Parameters

i
The index of the column.

Return Value

string

Implements

IDataRecord.GetString

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetTableName Method

Returns the name of the table associated with the specified column.

public string GetTableName(
int i
);

Parameters

i
The index of the column.

Return Value

string

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetValue Method

Retrieves the column as an object corresponding to the underlying datatype of the column

public override object GetValue(
int i
);

Parameters

i
The index of the column.

Return Value

object

Implements

IDataRecord.GetValue

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


GetValues Method

SQLite ADO.NET Provider

SQLiteDataReader.GetValues Method

Returns a collection containing all the column names and values for the current row of data in the current resultset, if any. If there is no current row or no current resultset, an exception may be thrown.

Overload List

Returns a collection containing all the column names and values for the current row of data in the current resultset, if any. If there is no current row or no current resultset, an exception may be thrown.

public NameValueCollection GetValues()

Retreives the values of multiple columns, up to the size of the supplied array

public override int GetValues(object[])

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.GetValues() Method

Returns a collection containing all the column names and values for the current row of data in the current resultset, if any. If there is no current row or no current resultset, an exception may be thrown.

public NameValueCollection GetValues();

Return Value

The collection containing the column name and value information for the current row of data in the current resultset or null if this information cannot be obtained.

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace | SQLiteDataReader.GetValues Overload List


SQLiteDataReader.GetValues(Object) Method

Retreives the values of multiple columns, up to the size of the supplied array

public override int GetValues(
object[] values
);

Parameters

values
The array to fill with values from the columns in the current resultset

Return Value

The number of columns retrieved

Implements

IDataRecord.GetValues

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace | SQLiteDataReader.GetValues Overload List


SQLiteDataReader.IsDBNull Method

Returns True if the specified column is null

public override bool IsDBNull(
int i
);

Parameters

i
The index of the column.

Return Value

True or False

Implements

IDataRecord.IsDBNull

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.NextResult Method

Moves to the next resultset in multiple row-returning SQL command.

public override bool NextResult();

Return Value

True if the command was successful and a new resultset is available, False otherwise.

Implements

IDataReader.NextResult

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.Read Method

Attempts to read the next row from the current result set.

public override bool Read();

Return Value

Non-zero if a new row was successfully loaded and is ready for processing; otherwise, zero.

Implements

IDataReader.Read

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReader.RefreshFlags Method

Forces the connection flags cached by this data reader to be refreshed from the underlying connection.

public void RefreshFlags();

See Also

SQLiteDataReader Class | System.Data.SQLite Namespace


SQLiteDataReaderValue Class

This class represents a single value to be returned from the SQLiteDataReader class via its GetBlob, GetBoolean, GetByte, GetBytes, GetChar, GetChars, GetDateTime, GetDecimal, GetDouble, GetFloat, GetGuid, GetInt16, GetInt32, GetInt64, GetString, or GetValue method. If the value of the associated public field of this class is null upon returning from the callback, the null value will only be used if the return type for the SQLiteDataReader method called is not a value type. If the value to be returned from the SQLiteDataReader method is unsuitable (e.g. null with a value type), an exception will be thrown.

For a list of all members of this type, see SQLiteDataReaderValue Members .

System.Object
SQLiteDataReaderValue

public sealed class SQLiteDataReaderValue

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteDataReaderValue Members | System.Data.SQLite Namespace


SQLiteDataReaderValue Members

SQLiteDataReaderValue overview

Public Instance Constructors

SQLiteDataReaderValue Constructor Initializes a new instance of the SQLiteDataReaderValue class.

Public Instance Fields

BlobValue | The value to be returned from the GetBlob method -OR- null to indicate an error.
BooleanValue | The value to be returned from the GetBoolean method -OR- null to indicate an error.
BytesValue | The value to be returned from the GetBytes method.
ByteValue | The value to be returned from the GetByte method -OR- null to indicate an error.
CharsValue | The value to be returned from the GetChars method.
CharValue | The value to be returned from the GetChar method -OR- null to indicate an error.
DateTimeValue | The value to be returned from the GetDateTime method -OR- null to indicate an error.
DecimalValue | The value to be returned from the GetDecimal method -OR- null to indicate an error.
DoubleValue | The value to be returned from the GetDouble method -OR- null to indicate an error.
FloatValue | The value to be returned from the GetFloat method -OR- null to indicate an error.
GuidValue | The value to be returned from the GetGuid method -OR- null to indicate an error.
Int16Value | The value to be returned from the GetInt16 method -OR- null to indicate an error.
Int32Value | The value to be returned from the GetInt32 method -OR- null to indicate an error.
Int64Value | The value to be returned from the GetInt64 method -OR- null to indicate an error.
StringValue | The value to be returned from the GetString method.
Value | The value to be returned from the GetValue method.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue Constructor

Initializes a new instance of the SQLiteDataReaderValue class.

SQLiteDataReaderValue();

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue Fields

The fields of the SQLiteDataReaderValue class are listed below. For a complete list of SQLiteDataReaderValue class members, see the SQLiteDataReaderValue Members topic.

Public Instance Fields

BlobValue | The value to be returned from the GetBlob method -OR- null to indicate an error.
BooleanValue | The value to be returned from the GetBoolean method -OR- null to indicate an error.
BytesValue | The value to be returned from the GetBytes method.
ByteValue | The value to be returned from the GetByte method -OR- null to indicate an error.
CharsValue | The value to be returned from the GetChars method.
CharValue | The value to be returned from the GetChar method -OR- null to indicate an error.
DateTimeValue | The value to be returned from the GetDateTime method -OR- null to indicate an error.
DecimalValue | The value to be returned from the GetDecimal method -OR- null to indicate an error.
DoubleValue | The value to be returned from the GetDouble method -OR- null to indicate an error.
FloatValue | The value to be returned from the GetFloat method -OR- null to indicate an error.
GuidValue | The value to be returned from the GetGuid method -OR- null to indicate an error.
Int16Value | The value to be returned from the GetInt16 method -OR- null to indicate an error.
Int32Value | The value to be returned from the GetInt32 method -OR- null to indicate an error.
Int64Value | The value to be returned from the GetInt64 method -OR- null to indicate an error.
StringValue | The value to be returned from the GetString method.
Value | The value to be returned from the GetValue method.

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.BlobValue Field

The value to be returned from the GetBlob method -OR- null to indicate an error.

public SQLiteBlob BlobValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.BooleanValue Field

The value to be returned from the GetBoolean method -OR- null to indicate an error.

public bool? BooleanValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.BytesValue Field

The value to be returned from the GetBytes method.

public byte[] BytesValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.ByteValue Field

The value to be returned from the GetByte method -OR- null to indicate an error.

public byte? ByteValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.CharsValue Field

The value to be returned from the GetChars method.

public char[] CharsValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.CharValue Field

The value to be returned from the GetChar method -OR- null to indicate an error.

public char? CharValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.DateTimeValue Field

The value to be returned from the GetDateTime method -OR- null to indicate an error.

public DateTime? DateTimeValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.DecimalValue Field

The value to be returned from the GetDecimal method -OR- null to indicate an error.

public decimal? DecimalValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.DoubleValue Field

The value to be returned from the GetDouble method -OR- null to indicate an error.

public double? DoubleValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.FloatValue Field

The value to be returned from the GetFloat method -OR- null to indicate an error.

public float? FloatValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.GuidValue Field

The value to be returned from the GetGuid method -OR- null to indicate an error.

public Guid? GuidValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.Int16Value Field

The value to be returned from the GetInt16 method -OR- null to indicate an error.

public short? Int16Value;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.Int32Value Field

The value to be returned from the GetInt32 method -OR- null to indicate an error.

public int? Int32Value;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.Int64Value Field

The value to be returned from the GetInt64 method -OR- null to indicate an error.

public long? Int64Value;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.StringValue Field

The value to be returned from the GetString method.

public string StringValue;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDataReaderValue.Value Field

The value to be returned from the GetValue method.

public object Value;

See Also

SQLiteDataReaderValue Class | System.Data.SQLite Namespace


SQLiteDateFormats Enumeration

This implementation of SQLite for ADO.NET can process date/time fields in databases in one of six formats.

public enum SQLiteDateFormats

Remarks

ISO8601 format is more compatible, readable, fully-processable, but less accurate as it does not provide time down to fractions of a second. JulianDay is the numeric format the SQLite uses internally and is arguably the most compatible with 3rd party tools. It is not readable as text without post-processing. Ticks less compatible with 3rd party tools that query the database, and renders the DateTime field unreadable as text without post-processing. UnixEpoch is more compatible with Unix systems. InvariantCulture allows the configured format for the invariant culture format to be used and is human readable. CurrentCulture allows the configured format for the current culture to be used and is also human readable. The preferred order of choosing a DateTime format is JulianDay, ISO8601, and then Ticks. Ticks is mainly present for legacy code support.

Members

Member Name | Description
Ticks | Use the value of DateTime.Ticks. This value is not recommended and is not well supported with LINQ.
ISO8601 | Use the ISO-8601 format. Uses the "yyyy-MM-dd HH:mm:ss.FFFFFFFK" format for UTC DateTime values and "yyyy-MM-dd HH:mm:ss.FFFFFFF" format for local DateTime values).
JulianDay | The interval of time in days and fractions of a day since January 1, 4713 BC.
UnixEpoch | The whole number of seconds since the Unix epoch (January 1, 1970).
InvariantCulture | Any culture-independent string value that the .NET Framework can interpret as a valid DateTime.
CurrentCulture | Any string value that the .NET Framework can interpret as a valid DateTime using the current culture.
Default | The default format for this provider.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteDelegateFunction Class

This class implements a SQLite function using a Delegate. All the virtual methods of the SQLiteFunction class are implemented using calls to the SQLiteInvokeDelegate, SQLiteStepDelegate, SQLiteFinalDelegate, and SQLiteCompareDelegate strongly typed delegate types or via the DynamicInvoke method. The arguments are presented in the same order they appear in the associated SQLiteFunction methods with one exception: the first argument is the name of the virtual method being implemented.

For a list of all members of this type, see SQLiteDelegateFunction Members .

System.Object
SQLiteFunction
SQLiteDelegateFunction

public class SQLiteDelegateFunction : SQLiteFunction

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteDelegateFunction Members | System.Data.SQLite Namespace


SQLiteDelegateFunction Members

SQLiteDelegateFunction overview

Public Instance Constructors

SQLiteDelegateFunction Overloaded. Initializes a new instance of the SQLiteDelegateFunction class.

Public Instance Properties

Callback1 | The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods needed by the SQLiteFunction base class.
Callback2 | The Delegate to be used for all calls into the Final virtual methods needed by the SQLiteFunction base class.
Callback3 | The Delegate to be used for all calls into the Value virtual methods needed by the SQLiteFunction base class.
Callback4 | The Delegate to be used for all calls into the Inverse virtual methods needed by the SQLiteFunction base class.
SQLiteConvert (inherited from SQLiteFunction) | Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert strings and DateTime's into the current connection's encoding schema.

Public Instance Methods

Compare | This virtual method is part of the implementation for collating sequences. See the Compare method for more details.
Dispose (inherited from SQLiteFunction) | Overloaded. Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Final | This virtual method is part of the implementation for aggregate functions. See the Final method for more details.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetParameterFromBind (inherited from SQLiteFunction) | Gets and returns the "from bind" flag associated with the specified function parameter.
GetParameterNoChange (inherited from SQLiteFunction) | Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.
GetParameterNumericType (inherited from SQLiteFunction) | Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.
GetParameterSubType (inherited from SQLiteFunction) | Gets and returns the sub-type associated with the specified function parameter.
GetType (inherited from Object) | Gets the Type of the current instance.
Inverse | This virtual method is part of the implementation for aggregate functions. See the Inverse method for more details.
Invoke | This virtual method is the implementation for scalar functions. See the Invoke method for more details.
SetReturnSubType (inherited from SQLiteFunction) | Arranges for the specified sub-type value to be associated with the function result.
Step | This virtual method is part of the implementation for aggregate functions. See the Step method for more details.
ToString (inherited from Object) | Returns a String that represents the current Object.
Value | This virtual method is part of the implementation for aggregate functions. See the Value method for more details.

Protected Instance Methods

Dispose (inherited from SQLiteFunction) | Overloaded. Placeholder for a user-defined disposal routine
Finalize (inherited from SQLiteFunction) | Cleans up resources associated with the current instance.
GetCompareArgs | Returns the list of arguments for the Compare method, as an Array of Object. The first argument is always the literal string "Compare".
GetFinalArgs | Returns the list of arguments for the Final method, as an Array of Object. The first argument is always the literal string "Final".
GetInverseArgs | Returns the list of arguments for the Inverse method, as an Array of Object. The first argument is always the literal string "Inverse".
GetInvokeArgs | Returns the list of arguments for the Invoke method, as an Array of Object. The first argument is always the literal string "Invoke".
GetStepArgs | Returns the list of arguments for the Step method, as an Array of Object. The first argument is always the literal string "Step".
GetValueArgs | Returns the list of arguments for the Value method, as an Array of Object. The first argument is always the literal string "Value".
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
UpdateInverseArgs | Updates the output arguments for the Inverse method, using an Array of Object. The first argument is always the literal string "Inverse". Currently, only the contextData parameter is updated.
UpdateStepArgs | Updates the output arguments for the Step method, using an Array of Object. The first argument is always the literal string "Step". Currently, only the contextData parameter is updated.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction Constructor

Constructs an empty instance of this class.

Overload List

Constructs an empty instance of this class.

public SQLiteDelegateFunction()

Constructs an instance of this class using the specified Delegate as the SQLiteFunction implementation.

public SQLiteDelegateFunction(Delegate,Delegate)

Constructs an instance of this class using the specified Delegate as the SQLiteFunction implementation.

public SQLiteDelegateFunction(Delegate,Delegate,Delegate,Delegate)

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction Constructor

Constructs an empty instance of this class.

SQLiteDelegateFunction();

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace | SQLiteDelegateFunction Constructor Overload List


SQLiteDelegateFunction Constructor

Constructs an instance of this class using the specified Delegate as the SQLiteFunction implementation.

SQLiteDelegateFunction(
Delegate callback1,
Delegate callback2
);

Parameters

callback1
The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods needed by the SQLiteFunction base class.
callback2
The Delegate to be used for all calls into the Final virtual methods needed by the SQLiteFunction base class.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace | SQLiteDelegateFunction Constructor Overload List


SQLiteDelegateFunction Constructor

Constructs an instance of this class using the specified Delegate as the SQLiteFunction implementation.

SQLiteDelegateFunction(
Delegate callback1,
Delegate callback2,
Delegate callback3,
Delegate callback4
);

Parameters

callback1
The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods needed by the SQLiteFunction base class.
callback2
The Delegate to be used for all calls into the Final virtual methods needed by the SQLiteFunction base class.
callback3
The Delegate to be used for all calls into the Value virtual method needed by the SQLiteFunction base class.
callback4
The Delegate to be used for all calls into the Inverse virtual method needed by the SQLiteFunction base class.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace | SQLiteDelegateFunction Constructor Overload List


SQLiteDelegateFunction Properties

The properties of the SQLiteDelegateFunction class are listed below. For a complete list of SQLiteDelegateFunction class members, see the SQLiteDelegateFunction Members topic.

Public Instance Properties

Callback1 | The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods needed by the SQLiteFunction base class.
Callback2 | The Delegate to be used for all calls into the Final virtual methods needed by the SQLiteFunction base class.
Callback3 | The Delegate to be used for all calls into the Value virtual methods needed by the SQLiteFunction base class.
Callback4 | The Delegate to be used for all calls into the Inverse virtual methods needed by the SQLiteFunction base class.
SQLiteConvert (inherited from SQLiteFunction) | Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert strings and DateTime's into the current connection's encoding schema.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


Callback1 Property

SQLite ADO.NET Provider

SQLiteDelegateFunction.Callback1 Property

The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods needed by the SQLiteFunction base class.

public virtual Delegate Callback1 { public get; public set; }

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


Callback2 Property

SQLite ADO.NET Provider

SQLiteDelegateFunction.Callback2 Property

The Delegate to be used for all calls into the Final virtual methods needed by the SQLiteFunction base class.

public virtual Delegate Callback2 { public get; public set; }

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


Callback3 Property

SQLite ADO.NET Provider

SQLiteDelegateFunction.Callback3 Property

The Delegate to be used for all calls into the Value virtual methods needed by the SQLiteFunction base class.

public virtual Delegate Callback3 { public get; public set; }

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


Callback4 Property

SQLite ADO.NET Provider

SQLiteDelegateFunction.Callback4 Property

The Delegate to be used for all calls into the Inverse virtual methods needed by the SQLiteFunction base class.

public virtual Delegate Callback4 { public get; public set; }

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction Methods

The methods of the SQLiteDelegateFunction class are listed below. For a complete list of SQLiteDelegateFunction class members, see the SQLiteDelegateFunction Members topic.

Public Instance Methods

Compare | This virtual method is part of the implementation for collating sequences. See the Compare method for more details.
Dispose (inherited from SQLiteFunction) | Overloaded. Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Final | This virtual method is part of the implementation for aggregate functions. See the Final method for more details.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetParameterFromBind (inherited from SQLiteFunction) | Gets and returns the "from bind" flag associated with the specified function parameter.
GetParameterNoChange (inherited from SQLiteFunction) | Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.
GetParameterNumericType (inherited from SQLiteFunction) | Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.
GetParameterSubType (inherited from SQLiteFunction) | Gets and returns the sub-type associated with the specified function parameter.
GetType (inherited from Object) | Gets the Type of the current instance.
Inverse | This virtual method is part of the implementation for aggregate functions. See the Inverse method for more details.
Invoke | This virtual method is the implementation for scalar functions. See the Invoke method for more details.
SetReturnSubType (inherited from SQLiteFunction) | Arranges for the specified sub-type value to be associated with the function result.
Step | This virtual method is part of the implementation for aggregate functions. See the Step method for more details.
ToString (inherited from Object) | Returns a String that represents the current Object.
Value | This virtual method is part of the implementation for aggregate functions. See the Value method for more details.

Protected Instance Methods

Dispose (inherited from SQLiteFunction) | Overloaded. Placeholder for a user-defined disposal routine
Finalize (inherited from SQLiteFunction) | Cleans up resources associated with the current instance.
GetCompareArgs | Returns the list of arguments for the Compare method, as an Array of Object. The first argument is always the literal string "Compare".
GetFinalArgs | Returns the list of arguments for the Final method, as an Array of Object. The first argument is always the literal string "Final".
GetInverseArgs | Returns the list of arguments for the Inverse method, as an Array of Object. The first argument is always the literal string "Inverse".
GetInvokeArgs | Returns the list of arguments for the Invoke method, as an Array of Object. The first argument is always the literal string "Invoke".
GetStepArgs | Returns the list of arguments for the Step method, as an Array of Object. The first argument is always the literal string "Step".
GetValueArgs | Returns the list of arguments for the Value method, as an Array of Object. The first argument is always the literal string "Value".
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
UpdateInverseArgs | Updates the output arguments for the Inverse method, using an Array of Object. The first argument is always the literal string "Inverse". Currently, only the contextData parameter is updated.
UpdateStepArgs | Updates the output arguments for the Step method, using an Array of Object. The first argument is always the literal string "Step". Currently, only the contextData parameter is updated.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.Compare Method

This virtual method is part of the implementation for collating sequences. See the Compare method for more details.

public override int Compare(
string param1,
string param2
);

Parameters

param1
The first string to compare.
param2
The second strnig to compare.

Return Value

A positive integer if the param1 parameter is greater than the param2 parameter, a negative integer if the param1 parameter is less than the param2 parameter, or zero if they are equal.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.Final Method

This virtual method is part of the implementation for aggregate functions. See the Final method for more details.

public override object Final(
object contextData
);

Parameters

contextData
A placeholder for implementers to store contextual data pertaining to the current context.

Return Value

The result of the aggregate function.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.GetCompareArgs Method

Returns the list of arguments for the Compare method, as an Array of Object. The first argument is always the literal string "Compare".

protected virtual object[] GetCompareArgs(
string param1,
string param2,
bool earlyBound
);

Parameters

param1
The first string to compare.
param2
The second strnig to compare.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteCompareDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.GetFinalArgs Method

Returns the list of arguments for the Final method, as an Array of Object. The first argument is always the literal string "Final".

protected virtual object[] GetFinalArgs(
object contextData,
bool earlyBound
);

Parameters

contextData
A placeholder for implementers to store contextual data pertaining to the current context.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteFinalDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.GetInverseArgs Method

Returns the list of arguments for the Inverse method, as an Array of Object. The first argument is always the literal string "Inverse".

protected virtual object[] GetInverseArgs(
object[] args,
int stepNumber,
object contextData,
bool earlyBound
);

Parameters

args
The original arguments received by the Inverse method.
stepNumber
The step number (one based). This is incrememted each time the Inverse method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteStepDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.GetInvokeArgs Method

Returns the list of arguments for the Invoke method, as an Array of Object. The first argument is always the literal string "Invoke".

protected virtual object[] GetInvokeArgs(
object[] args,
bool earlyBound
);

Parameters

args
The original arguments received by the Invoke method.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteInvokeDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.GetStepArgs Method

Returns the list of arguments for the Step method, as an Array of Object. The first argument is always the literal string "Step".

protected virtual object[] GetStepArgs(
object[] args,
int stepNumber,
object contextData,
bool earlyBound
);

Parameters

args
The original arguments received by the Step method.
stepNumber
The step number (one based). This is incrememted each time the Step method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteStepDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.GetValueArgs Method

Returns the list of arguments for the Value method, as an Array of Object. The first argument is always the literal string "Value".

protected virtual object[] GetValueArgs(
object contextData,
bool earlyBound
);

Parameters

contextData
A placeholder for implementers to store contextual data pertaining to the current context.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteFinalDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.Inverse Method

This virtual method is part of the implementation for aggregate functions. See the Inverse method for more details.

public override void Inverse(
object[] args,
int stepNumber,
ref object contextData
);

Parameters

args
The arguments for the aggregate function.
stepNumber
The step number (one based). This is incrememted each time the Inverse method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.Invoke Method

This virtual method is the implementation for scalar functions. See the Invoke method for more details.

public override object Invoke(
object[] args
);

Parameters

args
The arguments for the scalar function.

Return Value

The result of the scalar function.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.Step Method

This virtual method is part of the implementation for aggregate functions. See the Step method for more details.

public override void Step(
object[] args,
int stepNumber,
ref object contextData
);

Parameters

args
The arguments for the aggregate function.
stepNumber
The step number (one based). This is incrememted each time the Step method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.UpdateInverseArgs Method

Updates the output arguments for the Inverse method, using an Array of Object. The first argument is always the literal string "Inverse". Currently, only the contextData parameter is updated.

protected virtual void UpdateInverseArgs(
object[] args,
ref object contextData,
bool earlyBound
);

Parameters

args
The original arguments received by the Inverse method.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteStepDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.UpdateStepArgs Method

Updates the output arguments for the Step method, using an Array of Object. The first argument is always the literal string "Step". Currently, only the contextData parameter is updated.

protected virtual void UpdateStepArgs(
object[] args,
ref object contextData,
bool earlyBound
);

Parameters

args
The original arguments received by the Step method.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.
earlyBound
Non-zero if the returned arguments are going to be used with the SQLiteStepDelegate type; otherwise, zero.

Return Value

The arguments to pass to the configured Delegate.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteDelegateFunction.Value Method

This virtual method is part of the implementation for aggregate functions. See the Value method for more details.

public override object Value(
object contextData
);

Parameters

contextData
A placeholder for implementers to store contextual data pertaining to the current context.

Return Value

The result of the aggregate function.

See Also

SQLiteDelegateFunction Class | System.Data.SQLite Namespace


SQLiteErrorCode Enumeration

SQLite error codes. Actually, this enumeration represents a return code, which may also indicate success in one of several ways (e.g. SQLITE_OK, SQLITE_ROW, and SQLITE_DONE). Therefore, the name of this enumeration is something of a misnomer.

public enum SQLiteErrorCode

Members

Member Name | Description
Unknown | The error code is unknown. This error code is only used by the managed wrapper itself.
Ok | Successful result
Error | SQL error or missing database
Internal | Internal logic error in SQLite
Perm | Access permission denied
Abort | Callback routine requested an abort
Busy | The database file is locked
Locked | A table in the database is locked
NoMem | A malloc() failed
ReadOnly | Attempt to write a readonly database
Interrupt | Operation terminated by sqlite3_interrupt()
IoErr | Some kind of disk I/O error occurred
Corrupt | The database disk image is malformed
NotFound | Unknown opcode in sqlite3_file_control()
Full | Insertion failed because database is full
CantOpen | Unable to open the database file
Protocol | Database lock protocol error
Empty | Database is empty
Schema | The database schema changed
TooBig | String or BLOB exceeds size limit
Constraint | Abort due to constraint violation
Mismatch | Data type mismatch
Misuse | Library used incorrectly
NoLfs | Uses OS features not supported on host
Auth | Authorization denied
Format | Auxiliary database format error
Range | 2nd parameter to sqlite3_bind out of range
NotADb | File opened that is not a database file
Notice | Notifications from sqlite3_log()
Warning | Warnings from sqlite3_log()
Row | sqlite3_step() has another row ready
Done | sqlite3_step() has finished executing
NonExtendedMask | Used to mask off extended result codes
Error_Missing_CollSeq | A collation sequence was referenced by a schema and it cannot be found.
Error_Retry | An internal operation failed and it may succeed if retried.
Error_Snapshot | The specified snapshot has been overwritten by a checkpoint.
IoErr_Read | A file read operation failed.
IoErr_Short_Read | A file read operation returned less data than requested.
IoErr_Write | A file write operation failed.
IoErr_Fsync | A file synchronization operation failed.
IoErr_Dir_Fsync | A directory synchronization operation failed.
IoErr_Truncate | A file truncate operation failed.
IoErr_Fstat | A file metadata operation failed.
IoErr_Unlock | A file unlock operation failed.
IoErr_RdLock | A file lock operation failed.
IoErr_Delete | A file delete operation failed.
IoErr_Blocked | Not currently used.
IoErr_NoMem | Out-of-memory during a file operation.
IoErr_Access | A file existence/status operation failed.
IoErr_CheckReservedLock | A check for a reserved lock failed.
IoErr_Lock | A file lock operation failed.
IoErr_Close | A file close operation failed.
IoErr_Dir_Close | A directory close operation failed.
IoErr_ShmOpen | A shared memory open operation failed.
IoErr_ShmSize | A shared memory size operation failed.
IoErr_ShmLock | A shared memory lock operation failed.
IoErr_ShmMap | A shared memory map operation failed.
IoErr_Seek | A file seek operation failed.
IoErr_Delete_NoEnt | A file delete operation failed because it does not exist.
IoErr_Mmap | A file memory mapping operation failed.
IoErr_GetTempPath | The temporary directory path could not be obtained.
IoErr_ConvPath | A path string conversion operation failed.
IoErr_VNode | Reserved.
IoErr_Auth | An attempt to authenticate failed.
IoErr_Begin_Atomic | An attempt to begin a file system transaction failed.
IoErr_Commit_Atomic | An attempt to commit a file system transaction failed.
IoErr_Rollback_Atomic | An attempt to rollback a file system transaction failed.
IoErr_Data | Data read from the file system appears to be incorrect.
IoErr_CorruptFs | File system corruption was detected during a read or write.
Locked_SharedCache | A database table is locked in shared-cache mode.
Locked_Vtab | A virtual table in the database is locked.
Busy_Recovery | A database file is locked due to a recovery operation.
Busy_Snapshot | A database file is locked due to snapshot semantics.
Busy_Timeout | An internal timeout was encountered while waiting for a database lock.
CantOpen_NoTempDir | A database file cannot be opened because no temporary directory is available.
CantOpen_IsDir | A database file cannot be opened because its path represents a directory.
CantOpen_FullPath | A database file cannot be opened because its full path could not be obtained.
CantOpen_ConvPath | A database file cannot be opened because a path string conversion operation failed.
CantOpen_DirtyWal | No longer used.
CantOpen_SymLink | A database file is a symbolic link and cannot be opened.
Corrupt_Vtab | A virtual table is malformed.
Corrupt_Sequence | A required sequence table is missing or corrupt.
Corrupt_Index | An index entry that should be present is missing.
ReadOnly_Recovery | A database file is read-only due to a recovery operation.
ReadOnly_CantLock | A database file is read-only because a lock could not be obtained.
ReadOnly_Rollback | A database file is read-only because it needs rollback processing.
ReadOnly_DbMoved | A database file is read-only because it was moved while open.
ReadOnly_CantInit | The shared-memory file is read-only and it should be read-write.
ReadOnly_Directory | Unable to create journal file because the directory is read-only.
Abort_Rollback | An operation is being aborted due to rollback processing.
Constraint_Check | A CHECK constraint failed.
Constraint_CommitHook | A commit hook produced a unsuccessful return code.
Constraint_ForeignKey | A FOREIGN KEY constraint failed.
Constraint_Function | Not currently used.
Constraint_NotNull | A NOT NULL constraint failed.
Constraint_PrimaryKey | A PRIMARY KEY constraint failed.
Constraint_Trigger | The RAISE function was used by a trigger-program.
Constraint_Unique | A UNIQUE constraint failed.
Constraint_Vtab | Not currently used.
Constraint_RowId | A ROWID constraint failed.
Constraint_Pinned | A database cursor is busy and cannot be moved.
Constraint_DataType | Value does not conform to specified data type.
Notice_Recover_Wal | Frames were recovered from the WAL log file.
Notice_Recover_Rollback | Pages were recovered from the journal file.
Notice_Rbu | May be returned for spurious errors that can occur when applying an RBU update.
Warning_AutoIndex | An automatic index was created to process a query.
Auth_User | User authentication failed.
Ok_Load_Permanently | Success. Prevents the extension from unloading until the process terminates.
Ok_SymLink | Success. The specified file name refers to a symbolic link.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteException Class

SQLite exception class.

For a list of all members of this type, see SQLiteException Members .

System.Object
Exception
SystemException
ExternalException
DbException
SQLiteException

public sealed class SQLiteException : DbException

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteException Members | System.Data.SQLite Namespace


SQLiteException Members

SQLiteException overview

Public Instance Constructors

SQLiteException Overloaded. Initializes a new instance of the SQLiteException class.

Public Instance Properties

Data (inherited from Exception) | Gets a collection of key/value pairs that provide additional, user-defined information about the exception.
ErrorCode | Gets the associated SQLite return code for this exception as an Int32. For desktop versions of the .NET Framework, this property overrides the property of the same name within the ExternalException class. This property returns the same underlying value as the ResultCode property.
HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message (inherited from Exception) | Gets a message that describes the current exception.
ResultCode | Gets the associated SQLite result code for this exception as a SQLiteErrorCode. This property returns the same underlying value as the ErrorCode property.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData | Adds extra information to the serialized object data specific to this class type. This is only used for serialization.
GetType (inherited from Exception) | Gets the runtime type of the current instance.
ToString |

Protected Instance Properties

HResult (inherited from Exception) Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteException Class | System.Data.SQLite Namespace


SQLiteException Constructor

Public constructor for generating a SQLite exception given the error code and message.

Overload List

Public constructor that uses the default base class constructor.

public SQLiteException()

Public constructor for generating a SQLite exception given the error code and message.

public SQLiteException(SQLiteErrorCode,string)

Public constructor that uses the base class constructor for the error message.

public SQLiteException(string)

Public constructor that uses the base class constructor for the error message and inner exception.

public SQLiteException(string,Exception)

See Also

SQLiteException Class | System.Data.SQLite Namespace


SQLiteException Constructor

Public constructor for generating a SQLite exception given the error code and message.

SQLiteException(
SQLiteErrorCode errorCode,
string message
);

Parameters

errorCode
The SQLite return code to report.
message
Message text to go along with the return code message text.

See Also

SQLiteException Class | System.Data.SQLite Namespace | SQLiteException Constructor Overload List


SQLiteException Constructor

Public constructor that uses the base class constructor for the error message.

SQLiteException(
string message
);

Parameters

message
Error message text.

See Also

SQLiteException Class | System.Data.SQLite Namespace | SQLiteException Constructor Overload List


SQLiteException Constructor

Public constructor that uses the default base class constructor.

SQLiteException();

See Also

SQLiteException Class | System.Data.SQLite Namespace | SQLiteException Constructor Overload List


SQLiteException Constructor

Public constructor that uses the base class constructor for the error message and inner exception.

SQLiteException(
string message,
Exception innerException
);

Parameters

message
Error message text.
innerException
The original (inner) exception.

See Also

SQLiteException Class | System.Data.SQLite Namespace | SQLiteException Constructor Overload List


SQLiteException Properties

The properties of the SQLiteException class are listed below. For a complete list of SQLiteException class members, see the SQLiteException Members topic.

Public Instance Properties

Data (inherited from Exception) | Gets a collection of key/value pairs that provide additional, user-defined information about the exception.
ErrorCode | Gets the associated SQLite return code for this exception as an Int32. For desktop versions of the .NET Framework, this property overrides the property of the same name within the ExternalException class. This property returns the same underlying value as the ResultCode property.
HelpLink (inherited from Exception) | Gets or sets a link to the help file associated with this exception.
InnerException (inherited from Exception) | Gets the Exception instance that caused the current exception.
Message (inherited from Exception) | Gets a message that describes the current exception.
ResultCode | Gets the associated SQLite result code for this exception as a SQLiteErrorCode. This property returns the same underlying value as the ErrorCode property.
Source (inherited from Exception) | Gets or sets the name of the application or the object that causes the error.
StackTrace (inherited from Exception) | Gets a string representation of the frames on the call stack at the time the current exception was thrown.
TargetSite (inherited from Exception) | Gets the method that throws the current exception.

Protected Instance Properties

HResult (inherited from Exception) Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

See Also

SQLiteException Class | System.Data.SQLite Namespace


ErrorCode Property

SQLite ADO.NET Provider

SQLiteException.ErrorCode Property

Gets the associated SQLite return code for this exception as an Int32. For desktop versions of the .NET Framework, this property overrides the property of the same name within the ExternalException class. This property returns the same underlying value as the ResultCode property.

public override int ErrorCode { public get; }

See Also

SQLiteException Class | System.Data.SQLite Namespace


ResultCode Property

SQLite ADO.NET Provider

SQLiteException.ResultCode Property

Gets the associated SQLite result code for this exception as a SQLiteErrorCode. This property returns the same underlying value as the ErrorCode property.

public SQLiteErrorCode ResultCode { public get; }

See Also

SQLiteException Class | System.Data.SQLite Namespace


SQLiteException Methods

The methods of the SQLiteException class are listed below. For a complete list of SQLiteException class members, see the SQLiteException Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBaseException (inherited from Exception) | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetObjectData | Adds extra information to the serialized object data specific to this class type. This is only used for serialization.
GetType (inherited from Exception) | Gets the runtime type of the current instance.
ToString |

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteException Class | System.Data.SQLite Namespace


SQLiteException.GetObjectData Method

Adds extra information to the serialized object data specific to this class type. This is only used for serialization.

public override void GetObjectData(
SerializationInfo info,
StreamingContext context
);

Parameters

info
Holds the serialized object data about the exception being thrown.
context
Contains contextual information about the source or destination.

Implements

ISerializable.GetObjectData

See Also

SQLiteException Class | System.Data.SQLite Namespace


SQLiteException.ToString Method

public override string ToString();

See Also

SQLiteException Class | System.Data.SQLite Namespace


SQLiteExecuteType Enumeration

The requested command execution type. This controls which method of the SQLiteCommand object will be called.

public enum SQLiteExecuteType

Members

Member Name | Description
None | Do nothing. No method will be called.
NonQuery | The command is not expected to return a result -OR- the result is not needed. The ExecuteNonQuery or ExecuteNonQuery method will be called.
Scalar | The command is expected to return a scalar result -OR- the result should be limited to a scalar result. The ExecuteScalar or ExecuteScalar method will be called.
Reader | The command is expected to return SQLiteDataReader result. The ExecuteReader or ExecuteReader method will be called.
Default | Use the default command execution type. Using this value is the same as using the NonQuery value.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteFactory Class

SQLite implementation of DbProviderFactory.

SQLite implementation of IServiceProvider.

For a list of all members of this type, see SQLiteFactory Members .

System.Object
DbProviderFactory
SQLiteFactory

public sealed class SQLiteFactory : DbProviderFactory, IDisposable, IServiceProvider

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteFactory Members | System.Data.SQLite Namespace


SQLiteFactory Members

SQLiteFactory overview

Public Static Fields

Instance Static instance member which returns an instanced SQLiteFactory class.

Public Instance Constructors

SQLiteFactory Constructor Constructs a new instance.

Public Instance Properties

CanCreateDataSourceEnumerator (inherited from DbProviderFactory) Specifies whether the specific DbProviderFactory supports the DbDataSourceEnumerator class.

Public Instance Methods

CreateCommand | Creates and returns a new SQLiteCommand object.
CreateCommandBuilder | Creates and returns a new SQLiteCommandBuilder object.
CreateConnection | Creates and returns a new SQLiteConnection object.
CreateConnectionStringBuilder | Creates and returns a new SQLiteConnectionStringBuilder object.
CreateDataAdapter | Creates and returns a new SQLiteDataAdapter object.
CreateDataSourceEnumerator (inherited from DbProviderFactory) | Returns a new instance of the provider's class that implements the DbDataSourceEnumerator class.
CreateParameter | Creates and returns a new SQLiteParameter object.
CreatePermission (inherited from DbProviderFactory) | Returns a new instance of the provider's class that implements the provider's version of the CodeAccessPermission class.
Dispose | Cleans up resources (native and managed) associated with the current instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Public Instance Events

Log This event is raised whenever SQLite raises a logging event. Note that this should be set as one of the first things in the application. This event is provided for backward compatibility only. New code should use the SQLiteLog class instead.

Protected Instance Methods

Finalize | Cleans up resources associated with the current instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory Constructor

Constructs a new instance.

SQLiteFactory();

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory Fields

The fields of the SQLiteFactory class are listed below. For a complete list of SQLiteFactory class members, see the SQLiteFactory Members topic.

Public Static Fields

Instance Static instance member which returns an instanced SQLiteFactory class.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.Instance Field

Static instance member which returns an instanced SQLiteFactory class.

public static readonly SQLiteFactory Instance;

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory Methods

The methods of the SQLiteFactory class are listed below. For a complete list of SQLiteFactory class members, see the SQLiteFactory Members topic.

Public Instance Methods

CreateCommand | Creates and returns a new SQLiteCommand object.
CreateCommandBuilder | Creates and returns a new SQLiteCommandBuilder object.
CreateConnection | Creates and returns a new SQLiteConnection object.
CreateConnectionStringBuilder | Creates and returns a new SQLiteConnectionStringBuilder object.
CreateDataAdapter | Creates and returns a new SQLiteDataAdapter object.
CreateDataSourceEnumerator (inherited from DbProviderFactory) | Returns a new instance of the provider's class that implements the DbDataSourceEnumerator class.
CreateParameter | Creates and returns a new SQLiteParameter object.
CreatePermission (inherited from DbProviderFactory) | Returns a new instance of the provider's class that implements the provider's version of the CodeAccessPermission class.
Dispose | Cleans up resources (native and managed) associated with the current instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize | Cleans up resources associated with the current instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.CreateCommand Method

Creates and returns a new SQLiteCommand object.

public override DbCommand CreateCommand();

Return Value

The new object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.CreateCommandBuilder Method

Creates and returns a new SQLiteCommandBuilder object.

public override DbCommandBuilder CreateCommandBuilder();

Return Value

The new object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.CreateConnection Method

Creates and returns a new SQLiteConnection object.

public override DbConnection CreateConnection();

Return Value

The new object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.CreateConnectionStringBuilder Method

Creates and returns a new SQLiteConnectionStringBuilder object.

public override DbConnectionStringBuilder CreateConnectionStringBuilder();

Return Value

The new object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.CreateDataAdapter Method

Creates and returns a new SQLiteDataAdapter object.

public override DbDataAdapter CreateDataAdapter();

Return Value

The new object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.CreateParameter Method

Creates and returns a new SQLiteParameter object.

public override DbParameter CreateParameter();

Return Value

The new object.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.Dispose Method

Cleans up resources (native and managed) associated with the current instance.

public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.Finalize Method

Cleans up resources associated with the current instance.

protected override void Finalize();

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory Events

The events of the SQLiteFactory class are listed below. For a complete list of SQLiteFactory class members, see the SQLiteFactory Members topic.

Public Instance Events

Log This event is raised whenever SQLite raises a logging event. Note that this should be set as one of the first things in the application. This event is provided for backward compatibility only. New code should use the SQLiteLog class instead.

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFactory.Log Event

This event is raised whenever SQLite raises a logging event. Note that this should be set as one of the first things in the application. This event is provided for backward compatibility only. New code should use the SQLiteLog class instead.

public event SQLiteLogEventHandler Log;

See Also

SQLiteFactory Class | System.Data.SQLite Namespace


SQLiteFinalDelegate Delegate

This Delegate type is used with the Final method.

public delegate object SQLiteFinalDelegate(
string param0,
object contextData
);

Parameters

param0
This is always the string literal "Final".
contextData
A placeholder for implementers to store contextual data pertaining to the current context.

Return Value

The result of the aggregate function.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteFunction Class

This abstract class is designed to handle user-defined functions easily. An instance of the derived class is made for each connection to the database.

For a list of all members of this type, see SQLiteFunction Members .

System.Object
SQLiteFunction
SQLiteDelegateFunction
SQLiteFunctionEx

public abstract class SQLiteFunction : IDisposable

Remarks

Although there is one instance of a class derived from SQLiteFunction per database connection, the derived class has no access to the underlying connection. This is necessary to deter implementers from thinking it would be a good idea to make database calls during processing. It is important to distinguish between a per-connection instance, and a per-SQL statement context. One instance of this class services all SQL statements being stepped through on that connection, and there can be many. One should never store per-statement information in member variables of user-defined function classes. For aggregate functions, always create and store your per-statement data in the contextData object on the 1st step. This data will be automatically freed for you (and Dispose() called if the item supports IDisposable) when the statement completes.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteFunction Members | System.Data.SQLite Namespace


SQLiteFunction Members

SQLiteFunction overview

Public Static Methods

RegisterFunction Overloaded. Manual method of registering a function. The type must still have the SQLiteFunctionAttributes in order to work properly, but this is a workaround for the Compact Framework where enumerating assemblies is not currently supported.

Public Instance Properties

SQLiteConvert Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert strings and DateTime's into the current connection's encoding schema.

Public Instance Methods

Compare | User-defined collating sequences override this method to provide a custom string sorting algorithm.
Dispose | Overloaded. Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Final | Aggregate functions override this method to finish their aggregate processing.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetParameterFromBind | Gets and returns the "from bind" flag associated with the specified function parameter.
GetParameterNoChange | Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.
GetParameterNumericType | Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.
GetParameterSubType | Gets and returns the sub-type associated with the specified function parameter.
GetType (inherited from Object) | Gets the Type of the current instance.
Inverse | This method is only required for window aggregate functions, not legacy aggregate function implementations. It is invoked to remove the oldest presently aggregated result of xStep from the current window. The function arguments, if any, are those passed to xStep for the row being removed.
Invoke | Scalar functions override this method to do their magic.
SetReturnSubType | Arranges for the specified sub-type value to be associated with the function result.
Step | Aggregate functions override this method to do their magic.
ToString (inherited from Object) | Returns a String that represents the current Object.
Value | This method is only required window aggregate functions, not legacy aggregate function implementations. It is invoked to return the current value of the aggregate. Unlike xFinal, the implementation should not delete any context.

Protected Instance Constructors

SQLiteFunction Overloaded. Initializes a new instance of the SQLiteFunction class.

Protected Instance Methods

Dispose | Overloaded. Placeholder for a user-defined disposal routine
Finalize | Cleans up resources associated with the current instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction Constructor

Internal constructor, initializes the function's internal variables.

Overload List

Internal constructor, initializes the function's internal variables.

protected SQLiteFunction()

Constructs an instance of this class using the specified data-type conversion parameters.

protected SQLiteFunction(SQLiteDateFormats,DateTimeKind,string,bool)

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction Constructor

Internal constructor, initializes the function's internal variables.

SQLiteFunction();

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction Constructor Overload List


SQLiteFunction Constructor

Constructs an instance of this class using the specified data-type conversion parameters.

SQLiteFunction(
SQLiteDateFormats format,
DateTimeKind kind,
string formatString,
bool utf16
);

Parameters

format
The DateTime format to be used when converting string values to a DateTime and binding DateTime parameters.
kind
The DateTimeKind to be used when creating DateTime values.
formatString
The format string to be used when parsing and formatting DateTime values.
utf16
Non-zero to create a UTF-16 data-type conversion context; otherwise, a UTF-8 data-type conversion context will be created.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction Constructor Overload List


SQLiteFunction Properties

The properties of the SQLiteFunction class are listed below. For a complete list of SQLiteFunction class members, see the SQLiteFunction Members topic.

Public Instance Properties

SQLiteConvert Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert strings and DateTime's into the current connection's encoding schema.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteConvert Property

SQLite ADO.NET Provider

SQLiteFunction.SQLiteConvert Property

Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert strings and DateTime's into the current connection's encoding schema.

public SQLiteConvert SQLiteConvert { public get; }

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction Methods

The methods of the SQLiteFunction class are listed below. For a complete list of SQLiteFunction class members, see the SQLiteFunction Members topic.

Public Static Methods

RegisterFunction Overloaded. Manual method of registering a function. The type must still have the SQLiteFunctionAttributes in order to work properly, but this is a workaround for the Compact Framework where enumerating assemblies is not currently supported.

Public Instance Methods

Compare | User-defined collating sequences override this method to provide a custom string sorting algorithm.
Dispose | Overloaded. Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Final | Aggregate functions override this method to finish their aggregate processing.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetParameterFromBind | Gets and returns the "from bind" flag associated with the specified function parameter.
GetParameterNoChange | Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.
GetParameterNumericType | Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.
GetParameterSubType | Gets and returns the sub-type associated with the specified function parameter.
GetType (inherited from Object) | Gets the Type of the current instance.
Inverse | This method is only required for window aggregate functions, not legacy aggregate function implementations. It is invoked to remove the oldest presently aggregated result of xStep from the current window. The function arguments, if any, are those passed to xStep for the row being removed.
Invoke | Scalar functions override this method to do their magic.
SetReturnSubType | Arranges for the specified sub-type value to be associated with the function result.
Step | Aggregate functions override this method to do their magic.
ToString (inherited from Object) | Returns a String that represents the current Object.
Value | This method is only required window aggregate functions, not legacy aggregate function implementations. It is invoked to return the current value of the aggregate. Unlike xFinal, the implementation should not delete any context.

Protected Instance Methods

Dispose | Overloaded. Placeholder for a user-defined disposal routine
Finalize | Cleans up resources associated with the current instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Compare Method

User-defined collating sequences override this method to provide a custom string sorting algorithm.

public virtual int Compare(
string param1,
string param2
);

Parameters

param1
The first string to compare.
param2
The second strnig to compare.

Return Value

1 if param1 is greater than param2, 0 if they are equal, or -1 if param1 is less than param2.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteFunction.Dispose Method

Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.

Overload List

Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.

public void Dispose()

Placeholder for a user-defined disposal routine

protected virtual void Dispose(bool)

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Dispose() Method

Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.

public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction.Dispose Overload List


SQLiteFunction.Dispose(Boolean) Method

Placeholder for a user-defined disposal routine

protected virtual void Dispose(
bool disposing
);

Parameters

disposing
True if the object is being disposed explicitly

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction.Dispose Overload List


SQLiteFunction.Final Method

Aggregate functions override this method to finish their aggregate processing.

public virtual object Final(
object contextData
);

Parameters

contextData
Your own assigned contextData, provided for you so you can return your final results.

Return Value

You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, just return it!

Remarks

If you implemented your aggregate function properly, you've been recording and keeping track of your data in the contextData object provided, and now at this stage you should have all the information you need in there to figure out what to return. NOTE: It is possible to arrive here without receiving a previous call to Step(), in which case the contextData will be null. This can happen when no rows were returned. You can either return null, or 0 or some other custom return value if that is the case.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Finalize Method

Cleans up resources associated with the current instance.

protected override void Finalize();

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.GetParameterFromBind Method

Gets and returns the "from bind" flag associated with the specified function parameter.

public int GetParameterFromBind(
int index
);

Parameters

index
The parameter index to check.

Return Value

Non-zero if the function parameter at the specified index was originally specified via a bound parameter.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.GetParameterNoChange Method

Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.

public int GetParameterNoChange(
int index
);

Parameters

index
The parameter index to check.

Return Value

Non-zero if the column associated with the function parameter is unchanged in an UPDATE against a virtual table.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.GetParameterNumericType Method

Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.

public TypeAffinity GetParameterNumericType(
int index
);

Parameters

index
The parameter index to check.

Return Value

The new type affinity associated with this value.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.GetParameterSubType Method

Gets and returns the sub-type associated with the specified function parameter.

public uint GetParameterSubType(
int index
);

Parameters

index
The parameter index to check.

Return Value

The sub-type associated with the specified function parameter.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Inverse Method

This method is only required for window aggregate functions, not legacy aggregate function implementations. It is invoked to remove the oldest presently aggregated result of xStep from the current window. The function arguments, if any, are those passed to xStep for the row being removed.

public virtual void Inverse(
object[] args,
int stepNumber,
ref object contextData
);

Parameters

args
The arguments for the command to process
stepNumber
The 1-based step number. This is incrememted each time the step method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Invoke Method

Scalar functions override this method to do their magic.

public virtual object Invoke(
object[] args
);

Parameters

args
The arguments for the command to process

Return Value

You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, just return it!

Remarks

Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available to force them into a certain type. Therefore the only types you will ever see as parameters are DBNull.Value, Int64, Double, String or byte[] array.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


RegisterFunction Method

SQLite ADO.NET Provider

SQLiteFunction.RegisterFunction Method

Alternative method of registering a function. This method does not require the specified type to be annotated with SQLiteFunctionAttribute.

Overload List

Alternative method of registering a function. This method does not require the specified type to be annotated with SQLiteFunctionAttribute.

public static void RegisterFunction(string,int,FunctionType,SQLiteFunctionFlags,Type,Delegate,Delegate,Delegate,Delegate)

Alternative method of registering a function. This method does not require the specified type to be annotated with SQLiteFunctionAttribute.

public static void RegisterFunction(string,int,FunctionType,Type,Delegate,Delegate)

Manual method of registering a function. The type must still have the SQLiteFunctionAttributes in order to work properly, but this is a workaround for the Compact Framework where enumerating assemblies is not currently supported.

public static void RegisterFunction(Type)

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.RegisterFunction(String, Int32, FunctionType, SQLiteFunctionFlags, Type, Delegate, Delegate, Delegate, Delegate) Method

Alternative method of registering a function. This method does not require the specified type to be annotated with SQLiteFunctionAttribute.

public static void RegisterFunction(
string name,
int argumentCount,
FunctionType functionType,
SQLiteFunctionFlags functionFlags,
Type instanceType,
Delegate callback1,
Delegate callback2,
Delegate callback3,
Delegate callback4
);

Parameters

name
The name of the function to register.
argumentCount
The number of arguments accepted by the function.
functionType
The type of SQLite function being registered (e.g. scalar, aggregate, or collating sequence).
functionFlags
The extra flags for the function being registered.
instanceType
The Type that actually implements the function. This will only be used if the callback1 and callback2 parameters are null.
callback1
The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods.
callback2
The Delegate to be used for all calls into the Final virtual method. This parameter is only necessary for aggregate functions.
callback3
The Delegate to be used for all calls into the Value virtual method. This parameter is only necessary for window functions.
callback4
The Delegate to be used for all calls into the Inverse virtual method. This parameter is only necessary for window functions.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction.RegisterFunction Overload List


SQLiteFunction.RegisterFunction(String, Int32, FunctionType, Type, Delegate, Delegate) Method

Alternative method of registering a function. This method does not require the specified type to be annotated with SQLiteFunctionAttribute.

public static void RegisterFunction(
string name,
int argumentCount,
FunctionType functionType,
Type instanceType,
Delegate callback1,
Delegate callback2
);

Parameters

name
The name of the function to register.
argumentCount
The number of arguments accepted by the function.
functionType
The type of SQLite function being registered (e.g. scalar, aggregate, or collating sequence).
instanceType
The Type that actually implements the function. This will only be used if the callback1 and callback2 parameters are null.
callback1
The Delegate to be used for all calls into the Invoke, Step, and Compare virtual methods.
callback2
The Delegate to be used for all calls into the Final virtual method. This parameter is only necessary for aggregate functions.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction.RegisterFunction Overload List


SQLiteFunction.RegisterFunction(Type) Method

Manual method of registering a function. The type must still have the SQLiteFunctionAttributes in order to work properly, but this is a workaround for the Compact Framework where enumerating assemblies is not currently supported.

public static void RegisterFunction(
Type typ
);

Parameters

typ
The type of the function to register

See Also

SQLiteFunction Class | System.Data.SQLite Namespace | SQLiteFunction.RegisterFunction Overload List


SQLiteFunction.SetReturnSubType Method

Arranges for the specified sub-type value to be associated with the function result.

public void SetReturnSubType(
uint value
);

Parameters

value
The desired sub-type of the function result.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Step Method

Aggregate functions override this method to do their magic.

public virtual void Step(
object[] args,
int stepNumber,
ref object contextData
);

Parameters

args
The arguments for the command to process
stepNumber
The 1-based step number. This is incrememted each time the step method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.

Remarks

Typically you'll be updating whatever you've placed in the contextData field and returning as quickly as possible.

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunction.Value Method

This method is only required window aggregate functions, not legacy aggregate function implementations. It is invoked to return the current value of the aggregate. Unlike xFinal, the implementation should not delete any context.

public virtual object Value(
object contextData
);

Parameters

contextData
Your own assigned contextData, provided for you so you can return your final results.

Return Value

You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, just return it!

See Also

SQLiteFunction Class | System.Data.SQLite Namespace


SQLiteFunctionAttribute Class

A simple custom attribute to enable us to easily find user-defined functions in the loaded assemblies and initialize them in SQLite as connections are made.

For a list of all members of this type, see SQLiteFunctionAttribute Members .

System.Object
Attribute
SQLiteFunctionAttribute

public sealed class SQLiteFunctionAttribute : Attribute

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteFunctionAttribute Members | System.Data.SQLite Namespace


SQLiteFunctionAttribute Members

SQLiteFunctionAttribute overview

Public Instance Constructors

SQLiteFunctionAttribute Overloaded. Initializes a new instance of the SQLiteFunctionAttribute class.

Public Instance Properties

Arguments | The number of arguments this function expects. -1 if the number of arguments is variable.
FuncFlags | The flags for this function.
FuncType | The type of function this implementation will be.
Name | The function's name as it will be used in SQLite command text.
TypeId (inherited from Attribute) | When implemented in a derived class, gets a unique identifier for this Attribute.

Public Instance Methods

Equals (inherited from Attribute) | Returns a value that indicates whether this instance is equal to a specified object.
GetHashCode (inherited from Attribute) | Returns the hash code for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
IsDefaultAttribute (inherited from Attribute) | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
Match (inherited from Attribute) | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


SQLiteFunctionAttribute Constructor

Default constructor, initializes the internal variables for the function.

Overload List

Default constructor, initializes the internal variables for the function.

public SQLiteFunctionAttribute()

Constructs an instance of this class. This sets the initial InstanceType, Callback1, and Callback2 properties to null.

public SQLiteFunctionAttribute(string,int,FunctionType)

Constructs an instance of this class. This sets the initial InstanceType, Callback1, and Callback2 properties to null.

public SQLiteFunctionAttribute(string,int,FunctionType,SQLiteFunctionFlags)

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


SQLiteFunctionAttribute Constructor

Default constructor, initializes the internal variables for the function.

SQLiteFunctionAttribute();

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace | SQLiteFunctionAttribute Constructor Overload List


SQLiteFunctionAttribute Constructor

Constructs an instance of this class. This sets the initial InstanceType, Callback1, and Callback2 properties to null.

SQLiteFunctionAttribute(
string name,
int argumentCount,
FunctionType functionType
);

Parameters

name
The name of the function, as seen by the SQLite core library.
argumentCount
The number of arguments that the function will accept.
functionType
The type of function being declared. This will either be Scalar, Aggregate, or Collation.

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace | SQLiteFunctionAttribute Constructor Overload List


SQLiteFunctionAttribute Constructor

Constructs an instance of this class. This sets the initial InstanceType, Callback1, and Callback2 properties to null.

SQLiteFunctionAttribute(
string name,
int argumentCount,
FunctionType functionType,
SQLiteFunctionFlags functionFlags
);

Parameters

name
The name of the function, as seen by the SQLite core library.
argumentCount
The number of arguments that the function will accept.
functionType
The type of function being declared. This will either be Scalar, Aggregate, or Collation.
functionFlags
The extra flags for the function being declared.

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace | SQLiteFunctionAttribute Constructor Overload List


SQLiteFunctionAttribute Properties

The properties of the SQLiteFunctionAttribute class are listed below. For a complete list of SQLiteFunctionAttribute class members, see the SQLiteFunctionAttribute Members topic.

Public Instance Properties

Arguments | The number of arguments this function expects. -1 if the number of arguments is variable.
FuncFlags | The flags for this function.
FuncType | The type of function this implementation will be.
Name | The function's name as it will be used in SQLite command text.
TypeId (inherited from Attribute) | When implemented in a derived class, gets a unique identifier for this Attribute.

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


Arguments Property

SQLite ADO.NET Provider

SQLiteFunctionAttribute.Arguments Property

The number of arguments this function expects. -1 if the number of arguments is variable.

public int Arguments { public get; public set; }

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


FuncFlags Property

SQLite ADO.NET Provider

SQLiteFunctionAttribute.FuncFlags Property

The flags for this function.

public SQLiteFunctionFlags FuncFlags { public get; public set; }

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


FuncType Property

SQLite ADO.NET Provider

SQLiteFunctionAttribute.FuncType Property

The type of function this implementation will be.

public FunctionType FuncType { public get; public set; }

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


Name Property

SQLite ADO.NET Provider

SQLiteFunctionAttribute.Name Property

The function's name as it will be used in SQLite command text.

public string Name { public get; public set; }

See Also

SQLiteFunctionAttribute Class | System.Data.SQLite Namespace


SQLiteFunctionEx Class

Extends SQLiteFunction and allows an inherited class to obtain the collating sequence associated with a function call.

For a list of all members of this type, see SQLiteFunctionEx Members .

System.Object
SQLiteFunction
SQLiteFunctionEx

public class SQLiteFunctionEx : SQLiteFunction

Remarks

User-defined functions can call the GetCollationSequence() method in this class and use it to compare strings and char arrays.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteFunctionEx Members | System.Data.SQLite Namespace


SQLiteFunctionEx Members

SQLiteFunctionEx overview

Public Instance Constructors

SQLiteFunctionEx Constructor Initializes a new instance of the SQLiteFunctionEx class.

Public Instance Properties

SQLiteConvert (inherited from SQLiteFunction) Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert strings and DateTime's into the current connection's encoding schema.

Public Instance Methods

Compare (inherited from SQLiteFunction) | User-defined collating sequences override this method to provide a custom string sorting algorithm.
Dispose (inherited from SQLiteFunction) | Overloaded. Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Final (inherited from SQLiteFunction) | Aggregate functions override this method to finish their aggregate processing.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetParameterFromBind (inherited from SQLiteFunction) | Gets and returns the "from bind" flag associated with the specified function parameter.
GetParameterNoChange (inherited from SQLiteFunction) | Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.
GetParameterNumericType (inherited from SQLiteFunction) | Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.
GetParameterSubType (inherited from SQLiteFunction) | Gets and returns the sub-type associated with the specified function parameter.
GetType (inherited from Object) | Gets the Type of the current instance.
Inverse (inherited from SQLiteFunction) | This method is only required for window aggregate functions, not legacy aggregate function implementations. It is invoked to remove the oldest presently aggregated result of xStep from the current window. The function arguments, if any, are those passed to xStep for the row being removed.
Invoke (inherited from SQLiteFunction) | Scalar functions override this method to do their magic.
SetReturnSubType (inherited from SQLiteFunction) | Arranges for the specified sub-type value to be associated with the function result.
Step (inherited from SQLiteFunction) | Aggregate functions override this method to do their magic.
ToString (inherited from Object) | Returns a String that represents the current Object.
Value (inherited from SQLiteFunction) | This method is only required window aggregate functions, not legacy aggregate function implementations. It is invoked to return the current value of the aggregate. Unlike xFinal, the implementation should not delete any context.

Protected Instance Methods

Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
Finalize (inherited from SQLiteFunction) | Cleans up resources associated with the current instance.
GetCollationSequence | Obtains the collating sequence in effect for the given function.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFunctionEx Class | System.Data.SQLite Namespace


SQLiteFunctionEx Constructor

Initializes a new instance of the SQLiteFunctionEx class.

SQLiteFunctionEx();

See Also

SQLiteFunctionEx Class | System.Data.SQLite Namespace


SQLiteFunctionEx Methods

The methods of the SQLiteFunctionEx class are listed below. For a complete list of SQLiteFunctionEx class members, see the SQLiteFunctionEx Members topic.

Public Instance Methods

Compare (inherited from SQLiteFunction) | User-defined collating sequences override this method to provide a custom string sorting algorithm.
Dispose (inherited from SQLiteFunction) | Overloaded. Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if someone closes the connection while a DataReader is open.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Final (inherited from SQLiteFunction) | Aggregate functions override this method to finish their aggregate processing.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetParameterFromBind (inherited from SQLiteFunction) | Gets and returns the "from bind" flag associated with the specified function parameter.
GetParameterNoChange (inherited from SQLiteFunction) | Gets and returns the "no change" flag associated with the specified function parameter. This method can only be used while within a call to the xUpdate method of a virtual table implementation.
GetParameterNumericType (inherited from SQLiteFunction) | Attempts to convert the specified function parameter to numeric and then gets and returns the new type affinity associated with this value.
GetParameterSubType (inherited from SQLiteFunction) | Gets and returns the sub-type associated with the specified function parameter.
GetType (inherited from Object) | Gets the Type of the current instance.
Inverse (inherited from SQLiteFunction) | This method is only required for window aggregate functions, not legacy aggregate function implementations. It is invoked to remove the oldest presently aggregated result of xStep from the current window. The function arguments, if any, are those passed to xStep for the row being removed.
Invoke (inherited from SQLiteFunction) | Scalar functions override this method to do their magic.
SetReturnSubType (inherited from SQLiteFunction) | Arranges for the specified sub-type value to be associated with the function result.
Step (inherited from SQLiteFunction) | Aggregate functions override this method to do their magic.
ToString (inherited from Object) | Returns a String that represents the current Object.
Value (inherited from SQLiteFunction) | This method is only required window aggregate functions, not legacy aggregate function implementations. It is invoked to return the current value of the aggregate. Unlike xFinal, the implementation should not delete any context.

Protected Instance Methods

Dispose | Overloaded. Cleans up resources (native and managed) associated with the current instance.
Finalize (inherited from SQLiteFunction) | Cleans up resources associated with the current instance.
GetCollationSequence | Obtains the collating sequence in effect for the given function.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteFunctionEx Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteFunctionEx.Dispose Method

Cleans up resources (native and managed) associated with the current instance.

Overload List

Inherited from SQLiteFunction.

public void Dispose()

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(bool)

See Also

SQLiteFunctionEx Class | System.Data.SQLite Namespace


SQLiteFunctionEx.Dispose(Boolean) Method

Cleans up resources (native and managed) associated with the current instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Zero when being disposed via garbage collection; otherwise, non-zero.

See Also

SQLiteFunctionEx Class | System.Data.SQLite Namespace | SQLiteFunctionEx.Dispose Overload List


SQLiteFunctionEx.GetCollationSequence Method

Obtains the collating sequence in effect for the given function.

protected CollationSequence GetCollationSequence();

Return Value

See Also

SQLiteFunctionEx Class | System.Data.SQLite Namespace


SQLiteFunctionFlags Enumeration

These constants are used with the sqlite3_create_function() API, et al.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum SQLiteFunctionFlags

Members

Member Name | Description | Value
NONE | Initial flags value, no flags set. | 0
SQLITE_UTF8 | The function uses UTF-8. | 1
SQLITE_UTF16LE | The function uses little-endian UTF-16. | 2
SQLITE_UTF16BE | The function uses big-endian UTF-16. | 3
SQLITE_UTF16 | The function uses UTF-16 in native byte order. | 4
SQLITE_ANY | Deprecated, do not use. | 5
SQLITE_UTF16_ALIGNED | For sqlite3_create_collation() only, do not use. | 8
ENCODING_MASK | Used to mask off the flags related to encodings. | 15
SQLITE_DETERMINISTIC | The new function always gives the same output when the input parameters are the same. The abs() function is deterministic, for example, but randomblob() is not. Functions must be deterministic in order to be used in certain contexts such as with the WHERE clause of partial indexes or in generated columns. SQLite might also optimize deterministic functions by factoring them out of inner loops. | 2048
SQLITE_DIRECTONLY | The function may only be invoked from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in schema structures such as CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, or generated columns. The SQLITE_DIRECTONLY flags is a security feature which is recommended for all application-defined SQL functions, and especially for functions that have side-effects or that could potentially leak sensitive information. | 524288
SQLITE_SUBTYPE | The function may call sqlite3_value_subtype() to inspect the sub-types of its arguments. Specifying this flag makes no difference for scalar or aggregate user functions. However, if it is not specified for a user-defined window function, then any sub-types belonging to arguments passed to the window function may be discarded before the window function is called (i.e. sqlite3_value_subtype() will always return 0). | 1048576
SQLITE_INNOCUOUS | The function is unlikely to cause problems even if misused. An innocuous function should have no side effects and should not depend on any values other than its input parameters. The abs() function is an example of an innocuous function. The load_extension() SQL function is not innocuous because of its side effects. SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not exactly the same. The random() function is an example of a function that is innocuous but not deterministic. Some heightened security settings (SQLITE_DBCONFIG_TRUSTED_SCHEMA and PRAGMA trusted_schema=OFF) disable the use of SQL functions inside views and triggers and in schema structures such as CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, and generated columns unless the function is tagged with SQLITE_INNOCUOUS. Most built-in functions are innocuous. Developers are advised to avoid using the SQLITE_INNOCUOUS flag for application-defined functions unless the function has been carefully audited and found to be free of potentially security-adverse side-effects and information-leaks. | 2097152

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteIndex Class

This class represents the various inputs and outputs used with the BestIndex method.

For a list of all members of this type, see SQLiteIndex Members .

System.Object
SQLiteIndex

public sealed class SQLiteIndex

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteIndex Members | System.Data.SQLite Namespace


SQLiteIndex Members

SQLiteIndex overview

Public Instance Properties

Inputs | The SQLiteIndexInputs object instance containing the inputs to the BestIndex method.
Outputs | The SQLiteIndexOutputs object instance containing the outputs from the BestIndex method.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndex Class | System.Data.SQLite Namespace


SQLiteIndex Properties

The properties of the SQLiteIndex class are listed below. For a complete list of SQLiteIndex class members, see the SQLiteIndex Members topic.

Public Instance Properties

Inputs | The SQLiteIndexInputs object instance containing the inputs to the BestIndex method.
Outputs | The SQLiteIndexOutputs object instance containing the outputs from the BestIndex method.

See Also

SQLiteIndex Class | System.Data.SQLite Namespace


Inputs Property

SQLite ADO.NET Provider

SQLiteIndex.Inputs Property

The SQLiteIndexInputs object instance containing the inputs to the BestIndex method.

public SQLiteIndexInputs Inputs { public get; }

See Also

SQLiteIndex Class | System.Data.SQLite Namespace


Outputs Property

SQLite ADO.NET Provider

SQLiteIndex.Outputs Property

The SQLiteIndexOutputs object instance containing the outputs from the BestIndex method.

public SQLiteIndexOutputs Outputs { public get; }

See Also

SQLiteIndex Class | System.Data.SQLite Namespace


SQLiteIndexConstraint Class

This class represents the native sqlite3_index_constraint structure from the SQLite core library.

For a list of all members of this type, see SQLiteIndexConstraint Members .

System.Object
SQLiteIndexConstraint

public sealed class SQLiteIndexConstraint

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteIndexConstraint Members | System.Data.SQLite Namespace


SQLiteIndexConstraint Members

SQLiteIndexConstraint overview

Public Instance Fields

iColumn | Column on left-hand side of constraint.
iTermOffset | Used internally - BestIndex should ignore.
op | Constraint operator (SQLiteIndexConstraintOp).
usable | True if this constraint is usable.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndexConstraint Class | System.Data.SQLite Namespace


SQLiteIndexConstraint Fields

The fields of the SQLiteIndexConstraint class are listed below. For a complete list of SQLiteIndexConstraint class members, see the SQLiteIndexConstraint Members topic.

Public Instance Fields

iColumn | Column on left-hand side of constraint.
iTermOffset | Used internally - BestIndex should ignore.
op | Constraint operator (SQLiteIndexConstraintOp).
usable | True if this constraint is usable.

See Also

SQLiteIndexConstraint Class | System.Data.SQLite Namespace


SQLiteIndexConstraint.iColumn Field

Column on left-hand side of constraint.

public int iColumn;

See Also

SQLiteIndexConstraint Class | System.Data.SQLite Namespace


SQLiteIndexConstraint.iTermOffset Field

Used internally - BestIndex should ignore.

public int iTermOffset;

See Also

SQLiteIndexConstraint Class | System.Data.SQLite Namespace


SQLiteIndexConstraint.op Field

Constraint operator (SQLiteIndexConstraintOp).

public SQLiteIndexConstraintOp op;

See Also

SQLiteIndexConstraint Class | System.Data.SQLite Namespace


SQLiteIndexConstraint.usable Field

True if this constraint is usable.

public byte usable;

See Also

SQLiteIndexConstraint Class | System.Data.SQLite Namespace


SQLiteIndexConstraintOp Enumeration

These are the allowed values for the operators that are part of a constraint term in the WHERE clause of a query that uses a virtual table.

public enum SQLiteIndexConstraintOp : byte

Members

Member Name | Description
EqualTo | This value represents the equality operator.
GreaterThan | This value represents the greater than operator.
LessThanOrEqualTo | This value represents the less than or equal to operator.
LessThan | This value represents the less than operator.
GreaterThanOrEqualTo | This value represents the greater than or equal to operator.
Match | This value represents the MATCH operator.
Like | This value represents the LIKE operator.
Glob | This value represents the GLOB operator.
Regexp | This value represents the REGEXP operator.
NotEqualTo | This value represents the inequality operator.
IsNot | This value represents the IS NOT operator.
IsNotNull | This value represents the IS NOT NULL operator.
IsNull | This value represents the IS NULL operator.
Is | This value represents the IS operator.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteIndexConstraintUsage Class

This class represents the native sqlite3_index_constraint_usage structure from the SQLite core library.

For a list of all members of this type, see SQLiteIndexConstraintUsage Members .

System.Object
SQLiteIndexConstraintUsage

public sealed class SQLiteIndexConstraintUsage

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteIndexConstraintUsage Members | System.Data.SQLite Namespace


SQLiteIndexConstraintUsage Members

SQLiteIndexConstraintUsage overview

Public Instance Fields

argvIndex | If greater than 0, constraint is part of argv to xFilter.
omit | Do not code a test for this constraint.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndexConstraintUsage Class | System.Data.SQLite Namespace


SQLiteIndexConstraintUsage Fields

The fields of the SQLiteIndexConstraintUsage class are listed below. For a complete list of SQLiteIndexConstraintUsage class members, see the SQLiteIndexConstraintUsage Members topic.

Public Instance Fields

argvIndex | If greater than 0, constraint is part of argv to xFilter.
omit | Do not code a test for this constraint.

See Also

SQLiteIndexConstraintUsage Class | System.Data.SQLite Namespace


SQLiteIndexConstraintUsage.argvIndex Field

If greater than 0, constraint is part of argv to xFilter.

public int argvIndex;

See Also

SQLiteIndexConstraintUsage Class | System.Data.SQLite Namespace


SQLiteIndexConstraintUsage.omit Field

Do not code a test for this constraint.

public byte omit;

See Also

SQLiteIndexConstraintUsage Class | System.Data.SQLite Namespace


SQLiteIndexFlags Enumeration

These are the allowed values for the index flags from the BestIndex method.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum SQLiteIndexFlags

Members

Member Name | Description | Value
None | No special handling. This is the default. | 0
ScanUnique | This value indicates that the scan of the index will visit at most one row. | 1

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteIndexInputs Class

This class represents the various inputs provided by the SQLite core library to the BestIndex method.

For a list of all members of this type, see SQLiteIndexInputs Members .

System.Object
SQLiteIndexInputs

public sealed class SQLiteIndexInputs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteIndexInputs Members | System.Data.SQLite Namespace


SQLiteIndexInputs Members

SQLiteIndexInputs overview

Public Instance Properties

Constraints | An array of SQLiteIndexConstraint object instances, each containing information supplied by the SQLite core library.
OrderBys | An array of SQLiteIndexOrderBy object instances, each containing information supplied by the SQLite core library.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndexInputs Class | System.Data.SQLite Namespace


SQLiteIndexInputs Properties

The properties of the SQLiteIndexInputs class are listed below. For a complete list of SQLiteIndexInputs class members, see the SQLiteIndexInputs Members topic.

Public Instance Properties

Constraints | An array of SQLiteIndexConstraint object instances, each containing information supplied by the SQLite core library.
OrderBys | An array of SQLiteIndexOrderBy object instances, each containing information supplied by the SQLite core library.

See Also

SQLiteIndexInputs Class | System.Data.SQLite Namespace


Constraints Property

SQLite ADO.NET Provider

SQLiteIndexInputs.Constraints Property

An array of SQLiteIndexConstraint object instances, each containing information supplied by the SQLite core library.

public SQLiteIndexConstraint[] Constraints { public get; }

See Also

SQLiteIndexInputs Class | System.Data.SQLite Namespace


OrderBys Property

SQLite ADO.NET Provider

SQLiteIndexInputs.OrderBys Property

An array of SQLiteIndexOrderBy object instances, each containing information supplied by the SQLite core library.

public SQLiteIndexOrderBy[] OrderBys { public get; }

See Also

SQLiteIndexInputs Class | System.Data.SQLite Namespace


SQLiteIndexOrderBy Class

This class represents the native sqlite3_index_orderby structure from the SQLite core library.

For a list of all members of this type, see SQLiteIndexOrderBy Members .

System.Object
SQLiteIndexOrderBy

public sealed class SQLiteIndexOrderBy

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteIndexOrderBy Members | System.Data.SQLite Namespace


SQLiteIndexOrderBy Members

SQLiteIndexOrderBy overview

Public Instance Fields

desc | True for DESC. False for ASC.
iColumn | Column number.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndexOrderBy Class | System.Data.SQLite Namespace


SQLiteIndexOrderBy Fields

The fields of the SQLiteIndexOrderBy class are listed below. For a complete list of SQLiteIndexOrderBy class members, see the SQLiteIndexOrderBy Members topic.

Public Instance Fields

desc | True for DESC. False for ASC.
iColumn | Column number.

See Also

SQLiteIndexOrderBy Class | System.Data.SQLite Namespace


SQLiteIndexOrderBy.desc Field

True for DESC. False for ASC.

public byte desc;

See Also

SQLiteIndexOrderBy Class | System.Data.SQLite Namespace


SQLiteIndexOrderBy.iColumn Field

Column number.

public int iColumn;

See Also

SQLiteIndexOrderBy Class | System.Data.SQLite Namespace


SQLiteIndexOutputs Class

This class represents the various outputs provided to the SQLite core library by the BestIndex method.

For a list of all members of this type, see SQLiteIndexOutputs Members .

System.Object
SQLiteIndexOutputs

public sealed class SQLiteIndexOutputs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteIndexOutputs Members | System.Data.SQLite Namespace


SQLiteIndexOutputs Members

SQLiteIndexOutputs overview

Public Instance Properties

ColumnsUsed Indicates which columns of the virtual table may be required by the current scan. Virtual table columns are numbered from zero in the order in which they appear within the CREATE TABLE statement passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), the corresponding bit is set within the bit mask if the column may be required by SQLite. If the table has at least 64 columns and any column to the right of the first 63 is required, then bit 63 of colUsed is also set. In other words, column iCol may be required if the expression
(colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol)))
evaluates to non-zero. Using a null value here indicates that a default flags value should be used. This property has no effect if the SQLite core library is not at least version 3.10.0.
ConstraintUsages | An array of SQLiteIndexConstraintUsage object instances, each containing information to be supplied to the SQLite core library.
EstimatedCost | Estimated cost of using this index. Using a null value here indicates that a default estimated cost value should be used.
EstimatedRows | Estimated number of rows returned. Using a null value here indicates that a default estimated rows value should be used. This property has no effect if the SQLite core library is not at least version 3.8.2.
IndexFlags | The flags that should be used with this index. Using a null value here indicates that a default flags value should be used. This property has no effect if the SQLite core library is not at least version 3.9.0.
IndexNumber | Number used to help identify the selected index. This value will later be provided to the Filter method.
IndexString | String used to help identify the selected index. This value will later be provided to the Filter method.
NeedToFreeIndexString | Non-zero if the index string must be freed by the SQLite core library.
OrderByConsumed | True if output is already ordered.

Public Instance Methods

CanUseColumnsUsed | Determines if the native flags field can be used, based on the available version of the SQLite core library.
CanUseEstimatedRows | Determines if the native estimatedRows field can be used, based on the available version of the SQLite core library.
CanUseIndexFlags | Determines if the native flags field can be used, based on the available version of the SQLite core library.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


SQLiteIndexOutputs Properties

The properties of the SQLiteIndexOutputs class are listed below. For a complete list of SQLiteIndexOutputs class members, see the SQLiteIndexOutputs Members topic.

Public Instance Properties

ColumnsUsed Indicates which columns of the virtual table may be required by the current scan. Virtual table columns are numbered from zero in the order in which they appear within the CREATE TABLE statement passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), the corresponding bit is set within the bit mask if the column may be required by SQLite. If the table has at least 64 columns and any column to the right of the first 63 is required, then bit 63 of colUsed is also set. In other words, column iCol may be required if the expression
(colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol)))
evaluates to non-zero. Using a null value here indicates that a default flags value should be used. This property has no effect if the SQLite core library is not at least version 3.10.0.
ConstraintUsages | An array of SQLiteIndexConstraintUsage object instances, each containing information to be supplied to the SQLite core library.
EstimatedCost | Estimated cost of using this index. Using a null value here indicates that a default estimated cost value should be used.
EstimatedRows | Estimated number of rows returned. Using a null value here indicates that a default estimated rows value should be used. This property has no effect if the SQLite core library is not at least version 3.8.2.
IndexFlags | The flags that should be used with this index. Using a null value here indicates that a default flags value should be used. This property has no effect if the SQLite core library is not at least version 3.9.0.
IndexNumber | Number used to help identify the selected index. This value will later be provided to the Filter method.
IndexString | String used to help identify the selected index. This value will later be provided to the Filter method.
NeedToFreeIndexString | Non-zero if the index string must be freed by the SQLite core library.
OrderByConsumed | True if output is already ordered.

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


ColumnsUsed Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.ColumnsUsed Property

Indicates which columns of the virtual table may be required by the current scan. Virtual table columns are numbered from zero in the order in which they appear within the CREATE TABLE statement passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), the corresponding bit is set within the bit mask if the column may be required by SQLite. If the table has at least 64 columns and any column to the right of the first 63 is required, then bit 63 of colUsed is also set. In other words, column iCol may be required if the expression

(colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol)))

evaluates to non-zero. Using a null value here indicates that a default flags value should be used. This property has no effect if the SQLite core library is not at least version 3.10.0.

public long? ColumnsUsed { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


ConstraintUsages Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.ConstraintUsages Property

An array of SQLiteIndexConstraintUsage object instances, each containing information to be supplied to the SQLite core library.

public SQLiteIndexConstraintUsage[] ConstraintUsages { public get; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


EstimatedCost Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.EstimatedCost Property

Estimated cost of using this index. Using a null value here indicates that a default estimated cost value should be used.

public double? EstimatedCost { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


EstimatedRows Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.EstimatedRows Property

Estimated number of rows returned. Using a null value here indicates that a default estimated rows value should be used. This property has no effect if the SQLite core library is not at least version 3.8.2.

public long? EstimatedRows { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


IndexFlags Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.IndexFlags Property

The flags that should be used with this index. Using a null value here indicates that a default flags value should be used. This property has no effect if the SQLite core library is not at least version 3.9.0.

public SQLiteIndexFlags? IndexFlags { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


IndexNumber Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.IndexNumber Property

Number used to help identify the selected index. This value will later be provided to the Filter method.

public int IndexNumber { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


IndexString Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.IndexString Property

String used to help identify the selected index. This value will later be provided to the Filter method.

public string IndexString { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


NeedToFreeIndexString Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.NeedToFreeIndexString Property

Non-zero if the index string must be freed by the SQLite core library.

public int NeedToFreeIndexString { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


OrderByConsumed Property

SQLite ADO.NET Provider

SQLiteIndexOutputs.OrderByConsumed Property

True if output is already ordered.

public int OrderByConsumed { public get; public set; }

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


SQLiteIndexOutputs Methods

The methods of the SQLiteIndexOutputs class are listed below. For a complete list of SQLiteIndexOutputs class members, see the SQLiteIndexOutputs Members topic.

Public Instance Methods

CanUseColumnsUsed | Determines if the native flags field can be used, based on the available version of the SQLite core library.
CanUseEstimatedRows | Determines if the native estimatedRows field can be used, based on the available version of the SQLite core library.
CanUseIndexFlags | Determines if the native flags field can be used, based on the available version of the SQLite core library.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


SQLiteIndexOutputs.CanUseColumnsUsed Method

Determines if the native flags field can be used, based on the available version of the SQLite core library.

public bool CanUseColumnsUsed();

Return Value

Non-zero if the ColumnsUsed property is supported by the SQLite core library.

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


SQLiteIndexOutputs.CanUseEstimatedRows Method

Determines if the native estimatedRows field can be used, based on the available version of the SQLite core library.

public bool CanUseEstimatedRows();

Return Value

Non-zero if the EstimatedRows property is supported by the SQLite core library.

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


SQLiteIndexOutputs.CanUseIndexFlags Method

Determines if the native flags field can be used, based on the available version of the SQLite core library.

public bool CanUseIndexFlags();

Return Value

Non-zero if the IndexFlags property is supported by the SQLite core library.

See Also

SQLiteIndexOutputs Class | System.Data.SQLite Namespace


SQLiteInvokeDelegate Delegate

This Delegate type is used with the Invoke method.

public delegate object SQLiteInvokeDelegate(
string param0,
object[] args
);

Parameters

param0
This is always the string literal "Invoke".
args
The arguments for the scalar function.

Return Value

The result of the scalar function.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteJournalModeEnum Enumeration

This enum determines how SQLite treats its journal file.

public enum SQLiteJournalModeEnum

Remarks

By default SQLite will create and delete the journal file when needed during a transaction. However, for some computers running certain filesystem monitoring tools, the rapid creation and deletion of the journal file can cause those programs to fail, or to interfere with SQLite. If a program or virus scanner is interfering with SQLite's journal file, you may receive errors like "unable to open database file" when starting a transaction. If this is happening, you may want to change the default journal mode to Persist.

Members

Member Name | Description
Default | The default mode, this causes SQLite to use the existing journaling mode for the database.
Delete | SQLite will create and destroy the journal file as-needed.
Persist | When this is set, SQLite will keep the journal file even after a transaction has completed. It's contents will be erased, and the journal re-used as often as needed. If it is deleted, it will be recreated the next time it is needed.
Off | This option disables the rollback journal entirely. Interrupted transactions or a program crash can cause database corruption in this mode!
Truncate | SQLite will truncate the journal file to zero-length instead of deleting it.
Memory | SQLite will store the journal in volatile RAM. This saves disk I/O but at the expense of database safety and integrity. If the application using SQLite crashes in the middle of a transaction when the MEMORY journaling mode is set, then the database file will very likely go corrupt.
Wal | SQLite uses a write-ahead log instead of a rollback journal to implement transactions. The WAL journaling mode is persistent; after being set it stays in effect across multiple database connections and after closing and reopening the database. A database in WAL journaling mode can only be accessed by SQLite version 3.7.0 or later.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteLimitOpsEnum Enumeration

These constants are used with the sqlite3_limit() API.

public enum SQLiteLimitOpsEnum

Members

Member Name | Description
SQLITE_LIMIT_NONE | This value represents an unknown (or invalid) limit, do not use it.
SQLITE_LIMIT_LENGTH | The maximum size of any string or BLOB or table row, in bytes.
SQLITE_LIMIT_SQL_LENGTH | The maximum length of an SQL statement, in bytes.
SQLITE_LIMIT_COLUMN | The maximum number of columns in a table definition or in the result set of a SELECT or the maximum number of columns in an index or in an ORDER BY or GROUP BY clause.
SQLITE_LIMIT_EXPR_DEPTH | The maximum depth of the parse tree on any expression.
SQLITE_LIMIT_COMPOUND_SELECT | The maximum number of terms in a compound SELECT statement.
SQLITE_LIMIT_VDBE_OP | The maximum number of instructions in a virtual machine program used to implement an SQL statement. If sqlite3_prepare_v2() or the equivalent tries to allocate space for more than this many opcodes in a single prepared statement, an SQLITE_NOMEM error is returned.
SQLITE_LIMIT_FUNCTION_ARG | The maximum number of arguments on a function.
SQLITE_LIMIT_ATTACHED | The maximum number of attached databases.
SQLITE_LIMIT_LIKE_PATTERN_LENGTH | The maximum length of the pattern argument to the LIKE or GLOB operators.
SQLITE_LIMIT_VARIABLE_NUMBER | The maximum index number of any parameter in an SQL statement.
SQLITE_LIMIT_TRIGGER_DEPTH | The maximum depth of recursion for triggers.
SQLITE_LIMIT_WORKER_THREADS | The maximum number of auxiliary worker threads that a single prepared statement may start.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteLog Class

Manages the SQLite custom logging functionality and the associated callback for the whole process.

For a list of all members of this type, see SQLiteLog Members .

System.Object
SQLiteLog

public static class SQLiteLog

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteLog Members | System.Data.SQLite Namespace


SQLiteLog Members

SQLiteLog overview

Public Static Properties

Enabled If this property is true, logging is enabled; otherwise, logging is disabled. When logging is disabled, no logging events will fire.

Public Static Methods

AddDefaultHandler | Adds the default log event handler to the list of handlers.
Initialize | Initializes the SQLite logging facilities.
LogMessage | Overloaded. Log a message to all the registered log event handlers without going through the SQLite library.
RemoveDefaultHandler | Removes the default log event handler from the list of handlers.
Uninitialize | Uninitializes the SQLite logging facilities.

Public Static Events

Log This event is raised whenever SQLite raises a logging event. Note that this should be set as one of the first things in the application.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog Properties

The properties of the SQLiteLog class are listed below. For a complete list of SQLiteLog class members, see the SQLiteLog Members topic.

Public Static Properties

Enabled If this property is true, logging is enabled; otherwise, logging is disabled. When logging is disabled, no logging events will fire.

See Also

SQLiteLog Class | System.Data.SQLite Namespace


Enabled Property

SQLite ADO.NET Provider

SQLiteLog.Enabled Property

If this property is true, logging is enabled; otherwise, logging is disabled. When logging is disabled, no logging events will fire.

public static bool Enabled { public get; public set; }

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog Methods

The methods of the SQLiteLog class are listed below. For a complete list of SQLiteLog class members, see the SQLiteLog Members topic.

Public Static Methods

AddDefaultHandler | Adds the default log event handler to the list of handlers.
Initialize | Initializes the SQLite logging facilities.
LogMessage | Overloaded. Log a message to all the registered log event handlers without going through the SQLite library.
RemoveDefaultHandler | Removes the default log event handler from the list of handlers.
Uninitialize | Uninitializes the SQLite logging facilities.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog.AddDefaultHandler Method

Adds the default log event handler to the list of handlers.

public static void AddDefaultHandler();

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog.Initialize Method

Initializes the SQLite logging facilities.

public static void Initialize();

See Also

SQLiteLog Class | System.Data.SQLite Namespace


LogMessage Method

SQLite ADO.NET Provider

SQLiteLog.LogMessage Method

Log a message to all the registered log event handlers without going through the SQLite library.

Overload List

Log a message to all the registered log event handlers without going through the SQLite library.

public static void LogMessage(SQLiteErrorCode,string)

Log a message to all the registered log event handlers without going through the SQLite library.

public static void LogMessage(int,string)

Log a message to all the registered log event handlers without going through the SQLite library.

public static void LogMessage(string)

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog.LogMessage(SQLiteErrorCode, String) Method

Log a message to all the registered log event handlers without going through the SQLite library.

public static void LogMessage(
SQLiteErrorCode errorCode,
string message
);

Parameters

errorCode
The SQLite error code.
message
The message to be logged.

See Also

SQLiteLog Class | System.Data.SQLite Namespace | SQLiteLog.LogMessage Overload List


SQLiteLog.LogMessage(Int32, String) Method

Log a message to all the registered log event handlers without going through the SQLite library.

public static void LogMessage(
int errorCode,
string message
);

Parameters

errorCode
The integer error code.
message
The message to be logged.

See Also

SQLiteLog Class | System.Data.SQLite Namespace | SQLiteLog.LogMessage Overload List


SQLiteLog.LogMessage(String) Method

Log a message to all the registered log event handlers without going through the SQLite library.

public static void LogMessage(
string message
);

Parameters

message
The message to be logged.

See Also

SQLiteLog Class | System.Data.SQLite Namespace | SQLiteLog.LogMessage Overload List


SQLiteLog.RemoveDefaultHandler Method

Removes the default log event handler from the list of handlers.

public static void RemoveDefaultHandler();

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog.Uninitialize Method

Uninitializes the SQLite logging facilities.

public static void Uninitialize();

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog Events

The events of the SQLiteLog class are listed below. For a complete list of SQLiteLog class members, see the SQLiteLog Members topic.

Public Static Events

Log This event is raised whenever SQLite raises a logging event. Note that this should be set as one of the first things in the application.

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLog.Log Event

This event is raised whenever SQLite raises a logging event. Note that this should be set as one of the first things in the application.

public static event SQLiteLogEventHandler Log;

See Also

SQLiteLog Class | System.Data.SQLite Namespace


SQLiteLogEventHandler Delegate

Raised when a log event occurs.

public delegate void SQLiteLogEventHandler(
object sender,
LogEventArgs e
);

Parameters

sender
The current connection
e
Event arguments of the trace

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames Class

MetaDataCollections specific to SQLite

For a list of all members of this type, see SQLiteMetaDataCollectionNames Members .

System.Object
SQLiteMetaDataCollectionNames

public static class SQLiteMetaDataCollectionNames

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteMetaDataCollectionNames Members | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames Members

SQLiteMetaDataCollectionNames overview

Public Static Fields

Catalogs | Returns a list of databases attached to the connection
Columns | Returns column information for the specified table
ForeignKeys | Returns foreign key information for the given catalog
IndexColumns | Returns base columns for the given index
Indexes | Returns index information for the optionally-specified table
Tables | Returns the tables in the given catalog
Triggers | Returns the triggers on the database
ViewColumns | Returns underlying column information on the given view
Views | Returns user-defined views in the given catalog

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames Fields

The fields of the SQLiteMetaDataCollectionNames class are listed below. For a complete list of SQLiteMetaDataCollectionNames class members, see the SQLiteMetaDataCollectionNames Members topic.

Public Static Fields

Catalogs | Returns a list of databases attached to the connection
Columns | Returns column information for the specified table
ForeignKeys | Returns foreign key information for the given catalog
IndexColumns | Returns base columns for the given index
Indexes | Returns index information for the optionally-specified table
Tables | Returns the tables in the given catalog
Triggers | Returns the triggers on the database
ViewColumns | Returns underlying column information on the given view
Views | Returns user-defined views in the given catalog

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.Catalogs Field

Returns a list of databases attached to the connection

public static readonly string Catalogs;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.Columns Field

Returns column information for the specified table

public static readonly string Columns;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.ForeignKeys Field

Returns foreign key information for the given catalog

public static readonly string ForeignKeys;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.IndexColumns Field

Returns base columns for the given index

public static readonly string IndexColumns;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.Indexes Field

Returns index information for the optionally-specified table

public static readonly string Indexes;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.Tables Field

Returns the tables in the given catalog

public static readonly string Tables;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.Triggers Field

Returns the triggers on the database

public static readonly string Triggers;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.ViewColumns Field

Returns underlying column information on the given view

public static readonly string ViewColumns;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteMetaDataCollectionNames.Views Field

Returns user-defined views in the given catalog

public static readonly string Views;

See Also

SQLiteMetaDataCollectionNames Class | System.Data.SQLite Namespace


SQLiteModule Class

This class represents a managed virtual table module implementation. It is not sealed and must be used as the base class for any user-defined virtual table module classes implemented in managed code.

For a list of all members of this type, see SQLiteModule Members .

System.Object
SQLiteModule
SQLiteModuleNoop

public abstract class SQLiteModule : ISQLiteManagedModule, IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteModule Members | System.Data.SQLite Namespace


SQLiteModule Members

SQLiteModule overview

Public Instance Constructors

SQLiteModule Constructor Constructs an instance of this class.

Public Instance Properties

Declared | Returns non-zero if the schema for the virtual table has been declared.
LogErrors | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptions | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.
Name | Returns the name of the module as it was registered with the SQLite core library.

Public Instance Methods

Begin | This method is called in response to the xBegin method.
BestIndex | This method is called in response to the xBestIndex method.
Close | This method is called in response to the xClose method.
Column | This method is called in response to the xColumn method.
Commit | This method is called in response to the xCommit method.
Connect | This method is called in response to the xConnect method.
Create | This method is called in response to the xCreate method.
Destroy | This method is called in response to the xDestroy method.
Disconnect | This method is called in response to the xDisconnect method.
Dispose | Overloaded. Disposes of this object instance.
Eof | This method is called in response to the xEof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | This method is called in response to the xFilter method.
FindFunction | This method is called in response to the xFindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next | This method is called in response to the xNext method.
Open | This method is called in response to the xOpen method.
Release | This method is called in response to the xRelease method.
Rename | This method is called in response to the xRename method.
Rollback | This method is called in response to the xRollback method.
RollbackTo | This method is called in response to the xRollbackTo method.
RowId | This method is called in response to the xRowId method.
Savepoint | This method is called in response to the xSavepoint method.
Sync | This method is called in response to the xSync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update | This method is called in response to the xUpdate method.

Protected Instance Properties

LogErrorsNoThrow | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptionsNoThrow | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

Protected Instance Methods

AllocateCursor | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorFromIntPtr | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
DeclareFunction | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize | Finalizes this object instance.
FreeCursor | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetFunctionKey | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetNativeModuleImpl | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
SetCursorError | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags | Overloaded.
SetTableError | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule Constructor

Constructs an instance of this class.

SQLiteModule(
string name
);

Parameters

name
The name of the module. This parameter cannot be null.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule Properties

The properties of the SQLiteModule class are listed below. For a complete list of SQLiteModule class members, see the SQLiteModule Members topic.

Public Instance Properties

Declared | Returns non-zero if the schema for the virtual table has been declared.
LogErrors | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptions | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.
Name | Returns the name of the module as it was registered with the SQLite core library.

Protected Instance Properties

LogErrorsNoThrow | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptionsNoThrow | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


Declared Property

SQLite ADO.NET Provider

SQLiteModule.Declared Property

Returns non-zero if the schema for the virtual table has been declared.

public virtual bool Declared { public get; internal set; }

Implements

ISQLiteManagedModule.Declared

See Also

SQLiteModule Class | System.Data.SQLite Namespace


LogErrors Property

SQLite ADO.NET Provider

SQLiteModule.LogErrors Property

Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.

public virtual bool LogErrors { public get; public set; }

See Also

SQLiteModule Class | System.Data.SQLite Namespace


LogErrorsNoThrow Property

SQLite ADO.NET Provider

SQLiteModule.LogErrorsNoThrow Property

Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.

protected virtual bool LogErrorsNoThrow { protected get; protected set; }

See Also

SQLiteModule Class | System.Data.SQLite Namespace


LogExceptions Property

SQLite ADO.NET Provider

SQLiteModule.LogExceptions Property

Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.

public virtual bool LogExceptions { public get; public set; }

See Also

SQLiteModule Class | System.Data.SQLite Namespace


LogExceptionsNoThrow Property

SQLite ADO.NET Provider

SQLiteModule.LogExceptionsNoThrow Property

Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

protected virtual bool LogExceptionsNoThrow { protected get; protected set; }

See Also

SQLiteModule Class | System.Data.SQLite Namespace


Name Property

SQLite ADO.NET Provider

SQLiteModule.Name Property

Returns the name of the module as it was registered with the SQLite core library.

public virtual string Name { public get; }

Implements

ISQLiteManagedModule.Name

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule Methods

The methods of the SQLiteModule class are listed below. For a complete list of SQLiteModule class members, see the SQLiteModule Members topic.

Public Instance Methods

Begin | This method is called in response to the xBegin method.
BestIndex | This method is called in response to the xBestIndex method.
Close | This method is called in response to the xClose method.
Column | This method is called in response to the xColumn method.
Commit | This method is called in response to the xCommit method.
Connect | This method is called in response to the xConnect method.
Create | This method is called in response to the xCreate method.
Destroy | This method is called in response to the xDestroy method.
Disconnect | This method is called in response to the xDisconnect method.
Dispose | Overloaded. Disposes of this object instance.
Eof | This method is called in response to the xEof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | This method is called in response to the xFilter method.
FindFunction | This method is called in response to the xFindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next | This method is called in response to the xNext method.
Open | This method is called in response to the xOpen method.
Release | This method is called in response to the xRelease method.
Rename | This method is called in response to the xRename method.
Rollback | This method is called in response to the xRollback method.
RollbackTo | This method is called in response to the xRollbackTo method.
RowId | This method is called in response to the xRowId method.
Savepoint | This method is called in response to the xSavepoint method.
Sync | This method is called in response to the xSync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update | This method is called in response to the xUpdate method.

Protected Instance Methods

AllocateCursor | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorFromIntPtr | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
DeclareFunction | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize | Finalizes this object instance.
FreeCursor | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetFunctionKey | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetNativeModuleImpl | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
SetCursorError | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags | Overloaded.
SetTableError | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.AllocateCursor Method

Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.

protected virtual IntPtr AllocateCursor();

Return Value

A native pointer to a native sqlite3_vtab_cursor derived structure.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.AllocateTable Method

Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.

protected virtual IntPtr AllocateTable();

Return Value

A native pointer to a native sqlite3_vtab derived structure.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Begin Method

This method is called in response to the xBegin method.

public abstract SQLiteErrorCode Begin(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Begin

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.BestIndex Method

This method is called in response to the xBestIndex method.

public abstract SQLiteErrorCode BestIndex(
SQLiteVirtualTable table,
SQLiteIndex index
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
index
The SQLiteIndex object instance containing all the data for the inputs and outputs relating to index selection.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.BestIndex

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Close Method

This method is called in response to the xClose method.

public abstract SQLiteErrorCode Close(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Close

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Column Method

This method is called in response to the xColumn method.

public abstract SQLiteErrorCode Column(
SQLiteVirtualTableCursor cursor,
SQLiteContext context,
int index
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
context
The SQLiteContext object instance to be used for returning the specified column value to the SQLite core library.
index
The zero-based index corresponding to the column containing the value to be returned.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Column

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Commit Method

This method is called in response to the xCommit method.

public abstract SQLiteErrorCode Commit(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Commit

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Connect Method

This method is called in response to the xConnect method.

public abstract SQLiteErrorCode Connect(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
The SQLiteConnection object instance associated with the virtual table.
pClientData
The native user-data pointer associated with this module, as it was provided to the SQLite core library when the native module instance was created.
arguments
The module name, database name, virtual table name, and all other arguments passed to the CREATE VIRTUAL TABLE statement.
table
Upon success, this parameter must be modified to contain the SQLiteVirtualTable object instance associated with the virtual table.
error
Upon failure, this parameter must be modified to contain an error message.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Connect

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Create Method

This method is called in response to the xCreate method.

public abstract SQLiteErrorCode Create(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
The SQLiteConnection object instance associated with the virtual table.
pClientData
The native user-data pointer associated with this module, as it was provided to the SQLite core library when the native module instance was created.
arguments
The module name, database name, virtual table name, and all other arguments passed to the CREATE VIRTUAL TABLE statement.
table
Upon success, this parameter must be modified to contain the SQLiteVirtualTable object instance associated with the virtual table.
error
Upon failure, this parameter must be modified to contain an error message.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Create

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.CreateNativeModuleImpl Method

Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.

protected virtual ISQLiteNativeModule CreateNativeModuleImpl();

Return Value

The ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.CursorFromIntPtr Method

Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.

protected virtual SQLiteVirtualTableCursor CursorFromIntPtr(
IntPtr pVtab,
IntPtr pCursor
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
pCursor
The native pointer to the sqlite3_vtab_cursor derived structure.

Return Value

The SQLiteVirtualTableCursor object instance or null if the corresponding one cannot be found.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.CursorToIntPtr Method

Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.

protected virtual IntPtr CursorToIntPtr(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance to be used when creating the association.

Return Value

The native pointer to a sqlite3_vtab_cursor derived structure or Zero if the method fails for any reason.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.DeclareFunction Method

Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.

protected virtual SQLiteErrorCode DeclareFunction(
SQLiteConnection connection,
int argumentCount,
string name,
ref string error
);

Parameters

connection
The SQLiteConnection object instance to use when declaring the schema of the virtual table.
argumentCount
The number of arguments to the function being declared.
name
The name of the function being declared.
error
Upon success, the contents of this parameter are undefined. Upon failure, it should contain an appropriate error message.

Return Value

A standard SQLite return code.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.DeclareTable Method

Attempts to declare the schema for the virtual table using the specified database connection.

protected virtual SQLiteErrorCode DeclareTable(
SQLiteConnection connection,
string sql,
ref string error
);

Parameters

connection
The SQLiteConnection object instance to use when declaring the schema of the virtual table. This parameter may not be null.
sql
The string containing the CREATE TABLE statement that completely describes the schema for the virtual table. This parameter may not be null.
error
Upon failure, this parameter must be modified to contain an error message.

Return Value

A standard SQLite return code.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Destroy Method

This method is called in response to the xDestroy method.

public abstract SQLiteErrorCode Destroy(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Destroy

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Disconnect Method

This method is called in response to the xDisconnect method.

public abstract SQLiteErrorCode Disconnect(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Disconnect

See Also

SQLiteModule Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteModule.Dispose Method

Disposes of this object instance.

Overload List

Disposes of this object instance.

public void Dispose()

Disposes of this object instance.

protected virtual void Dispose(bool)

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Dispose() Method

Disposes of this object instance.

public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.Dispose Overload List


SQLiteModule.Dispose(Boolean) Method

Disposes of this object instance.

protected virtual void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.Dispose Overload List


SQLiteModule.Eof Method

This method is called in response to the xEof method.

public abstract bool Eof(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.

Return Value

Non-zero if no more rows are available; zero otherwise.

Implements

ISQLiteManagedModule.Eof

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Filter Method

This method is called in response to the xFilter method.

public abstract SQLiteErrorCode Filter(
SQLiteVirtualTableCursor cursor,
int indexNumber,
string indexString,
SQLiteValue[] values
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
indexNumber
Number used to help identify the selected index.
indexString
String used to help identify the selected index.
values
The values corresponding to each column in the selected index.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Filter

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Finalize Method

Finalizes this object instance.

protected override void Finalize();

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.FindFunction Method

This method is called in response to the xFindFunction method.

public abstract bool FindFunction(
SQLiteVirtualTable table,
int argumentCount,
string name,
ref SQLiteFunction function,
ref IntPtr pClientData
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
argumentCount
The number of arguments to the function being sought.
name
The name of the function being sought.
function
Upon success, this parameter must be modified to contain the SQLiteFunction object instance responsible for implementing the specified function.
pClientData
Upon success, this parameter must be modified to contain the native user-data pointer associated with function.

Return Value

Non-zero if the specified function was found; zero otherwise.

Implements

ISQLiteManagedModule.FindFunction

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.FreeCursor Method

Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.

protected virtual void FreeCursor(
IntPtr pCursor
);

Parameters

pCursor
A native pointer to a native sqlite3_vtab_cursor derived structure.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.FreeTable Method

Frees a native sqlite3_vtab structure using the provided native pointer to it.

protected virtual void FreeTable(
IntPtr pVtab
);

Parameters

pVtab
A native pointer to a native sqlite3_vtab derived structure.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.GetFunctionKey Method

Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).

protected virtual string GetFunctionKey(
int argumentCount,
string name,
SQLiteFunction function
);

Parameters

argumentCount
The number of arguments to the virtual table function.
name
The name of the virtual table function.
function
The SQLiteFunction object instance associated with this virtual table function.

Return Value

The string that should be used to identify and store the virtual table function instance. This method cannot return null. If null is returned from this method, the behavior is undefined.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.GetNativeModuleImpl Method

Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.

protected virtual ISQLiteNativeModule GetNativeModuleImpl();

Return Value

The ISQLiteNativeModule interface implementation to be used when populating the native sqlite3_module structure. If the returned value is null, the private methods provided by the SQLiteModule class and relating to the ISQLiteNativeModule interface will be used to create the necessary delegates.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Next Method

This method is called in response to the xNext method.

public abstract SQLiteErrorCode Next(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Next

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Open Method

This method is called in response to the xOpen method.

public abstract SQLiteErrorCode Open(
SQLiteVirtualTable table,
ref SQLiteVirtualTableCursor cursor
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
cursor
Upon success, this parameter must be modified to contain the SQLiteVirtualTableCursor object instance associated with the newly opened virtual table cursor.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Open

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Release Method

This method is called in response to the xRelease method.

public abstract SQLiteErrorCode Release(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
savepoint
This is an integer used to indicate that any saved states with an identifier greater than or equal to this should be deleted by the virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Release

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Rename Method

This method is called in response to the xRename method.

public abstract SQLiteErrorCode Rename(
SQLiteVirtualTable table,
string newName
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
newName
The new name for the virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Rename

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Rollback Method

This method is called in response to the xRollback method.

public abstract SQLiteErrorCode Rollback(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Rollback

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.RollbackTo Method

This method is called in response to the xRollbackTo method.

public abstract SQLiteErrorCode RollbackTo(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
savepoint
This is an integer identifier used to specify a specific saved state for the virtual table for it to restore itself back to, which should also have the effect of deleting all saved states with an integer identifier greater than this one.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.RollbackTo

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.RowId Method

This method is called in response to the xRowId method.

public abstract SQLiteErrorCode RowId(
SQLiteVirtualTableCursor cursor,
ref long rowId
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
rowId
Upon success, this parameter must be modified to contain the unique integer row identifier for the current row for the specified cursor.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.RowId

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Savepoint Method

This method is called in response to the xSavepoint method.

public abstract SQLiteErrorCode Savepoint(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
savepoint
This is an integer identifier under which the the current state of the virtual table should be saved.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Savepoint

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.SetCursorError Method

Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.

protected virtual bool SetCursorError(
SQLiteVirtualTableCursor cursor,
string error
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance used to lookup the native pointer to the sqlite3_vtab derived structure.
error
The error message.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SetEstimatedCost Method

SQLite ADO.NET Provider

SQLiteModule.SetEstimatedCost Method

Modifies the specified SQLiteIndex object instance to contain the default estimated cost.

Overload List

Modifies the specified SQLiteIndex object instance to contain the default estimated cost.

protected virtual bool SetEstimatedCost(SQLiteIndex)

Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.

protected virtual bool SetEstimatedCost(SQLiteIndex,double?)

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.SetEstimatedCost(SQLiteIndex) Method

Modifies the specified SQLiteIndex object instance to contain the default estimated cost.

protected virtual bool SetEstimatedCost(
SQLiteIndex index
);

Parameters

index
The SQLiteIndex object instance to modify.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetEstimatedCost Overload List


SQLiteModule.SetEstimatedCost(SQLiteIndex, Double) Method

Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.

protected virtual bool SetEstimatedCost(
SQLiteIndex index,
double? estimatedCost
);

Parameters

index
The SQLiteIndex object instance to modify.
estimatedCost
The estimated cost value to use. Using a null value means that the default value provided by the SQLite core library should be used.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetEstimatedCost Overload List


SetEstimatedRows Method

SQLite ADO.NET Provider

SQLiteModule.SetEstimatedRows Method

Modifies the specified SQLiteIndex object instance to contain the default estimated rows.

Overload List

Modifies the specified SQLiteIndex object instance to contain the default estimated rows.

protected virtual bool SetEstimatedRows(SQLiteIndex)

Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.

protected virtual bool SetEstimatedRows(SQLiteIndex,long?)

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.SetEstimatedRows(SQLiteIndex) Method

Modifies the specified SQLiteIndex object instance to contain the default estimated rows.

protected virtual bool SetEstimatedRows(
SQLiteIndex index
);

Parameters

index
The SQLiteIndex object instance to modify.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetEstimatedRows Overload List


SQLiteModule.SetEstimatedRows(SQLiteIndex, Int64) Method

Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.

protected virtual bool SetEstimatedRows(
SQLiteIndex index,
long? estimatedRows
);

Parameters

index
The SQLiteIndex object instance to modify.
estimatedRows
The estimated rows value to use. Using a null value means that the default value provided by the SQLite core library should be used.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetEstimatedRows Overload List


SetIndexFlags Method

SQLite ADO.NET Provider

SQLiteModule.SetIndexFlags Method

Modifies the specified SQLiteIndex object instance to contain the default index flags.

Overload List

Modifies the specified SQLiteIndex object instance to contain the default index flags.

protected virtual bool SetIndexFlags(SQLiteIndex)

protected virtual bool SetIndexFlags(SQLiteIndex,SQLiteIndexFlags?)

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.SetIndexFlags(SQLiteIndex) Method

Modifies the specified SQLiteIndex object instance to contain the default index flags.

protected virtual bool SetIndexFlags(
SQLiteIndex index
);

Parameters

index
The SQLiteIndex object instance to modify.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetIndexFlags Overload List


SQLiteModule.SetIndexFlags(SQLiteIndex, SQLiteIndexFlags) Method

protected virtual bool SetIndexFlags(
SQLiteIndex index,
SQLiteIndexFlags? indexFlags
);

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetIndexFlags Overload List


SetTableError Method

SQLite ADO.NET Provider

SQLiteModule.SetTableError Method

Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.

Overload List

Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.

protected virtual bool SetTableError(SQLiteVirtualTable,string)

Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.

protected virtual bool SetTableError(IntPtr,string)

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.SetTableError(SQLiteVirtualTable, String) Method

Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.

protected virtual bool SetTableError(
SQLiteVirtualTable table,
string error
);

Parameters

table
The SQLiteVirtualTable object instance used to lookup the native pointer to the sqlite3_vtab derived structure.
error
The error message.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetTableError Overload List


SQLiteModule.SetTableError(IntPtr, String) Method

Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.

protected virtual bool SetTableError(
IntPtr pVtab,
string error
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.
error
The error message.

Return Value

Non-zero upon success.

See Also

SQLiteModule Class | System.Data.SQLite Namespace | SQLiteModule.SetTableError Overload List


SQLiteModule.Sync Method

This method is called in response to the xSync method.

public abstract SQLiteErrorCode Sync(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Sync

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.TableFromCursor Method

Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.

protected virtual IntPtr TableFromCursor(
IntPtr pCursor
);

Parameters

pCursor
The native pointer to the sqlite3_vtab_cursor derived structure from which to read the native pointer to the sqlite3_vtab derived structure.

Return Value

The native pointer to the sqlite3_vtab derived structure -OR- Zero if it cannot be determined.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.TableFromIntPtr Method

Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.

protected virtual SQLiteVirtualTable TableFromIntPtr(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the sqlite3_vtab derived structure.

Return Value

The SQLiteVirtualTable object instance or null if the corresponding one cannot be found.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.TableToIntPtr Method

Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.

protected virtual IntPtr TableToIntPtr(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance to be used when creating the association.

Return Value

The native pointer to a sqlite3_vtab derived structure or Zero if the method fails for any reason.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.Update Method

This method is called in response to the xUpdate method.

public abstract SQLiteErrorCode Update(
SQLiteVirtualTable table,
SQLiteValue[] values,
ref long rowId
);

Parameters

table
The SQLiteVirtualTable object instance associated with this virtual table.
values
The array of SQLiteValue object instances containing the new or modified column values, if any.
rowId
Upon success, this parameter must be modified to contain the unique integer row identifier for the row that was inserted, if any.

Return Value

A standard SQLite return code.

Implements

ISQLiteManagedModule.Update

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModule.ZeroTable Method

Zeros out the fields of a native sqlite3_vtab derived structure.

protected virtual void ZeroTable(
IntPtr pVtab
);

Parameters

pVtab
The native pointer to the native sqlite3_vtab derived structure to zero.

See Also

SQLiteModule Class | System.Data.SQLite Namespace


SQLiteModuleCommon Class

This class contains some virtual methods that may be useful for other virtual table classes. It specifically does NOT implement any of the ISQLiteManagedModule interface methods.

For a list of all members of this type, see SQLiteModuleCommon Members .

System.Object
SQLiteModule
SQLiteModuleNoop
SQLiteModuleCommon
SQLiteModuleEnumerable

public class SQLiteModuleCommon : SQLiteModuleNoop

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteModuleCommon Members | System.Data.SQLite Namespace


SQLiteModuleCommon Members

SQLiteModuleCommon overview

Public Instance Constructors

SQLiteModuleCommon Overloaded. Initializes a new instance of the SQLiteModuleCommon class.

Public Instance Properties

Declared (inherited from SQLiteModule) | Returns non-zero if the schema for the virtual table has been declared.
LogErrors (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptions (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.
Name (inherited from SQLiteModule) | Returns the name of the module as it was registered with the SQLite core library.

Public Instance Methods

Begin (inherited from SQLiteModuleNoop) | See the Begin method.
BestIndex (inherited from SQLiteModuleNoop) | See the BestIndex method.
Close (inherited from SQLiteModuleNoop) | See the Close method.
Column (inherited from SQLiteModuleNoop) | See the Column method.
Commit (inherited from SQLiteModuleNoop) | See the Commit method.
Connect (inherited from SQLiteModuleNoop) | See the Connect method.
Create (inherited from SQLiteModuleNoop) | See the Create method.
Destroy (inherited from SQLiteModuleNoop) | See the Destroy method.
Disconnect (inherited from SQLiteModuleNoop) | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof (inherited from SQLiteModuleNoop) | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteModuleNoop) | See the Filter method.
FindFunction (inherited from SQLiteModuleNoop) | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next (inherited from SQLiteModuleNoop) | See the Next method.
Open (inherited from SQLiteModuleNoop) | See the Open method.
Release (inherited from SQLiteModuleNoop) | See the Release method.
Rename (inherited from SQLiteModuleNoop) | See the Rename method.
Rollback (inherited from SQLiteModuleNoop) | See the Rollback method.
RollbackTo (inherited from SQLiteModuleNoop) | See the RollbackTo method.
RowId (inherited from SQLiteModuleNoop) | See the RowId method.
Savepoint (inherited from SQLiteModuleNoop) | See the Savepoint method.
Sync (inherited from SQLiteModuleNoop) | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update (inherited from SQLiteModuleNoop) | See the Update method.

Protected Instance Properties

LogErrorsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptionsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
CursorTypeMismatchError | Sets the table error message to one that indicates the virtual table cursor is of the wrong type.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode (inherited from SQLiteModuleNoop) | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode (inherited from SQLiteModuleNoop) | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
GetRowIdFromObject | Determines the unique row identifier for the current row.
GetSqlForDeclareTable | Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.
GetStringFromObject | Determines the string to return as the column value for the object instance value.
MakeRowId | Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode (inherited from SQLiteModuleNoop) | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon Constructor

Constructs an instance of this class.

Overload List

Constructs an instance of this class.

public SQLiteModuleCommon(string)

Constructs an instance of this class.

public SQLiteModuleCommon(string,bool)

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon Constructor

Constructs an instance of this class.

SQLiteModuleCommon(
string name
);

Parameters

name
The name of the module. This parameter cannot be null.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace | SQLiteModuleCommon Constructor Overload List


SQLiteModuleCommon Constructor

Constructs an instance of this class.

SQLiteModuleCommon(
string name,
bool objectIdentity
);

Parameters

name
The name of the module. This parameter cannot be null.
objectIdentity
Non-zero if different object instances with the same value should generate different row identifiers, where applicable. This parameter has no effect on the .NET Compact Framework.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace | SQLiteModuleCommon Constructor Overload List


SQLiteModuleCommon Methods

The methods of the SQLiteModuleCommon class are listed below. For a complete list of SQLiteModuleCommon class members, see the SQLiteModuleCommon Members topic.

Public Instance Methods

Begin (inherited from SQLiteModuleNoop) | See the Begin method.
BestIndex (inherited from SQLiteModuleNoop) | See the BestIndex method.
Close (inherited from SQLiteModuleNoop) | See the Close method.
Column (inherited from SQLiteModuleNoop) | See the Column method.
Commit (inherited from SQLiteModuleNoop) | See the Commit method.
Connect (inherited from SQLiteModuleNoop) | See the Connect method.
Create (inherited from SQLiteModuleNoop) | See the Create method.
Destroy (inherited from SQLiteModuleNoop) | See the Destroy method.
Disconnect (inherited from SQLiteModuleNoop) | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof (inherited from SQLiteModuleNoop) | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteModuleNoop) | See the Filter method.
FindFunction (inherited from SQLiteModuleNoop) | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next (inherited from SQLiteModuleNoop) | See the Next method.
Open (inherited from SQLiteModuleNoop) | See the Open method.
Release (inherited from SQLiteModuleNoop) | See the Release method.
Rename (inherited from SQLiteModuleNoop) | See the Rename method.
Rollback (inherited from SQLiteModuleNoop) | See the Rollback method.
RollbackTo (inherited from SQLiteModuleNoop) | See the RollbackTo method.
RowId (inherited from SQLiteModuleNoop) | See the RowId method.
Savepoint (inherited from SQLiteModuleNoop) | See the Savepoint method.
Sync (inherited from SQLiteModuleNoop) | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update (inherited from SQLiteModuleNoop) | See the Update method.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
CursorTypeMismatchError | Sets the table error message to one that indicates the virtual table cursor is of the wrong type.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode (inherited from SQLiteModuleNoop) | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode (inherited from SQLiteModuleNoop) | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
GetRowIdFromObject | Determines the unique row identifier for the current row.
GetSqlForDeclareTable | Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.
GetStringFromObject | Determines the string to return as the column value for the object instance value.
MakeRowId | Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode (inherited from SQLiteModuleNoop) | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon.CursorTypeMismatchError Method

Sets the table error message to one that indicates the virtual table cursor is of the wrong type.

protected virtual SQLiteErrorCode CursorTypeMismatchError(
SQLiteVirtualTableCursor cursor,
Type type
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance.
type
The Type that the virtual table cursor should be.

Return Value

The value of Error.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteModuleCommon.Dispose Method

Disposes of this object instance.

Overload List

Inherited from SQLiteModule.

public void Dispose()

Disposes of this object instance.

protected override void Dispose(bool)

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon.Dispose(Boolean) Method

Disposes of this object instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace | SQLiteModuleCommon.Dispose Overload List


SQLiteModuleCommon.GetRowIdFromObject Method

Determines the unique row identifier for the current row.

protected virtual long GetRowIdFromObject(
SQLiteVirtualTableCursor cursor,
object value
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
value
The object instance to return a unique row identifier for.

Return Value

The unique row identifier or zero upon failure.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon.GetSqlForDeclareTable Method

Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.

protected virtual string GetSqlForDeclareTable();

Return Value

The SQL statement used to declare the virtual table -OR- null if it cannot be determined.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon.GetStringFromObject Method

Determines the string to return as the column value for the object instance value.

protected virtual string GetStringFromObject(
SQLiteVirtualTableCursor cursor,
object value
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance associated with the previously opened virtual table cursor to be used.
value
The object instance to return a string representation for.

Return Value

The string representation of the specified object instance or null upon failure.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleCommon.MakeRowId Method

Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.

protected virtual long MakeRowId(
int rowIndex,
int hashCode
);

Parameters

rowIndex
The integer row sequence number for the current row.
hashCode
The hash code of the key column value for the current row.

Return Value

The unique row identifier or zero upon failure.

See Also

SQLiteModuleCommon Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable Class

This class implements a virtual table module that exposes an IEnumerable object instance as a read-only virtual table. It is not sealed and may be used as the base class for any user-defined virtual table class that wraps an IEnumerable object instance. The following short example shows it being used to treat an array of strings as a table data source:

   public static class Sample
   {
     public static void Main()
     {
       using (SQLiteConnection connection = new SQLiteConnection(
           "Data Source=:memory:;"))
       {
         connection.Open();

         connection.CreateModule(new SQLiteModuleEnumerable(
           "sampleModule", new string[] { "one", "two", "three" }));

         using (SQLiteCommand command = connection.CreateCommand())
         {
           command.CommandText =
               "CREATE VIRTUAL TABLE t1 USING sampleModule;";

           command.ExecuteNonQuery();
         }

         using (SQLiteCommand command = connection.CreateCommand())
         {
           command.CommandText = "SELECT * FROM t1;";

           using (SQLiteDataReader dataReader = command.ExecuteReader())
           {
             while (dataReader.Read())
               Console.WriteLine(dataReader[0].ToString());
           }
         }

         connection.Close();
       }
     }
   }

For a list of all members of this type, see SQLiteModuleEnumerable Members .

System.Object
SQLiteModule
SQLiteModuleNoop
SQLiteModuleCommon
SQLiteModuleEnumerable
SQLiteModuleEnumerable(T)

public class SQLiteModuleEnumerable : SQLiteModuleCommon

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteModuleEnumerable Members | System.Data.SQLite Namespace


SQLiteModuleEnumerable Members

SQLiteModuleEnumerable overview

Public Instance Constructors

SQLiteModuleEnumerable Overloaded. Initializes a new instance of the SQLiteModuleEnumerable class.

Public Instance Properties

Declared (inherited from SQLiteModule) | Returns non-zero if the schema for the virtual table has been declared.
LogErrors (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptions (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.
Name (inherited from SQLiteModule) | Returns the name of the module as it was registered with the SQLite core library.

Public Instance Methods

Begin (inherited from SQLiteModuleNoop) | See the Begin method.
BestIndex | See the BestIndex method.
Close | See the Close method.
Column | See the Column method.
Commit (inherited from SQLiteModuleNoop) | See the Commit method.
Connect | See the Connect method.
Create | See the Create method.
Destroy | See the Destroy method.
Disconnect | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | See the Filter method.
FindFunction (inherited from SQLiteModuleNoop) | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next | See the Next method.
Open | See the Open method.
Release (inherited from SQLiteModuleNoop) | See the Release method.
Rename | See the Rename method.
Rollback (inherited from SQLiteModuleNoop) | See the Rollback method.
RollbackTo (inherited from SQLiteModuleNoop) | See the RollbackTo method.
RowId | See the RowId method.
Savepoint (inherited from SQLiteModuleNoop) | See the Savepoint method.
Sync (inherited from SQLiteModuleNoop) | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update | See the Update method.

Protected Instance Properties

LogErrorsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptionsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorEndOfEnumeratorError | Sets the table error message to one that indicates the virtual table cursor has no current row.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
CursorTypeMismatchError (inherited from SQLiteModuleCommon) | Sets the table error message to one that indicates the virtual table cursor is of the wrong type.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode (inherited from SQLiteModuleNoop) | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode (inherited from SQLiteModuleNoop) | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
GetRowIdFromObject (inherited from SQLiteModuleCommon) | Determines the unique row identifier for the current row.
GetSqlForDeclareTable (inherited from SQLiteModuleCommon) | Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.
GetStringFromObject (inherited from SQLiteModuleCommon) | Determines the string to return as the column value for the object instance value.
MakeRowId (inherited from SQLiteModuleCommon) | Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode (inherited from SQLiteModuleNoop) | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable Constructor

Constructs an instance of this class.

Overload List

Constructs an instance of this class.

public SQLiteModuleEnumerable(string,IEnumerable)

Constructs an instance of this class.

public SQLiteModuleEnumerable(string,IEnumerable,bool)

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable Constructor

Constructs an instance of this class.

SQLiteModuleEnumerable(
string name,
IEnumerable enumerable
);

Parameters

name
The name of the module. This parameter cannot be null.
enumerable
The IEnumerable instance to expose as a virtual table. This parameter cannot be null.

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace | SQLiteModuleEnumerable Constructor Overload List


SQLiteModuleEnumerable Constructor

Constructs an instance of this class.

SQLiteModuleEnumerable(
string name,
IEnumerable enumerable,
bool objectIdentity
);

Parameters

name
The name of the module. This parameter cannot be null.
enumerable
The IEnumerable instance to expose as a virtual table. This parameter cannot be null.
objectIdentity
Non-zero if different object instances with the same value should generate different row identifiers, where applicable. This parameter has no effect on the .NET Compact Framework.

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace | SQLiteModuleEnumerable Constructor Overload List


SQLiteModuleEnumerable Methods

The methods of the SQLiteModuleEnumerable class are listed below. For a complete list of SQLiteModuleEnumerable class members, see the SQLiteModuleEnumerable Members topic.

Public Instance Methods

Begin (inherited from SQLiteModuleNoop) | See the Begin method.
BestIndex | See the BestIndex method.
Close | See the Close method.
Column | See the Column method.
Commit (inherited from SQLiteModuleNoop) | See the Commit method.
Connect | See the Connect method.
Create | See the Create method.
Destroy | See the Destroy method.
Disconnect | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | See the Filter method.
FindFunction (inherited from SQLiteModuleNoop) | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next | See the Next method.
Open | See the Open method.
Release (inherited from SQLiteModuleNoop) | See the Release method.
Rename | See the Rename method.
Rollback (inherited from SQLiteModuleNoop) | See the Rollback method.
RollbackTo (inherited from SQLiteModuleNoop) | See the RollbackTo method.
RowId | See the RowId method.
Savepoint (inherited from SQLiteModuleNoop) | See the Savepoint method.
Sync (inherited from SQLiteModuleNoop) | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update | See the Update method.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorEndOfEnumeratorError | Sets the table error message to one that indicates the virtual table cursor has no current row.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
CursorTypeMismatchError (inherited from SQLiteModuleCommon) | Sets the table error message to one that indicates the virtual table cursor is of the wrong type.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode (inherited from SQLiteModuleNoop) | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode (inherited from SQLiteModuleNoop) | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
GetRowIdFromObject (inherited from SQLiteModuleCommon) | Determines the unique row identifier for the current row.
GetSqlForDeclareTable (inherited from SQLiteModuleCommon) | Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.
GetStringFromObject (inherited from SQLiteModuleCommon) | Determines the string to return as the column value for the object instance value.
MakeRowId (inherited from SQLiteModuleCommon) | Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode (inherited from SQLiteModuleNoop) | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.BestIndex Method

See the BestIndex method.

public override SQLiteErrorCode BestIndex(
SQLiteVirtualTable table,
SQLiteIndex index
);

Parameters

table
See the BestIndex method.
index
See the BestIndex method.

Return Value

See the BestIndex method.

Implements

ISQLiteManagedModule.BestIndex

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Close Method

See the Close method.

public override SQLiteErrorCode Close(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
See the Close method.

Return Value

See the Close method.

Implements

ISQLiteManagedModule.Close

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Column Method

See the Column method.

public override SQLiteErrorCode Column(
SQLiteVirtualTableCursor cursor,
SQLiteContext context,
int index
);

Parameters

cursor
See the Column method.
context
See the Column method.
index
See the Column method.

Return Value

See the Column method.

Implements

ISQLiteManagedModule.Column

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Connect Method

See the Connect method.

public override SQLiteErrorCode Connect(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
See the Connect method.
pClientData
See the Connect method.
arguments
See the Connect method.
table
See the Connect method.
error
See the Connect method.

Return Value

See the Connect method.

Implements

ISQLiteManagedModule.Connect

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Create Method

See the Create method.

public override SQLiteErrorCode Create(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
See the Create method.
pClientData
See the Create method.
arguments
See the Create method.
table
See the Create method.
error
See the Create method.

Return Value

See the Create method.

Implements

ISQLiteManagedModule.Create

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.CursorEndOfEnumeratorError Method

Sets the table error message to one that indicates the virtual table cursor has no current row.

protected virtual SQLiteErrorCode CursorEndOfEnumeratorError(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
The SQLiteVirtualTableCursor object instance.

Return Value

The value of Error.

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Destroy Method

See the Destroy method.

public override SQLiteErrorCode Destroy(
SQLiteVirtualTable table
);

Parameters

table
See the Destroy method.

Return Value

See the Destroy method.

Implements

ISQLiteManagedModule.Destroy

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Disconnect Method

See the Disconnect method.

public override SQLiteErrorCode Disconnect(
SQLiteVirtualTable table
);

Parameters

table
See the Disconnect method.

Return Value

See the Disconnect method.

Implements

ISQLiteManagedModule.Disconnect

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteModuleEnumerable.Dispose Method

Disposes of this object instance.

Overload List

Inherited from SQLiteModule.

public void Dispose()

Disposes of this object instance.

protected override void Dispose(bool)

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Dispose(Boolean) Method

Disposes of this object instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace | SQLiteModuleEnumerable.Dispose Overload List


SQLiteModuleEnumerable.Eof Method

See the Eof method.

public override bool Eof(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
See the Eof method.

Return Value

See the Eof method.

Implements

ISQLiteManagedModule.Eof

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Filter Method

See the Filter method.

public override SQLiteErrorCode Filter(
SQLiteVirtualTableCursor cursor,
int indexNumber,
string indexString,
SQLiteValue[] values
);

Parameters

cursor
See the Filter method.
indexNumber
See the Filter method.
indexString
See the Filter method.
values
See the Filter method.

Return Value

See the Filter method.

Implements

ISQLiteManagedModule.Filter

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Next Method

See the Next method.

public override SQLiteErrorCode Next(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
See the Next method.

Return Value

See the Next method.

Implements

ISQLiteManagedModule.Next

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Open Method

See the Open method.

public override SQLiteErrorCode Open(
SQLiteVirtualTable table,
ref SQLiteVirtualTableCursor cursor
);

Parameters

table
See the Open method.
cursor
See the Open method.

Return Value

See the Open method.

Implements

ISQLiteManagedModule.Open

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Rename Method

See the Rename method.

public override SQLiteErrorCode Rename(
SQLiteVirtualTable table,
string newName
);

Parameters

table
See the Rename method.
newName
See the Rename method.

Return Value

See the Rename method.

Implements

ISQLiteManagedModule.Rename

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.RowId Method

See the RowId method.

public override SQLiteErrorCode RowId(
SQLiteVirtualTableCursor cursor,
ref long rowId
);

Parameters

cursor
See the RowId method.
rowId
See the RowId method.

Return Value

See the RowId method.

Implements

ISQLiteManagedModule.RowId

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleEnumerable.Update Method

See the Update method.

public override SQLiteErrorCode Update(
SQLiteVirtualTable table,
SQLiteValue[] values,
ref long rowId
);

Parameters

table
See the Update method.
values
See the Update method.
rowId
See the Update method.

Return Value

See the Update method.

Implements

ISQLiteManagedModule.Update

See Also

SQLiteModuleEnumerable Class | System.Data.SQLite Namespace


SQLiteModuleNoop Class

This class implements a virtual table module that does nothing by providing "empty" implementations for all of the ISQLiteManagedModule interface methods. The result codes returned by these "empty" method implementations may be controlled on a per-method basis by using and/or overriding the GetDefaultResultCode, ResultCodeToEofResult, ResultCodeToFindFunctionResult, GetMethodResultCode, and SetMethodResultCode methods from within derived classes.

For a list of all members of this type, see SQLiteModuleNoop Members .

System.Object
SQLiteModule
SQLiteModuleNoop
SQLiteModuleCommon

public class SQLiteModuleNoop : SQLiteModule

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteModuleNoop Members | System.Data.SQLite Namespace


SQLiteModuleNoop Members

SQLiteModuleNoop overview

Public Instance Constructors

SQLiteModuleNoop Constructor Constructs an instance of this class.

Public Instance Properties

Declared (inherited from SQLiteModule) | Returns non-zero if the schema for the virtual table has been declared.
LogErrors (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptions (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.
Name (inherited from SQLiteModule) | Returns the name of the module as it was registered with the SQLite core library.

Public Instance Methods

Begin | See the Begin method.
BestIndex | See the BestIndex method.
Close | See the Close method.
Column | See the Column method.
Commit | See the Commit method.
Connect | See the Connect method.
Create | See the Create method.
Destroy | See the Destroy method.
Disconnect | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | See the Filter method.
FindFunction | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next | See the Next method.
Open | See the Open method.
Release | See the Release method.
Rename | See the Rename method.
Rollback | See the Rollback method.
RollbackTo | See the RollbackTo method.
RowId | See the RowId method.
Savepoint | See the Savepoint method.
Sync | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update | See the Update method.

Protected Instance Properties

LogErrorsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptionsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop Constructor

Constructs an instance of this class.

SQLiteModuleNoop(
string name
);

Parameters

name
The name of the module. This parameter cannot be null.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop Methods

The methods of the SQLiteModuleNoop class are listed below. For a complete list of SQLiteModuleNoop class members, see the SQLiteModuleNoop Members topic.

Public Instance Methods

Begin | See the Begin method.
BestIndex | See the BestIndex method.
Close | See the Close method.
Column | See the Column method.
Commit | See the Commit method.
Connect | See the Connect method.
Create | See the Create method.
Destroy | See the Destroy method.
Disconnect | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | See the Filter method.
FindFunction | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next | See the Next method.
Open | See the Open method.
Release | See the Release method.
Rename | See the Rename method.
Rollback | See the Rollback method.
RollbackTo | See the RollbackTo method.
RowId | See the RowId method.
Savepoint | See the Savepoint method.
Sync | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update | See the Update method.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Begin Method

See the Begin method.

public override SQLiteErrorCode Begin(
SQLiteVirtualTable table
);

Parameters

table
See the Begin method.

Return Value

See the Begin method.

Implements

ISQLiteManagedModule.Begin

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.BestIndex Method

See the BestIndex method.

public override SQLiteErrorCode BestIndex(
SQLiteVirtualTable table,
SQLiteIndex index
);

Parameters

table
See the BestIndex method.
index
See the BestIndex method.

Return Value

See the BestIndex method.

Implements

ISQLiteManagedModule.BestIndex

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Close Method

See the Close method.

public override SQLiteErrorCode Close(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
See the Close method.

Return Value

See the Close method.

Implements

ISQLiteManagedModule.Close

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Column Method

See the Column method.

public override SQLiteErrorCode Column(
SQLiteVirtualTableCursor cursor,
SQLiteContext context,
int index
);

Parameters

cursor
See the Column method.
context
See the Column method.
index
See the Column method.

Return Value

See the Column method.

Implements

ISQLiteManagedModule.Column

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Commit Method

See the Commit method.

public override SQLiteErrorCode Commit(
SQLiteVirtualTable table
);

Parameters

table
See the Commit method.

Return Value

See the Commit method.

Implements

ISQLiteManagedModule.Commit

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Connect Method

See the Connect method.

public override SQLiteErrorCode Connect(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
See the Connect method.
pClientData
See the Connect method.
arguments
See the Connect method.
table
See the Connect method.
error
See the Connect method.

Return Value

See the Connect method.

Implements

ISQLiteManagedModule.Connect

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Create Method

See the Create method.

public override SQLiteErrorCode Create(
SQLiteConnection connection,
IntPtr pClientData,
string[] arguments,
ref SQLiteVirtualTable table,
ref string error
);

Parameters

connection
See the Create method.
pClientData
See the Create method.
arguments
See the Create method.
table
See the Create method.
error
See the Create method.

Return Value

See the Create method.

Implements

ISQLiteManagedModule.Create

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Destroy Method

See the Destroy method.

public override SQLiteErrorCode Destroy(
SQLiteVirtualTable table
);

Parameters

table
See the Destroy method.

Return Value

See the Destroy method.

Implements

ISQLiteManagedModule.Destroy

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Disconnect Method

See the Disconnect method.

public override SQLiteErrorCode Disconnect(
SQLiteVirtualTable table
);

Parameters

table
See the Disconnect method.

Return Value

See the Disconnect method.

Implements

ISQLiteManagedModule.Disconnect

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteModuleNoop.Dispose Method

Disposes of this object instance.

Overload List

Inherited from SQLiteModule.

public void Dispose()

Disposes of this object instance.

protected override void Dispose(bool)

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Dispose(Boolean) Method

Disposes of this object instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace | SQLiteModuleNoop.Dispose Overload List


SQLiteModuleNoop.Eof Method

See the Eof method.

public override bool Eof(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
See the Eof method.

Return Value

See the Eof method.

Implements

ISQLiteManagedModule.Eof

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Filter Method

See the Filter method.

public override SQLiteErrorCode Filter(
SQLiteVirtualTableCursor cursor,
int indexNumber,
string indexString,
SQLiteValue[] values
);

Parameters

cursor
See the Filter method.
indexNumber
See the Filter method.
indexString
See the Filter method.
values
See the Filter method.

Return Value

See the Filter method.

Implements

ISQLiteManagedModule.Filter

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.FindFunction Method

See the FindFunction method.

public override bool FindFunction(
SQLiteVirtualTable table,
int argumentCount,
string name,
ref SQLiteFunction function,
ref IntPtr pClientData
);

Parameters

table
See the FindFunction method.
argumentCount
See the FindFunction method.
name
See the FindFunction method.
function
See the FindFunction method.
pClientData
See the FindFunction method.

Return Value

See the FindFunction method.

Implements

ISQLiteManagedModule.FindFunction

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.GetDefaultResultCode Method

Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.

protected virtual SQLiteErrorCode GetDefaultResultCode();

Return Value

The SQLiteErrorCode value that should be returned by all ISQLiteManagedModule interface methods unless a more specific result code has been set for that interface method.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.GetMethodResultCode Method

Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.

protected virtual SQLiteErrorCode GetMethodResultCode(
string methodName
);

Parameters

methodName
The name of the method. Currently, this method must be part of the ISQLiteManagedModule interface.

Return Value

The SQLiteErrorCode value that should be returned by the ISQLiteManagedModule interface method.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Next Method

See the Next method.

public override SQLiteErrorCode Next(
SQLiteVirtualTableCursor cursor
);

Parameters

cursor
See the Next method.

Return Value

See the Next method.

Implements

ISQLiteManagedModule.Next

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Open Method

See the Open method.

public override SQLiteErrorCode Open(
SQLiteVirtualTable table,
ref SQLiteVirtualTableCursor cursor
);

Parameters

table
See the Open method.
cursor
See the Open method.

Return Value

See the Open method.

Implements

ISQLiteManagedModule.Open

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Release Method

See the Release method.

public override SQLiteErrorCode Release(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
See the Release method.
savepoint
See the Release method.

Return Value

See the Release method.

Implements

ISQLiteManagedModule.Release

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Rename Method

See the Rename method.

public override SQLiteErrorCode Rename(
SQLiteVirtualTable table,
string newName
);

Parameters

table
See the Rename method.
newName
See the Rename method.

Return Value

See the Rename method.

Implements

ISQLiteManagedModule.Rename

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.ResultCodeToEofResult Method

Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.

protected virtual bool ResultCodeToEofResult(
SQLiteErrorCode resultCode
);

Parameters

resultCode
The SQLiteErrorCode value to convert.

Return Value

The Boolean value.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.ResultCodeToFindFunctionResult Method

Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.

protected virtual bool ResultCodeToFindFunctionResult(
SQLiteErrorCode resultCode
);

Parameters

resultCode
The SQLiteErrorCode value to convert.

Return Value

The Boolean value.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Rollback Method

See the Rollback method.

public override SQLiteErrorCode Rollback(
SQLiteVirtualTable table
);

Parameters

table
See the Rollback method.

Return Value

See the Rollback method.

Implements

ISQLiteManagedModule.Rollback

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.RollbackTo Method

See the RollbackTo method.

public override SQLiteErrorCode RollbackTo(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
See the RollbackTo method.
savepoint
See the RollbackTo method.

Return Value

See the RollbackTo method.

Implements

ISQLiteManagedModule.RollbackTo

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.RowId Method

See the RowId method.

public override SQLiteErrorCode RowId(
SQLiteVirtualTableCursor cursor,
ref long rowId
);

Parameters

cursor
See the RowId method.
rowId
See the RowId method.

Return Value

See the RowId method.

Implements

ISQLiteManagedModule.RowId

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Savepoint Method

See the Savepoint method.

public override SQLiteErrorCode Savepoint(
SQLiteVirtualTable table,
int savepoint
);

Parameters

table
See the Savepoint method.
savepoint
See the Savepoint method.

Return Value

See the Savepoint method.

Implements

ISQLiteManagedModule.Savepoint

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.SetMethodResultCode Method

Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.

protected virtual bool SetMethodResultCode(
string methodName,
SQLiteErrorCode resultCode
);

Parameters

methodName
The name of the method. Currently, this method must be part of the ISQLiteManagedModule interface.
resultCode
The SQLiteErrorCode value that should be returned by the ISQLiteManagedModule interface method.

Return Value

Non-zero upon success.

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Sync Method

See the Sync method.

public override SQLiteErrorCode Sync(
SQLiteVirtualTable table
);

Parameters

table
See the Sync method.

Return Value

See the Sync method.

Implements

ISQLiteManagedModule.Sync

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteModuleNoop.Update Method

See the Update method.

public override SQLiteErrorCode Update(
SQLiteVirtualTable table,
SQLiteValue[] values,
ref long rowId
);

Parameters

table
See the Update method.
values
See the Update method.
rowId
See the Update method.

Return Value

See the Update method.

Implements

ISQLiteManagedModule.Update

See Also

SQLiteModuleNoop Class | System.Data.SQLite Namespace


SQLiteParameter Class

SQLite implementation of DbParameter.

For a list of all members of this type, see SQLiteParameter Members .

System.Object
MarshalByRefObject
DbParameter
SQLiteParameter

public sealed class SQLiteParameter : DbParameter, ICloneable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteParameter Members | System.Data.SQLite Namespace


SQLiteParameter Members

SQLiteParameter overview

Public Instance Constructors

SQLiteParameter Overloaded. Initializes a new instance of the SQLiteParameter class.

Public Instance Properties

Command | The command associated with this parameter.
DbType | Returns the datatype of the parameter
Direction | Supports only input parameters
IsNullable | Whether or not the parameter can contain a null value
ParameterName | Returns the parameter name
Size | Returns the size of the parameter
SourceColumn | Gets/sets the source column
SourceColumnNullMapping | Used by DbCommandBuilder to determine the mapping for nullable fields
SourceVersion | Gets and sets the row version
TypeName | The database type name associated with this parameter, if any.
Value | Gets and sets the parameter value. If no datatype was specified, the datatype will assume the type from the value given.

Public Instance Methods

Clone | Clones a parameter
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ResetDbType | Resets the DbType of the parameter so it can be inferred from the value
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SQLiteParameter Constructor

Default constructor

Overload List

Default constructor

public SQLiteParameter()

Constructs an unnamed parameter of the specified data type

public SQLiteParameter(DbType)

Constructs an unnamed parameter of the specified type and size

public SQLiteParameter(DbType,int)

Constructs an unnamed parameter of the specified type, size, and source column

public SQLiteParameter(DbType,int,string)

Constructs an unnamed parameter of the specified type, size, source column and row version

public SQLiteParameter(DbType,int,string,DataRowVersion)

Constructs an unnamed parameter of the specified data type and sets the initial value

public SQLiteParameter(DbType,object)

Constructs an unnamed parameter of the specified data type and source column

public SQLiteParameter(DbType,string)

Constructs an unnamed parameter of the specified data type, source column and row version

public SQLiteParameter(DbType,string,DataRowVersion)

Constructs a named parameter given the specified parameter name

public SQLiteParameter(string)

Constructs a named parameter of the specified type

public SQLiteParameter(string,DbType)

Constructs a named parameter of the specified type and size

public SQLiteParameter(string,DbType,int)

Constructs a named parameter of the specified type, size, source column and row version

public SQLiteParameter(string,DbType,int,ParameterDirection,bool,byte,byte,string,DataRowVersion,object)

Constructs a named parameter, yet another flavor

public SQLiteParameter(string,DbType,int,ParameterDirection,byte,byte,string,DataRowVersion,bool,object)

Constructs a named parameter of the specified type, size and source column

public SQLiteParameter(string,DbType,int,string)

Constructs a named parameter of the specified type, size, source column and row version

public SQLiteParameter(string,DbType,int,string,DataRowVersion)

Constructs a named parameter of the specified type and source column reference

public SQLiteParameter(string,DbType,string)

Constructs a named parameter of the specified type, source column and row version

public SQLiteParameter(string,DbType,string,DataRowVersion)

Constructs a named parameter given the specified parameter name and initial value

public SQLiteParameter(string,object)

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SQLiteParameter Constructor

Default constructor

SQLiteParameter();

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter given the specified parameter name

SQLiteParameter(
string parameterName
);

Parameters

parameterName
The parameter name

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter given the specified parameter name and initial value

SQLiteParameter(
string parameterName,
object value
);

Parameters

parameterName
The parameter name
value
The initial value of the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type

SQLiteParameter(
string parameterName,
DbType dbType
);

Parameters

parameterName
The parameter name
dbType
The datatype of the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type and source column reference

SQLiteParameter(
string parameterName,
DbType dbType,
string sourceColumn
);

Parameters

parameterName
The parameter name
dbType
The data type
sourceColumn
The source column

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type, source column and row version

SQLiteParameter(
string parameterName,
DbType dbType,
string sourceColumn,
DataRowVersion rowVersion
);

Parameters

parameterName
The parameter name
dbType
The data type
sourceColumn
The source column
rowVersion
The row version information

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified data type

SQLiteParameter(
DbType dbType
);

Parameters

dbType
The datatype of the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified data type and sets the initial value

SQLiteParameter(
DbType dbType,
object value
);

Parameters

dbType
The datatype of the parameter
value
The initial value of the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified data type and source column

SQLiteParameter(
DbType dbType,
string sourceColumn
);

Parameters

dbType
The datatype of the parameter
sourceColumn
The source column

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified data type, source column and row version

SQLiteParameter(
DbType dbType,
string sourceColumn,
DataRowVersion rowVersion
);

Parameters

dbType
The data type
sourceColumn
The source column
rowVersion
The row version information

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type and size

SQLiteParameter(
string parameterName,
DbType parameterType,
int parameterSize
);

Parameters

parameterName
The parameter name
parameterType
The data type
parameterSize
The size of the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type, size and source column

SQLiteParameter(
string parameterName,
DbType parameterType,
int parameterSize,
string sourceColumn
);

Parameters

parameterName
The name of the parameter
parameterType
The data type
parameterSize
The size of the parameter
sourceColumn
The source column

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type, size, source column and row version

SQLiteParameter(
string parameterName,
DbType parameterType,
int parameterSize,
string sourceColumn,
DataRowVersion rowVersion
);

Parameters

parameterName
The name of the parameter
parameterType
The data type
parameterSize
The size of the parameter
sourceColumn
The source column
rowVersion
The row version information

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter of the specified type, size, source column and row version

SQLiteParameter(
string parameterName,
DbType parameterType,
int parameterSize,
ParameterDirection direction,
bool isNullable,
byte precision,
byte scale,
string sourceColumn,
DataRowVersion rowVersion,
object value
);

Parameters

parameterName
The name of the parameter
parameterType
The data type
parameterSize
The size of the parameter
direction
Only input parameters are supported in SQLite
isNullable
Ignored
precision
Ignored
scale
Ignored
sourceColumn
The source column
rowVersion
The row version information
value
The initial value to assign the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs a named parameter, yet another flavor

SQLiteParameter(
string parameterName,
DbType parameterType,
int parameterSize,
ParameterDirection direction,
byte precision,
byte scale,
string sourceColumn,
DataRowVersion rowVersion,
bool sourceColumnNullMapping,
object value
);

Parameters

parameterName
The name of the parameter
parameterType
The data type
parameterSize
The size of the parameter
direction
Only input parameters are supported in SQLite
precision
Ignored
scale
Ignored
sourceColumn
The source column
rowVersion
The row version information
sourceColumnNullMapping
Whether or not this parameter is for comparing NULL's
value
The intial value to assign the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified type and size

SQLiteParameter(
DbType parameterType,
int parameterSize
);

Parameters

parameterType
The data type
parameterSize
The size of the parameter

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified type, size, and source column

SQLiteParameter(
DbType parameterType,
int parameterSize,
string sourceColumn
);

Parameters

parameterType
The data type
parameterSize
The size of the parameter
sourceColumn
The source column

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Constructor

Constructs an unnamed parameter of the specified type, size, source column and row version

SQLiteParameter(
DbType parameterType,
int parameterSize,
string sourceColumn,
DataRowVersion rowVersion
);

Parameters

parameterType
The data type
parameterSize
The size of the parameter
sourceColumn
The source column
rowVersion
The row version information

See Also

SQLiteParameter Class | System.Data.SQLite Namespace | SQLiteParameter Constructor Overload List


SQLiteParameter Properties

The properties of the SQLiteParameter class are listed below. For a complete list of SQLiteParameter class members, see the SQLiteParameter Members topic.

Public Instance Properties

Command | The command associated with this parameter.
DbType | Returns the datatype of the parameter
Direction | Supports only input parameters
IsNullable | Whether or not the parameter can contain a null value
ParameterName | Returns the parameter name
Size | Returns the size of the parameter
SourceColumn | Gets/sets the source column
SourceColumnNullMapping | Used by DbCommandBuilder to determine the mapping for nullable fields
SourceVersion | Gets and sets the row version
TypeName | The database type name associated with this parameter, if any.
Value | Gets and sets the parameter value. If no datatype was specified, the datatype will assume the type from the value given.

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


Command Property

SQLite ADO.NET Provider

SQLiteParameter.Command Property

The command associated with this parameter.

public IDbCommand Command { public get; public set; }

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


DbType Property

SQLite ADO.NET Provider

SQLiteParameter.DbType Property

Returns the datatype of the parameter

public override DbType DbType { public get; public set; }

Implements

IDataParameter.DbType

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


Direction Property

SQLite ADO.NET Provider

SQLiteParameter.Direction Property

Supports only input parameters

public override ParameterDirection Direction { public get; public set; }

Implements

IDataParameter.Direction

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


IsNullable Property

SQLite ADO.NET Provider

SQLiteParameter.IsNullable Property

Whether or not the parameter can contain a null value

public override bool IsNullable { public get; public set; }

Implements

IDataParameter.IsNullable

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


ParameterName Property

SQLite ADO.NET Provider

SQLiteParameter.ParameterName Property

Returns the parameter name

public override string ParameterName { public get; public set; }

Implements

IDataParameter.ParameterName

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


Size Property

SQLite ADO.NET Provider

SQLiteParameter.Size Property

Returns the size of the parameter

public override int Size { public get; public set; }

Implements

IDbDataParameter.Size

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SourceColumn Property

SQLite ADO.NET Provider

SQLiteParameter.SourceColumn Property

Gets/sets the source column

public override string SourceColumn { public get; public set; }

Implements

IDataParameter.SourceColumn

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SourceColumnNullMapping Property

SQLite ADO.NET Provider

SQLiteParameter.SourceColumnNullMapping Property

Used by DbCommandBuilder to determine the mapping for nullable fields

public override bool SourceColumnNullMapping { public get; public set; }

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SourceVersion Property

SQLite ADO.NET Provider

SQLiteParameter.SourceVersion Property

Gets and sets the row version

public override DataRowVersion SourceVersion { public get; public set; }

Implements

IDataParameter.SourceVersion

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


TypeName Property

SQLite ADO.NET Provider

SQLiteParameter.TypeName Property

The database type name associated with this parameter, if any.

public string TypeName { public get; public set; }

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


Value Property

SQLite ADO.NET Provider

SQLiteParameter.Value Property

Gets and sets the parameter value. If no datatype was specified, the datatype will assume the type from the value given.

public override object Value { public get; public set; }

Implements

IDataParameter.Value

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SQLiteParameter Methods

The methods of the SQLiteParameter class are listed below. For a complete list of SQLiteParameter class members, see the SQLiteParameter Members topic.

Public Instance Methods

Clone | Clones a parameter
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
ResetDbType | Resets the DbType of the parameter so it can be inferred from the value
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SQLiteParameter.Clone Method

Clones a parameter

public object Clone();

Return Value

A new, unassociated SQLiteParameter

Implements

ICloneable.Clone

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SQLiteParameter.ResetDbType Method

Resets the DbType of the parameter so it can be inferred from the value

public override void ResetDbType();

See Also

SQLiteParameter Class | System.Data.SQLite Namespace


SQLiteParameterCollection Class

SQLite implementation of DbParameterCollection.

For a list of all members of this type, see SQLiteParameterCollection Members .

System.Object
MarshalByRefObject
DbParameterCollection
SQLiteParameterCollection

public sealed class SQLiteParameterCollection : DbParameterCollection

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteParameterCollection Members | System.Data.SQLite Namespace


SQLiteParameterCollection Members

SQLiteParameterCollection overview

Public Instance Properties

Count | Returns a count of parameters in the collection
IsFixedSize | Returns false
IsReadOnly | Returns false
IsSynchronized | Returns false
Item | Overloaded. Overloaded to specialize the return value of the default indexer
SyncRoot | Returns null

Public Instance Methods

Add | Overloaded. Adds a parameter to the collection
AddRange | Overloaded. Adds an array of parameters to the collection
AddWithValue | Adds a named/unnamed parameter and its value to the parameter collection.
Clear | Clears the array and resets the collection
Contains | Overloaded. Determines if the named parameter exists in the collection
CopyTo | Not implemented
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetEnumerator | Retrieves an enumerator for the collection
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
IndexOf | Overloaded. Returns the index of a parameter given its name
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Insert | Inserts a parameter into the array at the specified location
Remove | Removes a parameter from the collection
RemoveAt | Overloaded. Removes a parameter from the collection given its name
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetParameter | Overloaded. Retrieve a parameter by name from the collection
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
SetParameter | Overloaded. Re-assign the named parameter to a new parameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection Properties

The properties of the SQLiteParameterCollection class are listed below. For a complete list of SQLiteParameterCollection class members, see the SQLiteParameterCollection Members topic.

Public Instance Properties

Count | Returns a count of parameters in the collection
IsFixedSize | Returns false
IsReadOnly | Returns false
IsSynchronized | Returns false
Item | Overloaded. Overloaded to specialize the return value of the default indexer
SyncRoot | Returns null

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


Count Property

SQLite ADO.NET Provider

SQLiteParameterCollection.Count Property

Returns a count of parameters in the collection

public override int Count { public get; }

Implements

ICollection.Count

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


IsFixedSize Property

SQLite ADO.NET Provider

SQLiteParameterCollection.IsFixedSize Property

Returns false

public override bool IsFixedSize { public get; }

Implements

IList.IsFixedSize

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


IsReadOnly Property

SQLite ADO.NET Provider

SQLiteParameterCollection.IsReadOnly Property

Returns false

public override bool IsReadOnly { public get; }

Implements

IList.IsReadOnly

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


IsSynchronized Property

SQLite ADO.NET Provider

SQLiteParameterCollection.IsSynchronized Property

Returns false

public override bool IsSynchronized { public get; }

Implements

ICollection.IsSynchronized

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameter Property

SQLite ADO.NET Provider

SQLiteParameterCollection.SQLiteParameter Property

Overloaded to specialize the return value of the default indexer

Overload List

Overloaded to specialize the return value of the default indexer

public SQLiteParameter this[ int] { public get; public set; }

Overloaded to specialize the return value of the default indexer

public SQLiteParameter this[ string] { public get; public set; }

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


Item Property

SQLite ADO.NET Provider

SQLiteParameterCollection.Item Property

Overloaded to specialize the return value of the default indexer

public SQLiteParameter this[
int index
] { public get; public set; }

Parameters

index
The index of the parameter to get/set

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Item Overload List


Item Property

SQLite ADO.NET Provider

SQLiteParameterCollection.Item Property

Overloaded to specialize the return value of the default indexer

public SQLiteParameter this[
string parameterName
] { public get; public set; }

Parameters

parameterName
Name of the parameter to get/set

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Item Overload List


SyncRoot Property

SQLite ADO.NET Provider

SQLiteParameterCollection.SyncRoot Property

Returns null

public override object SyncRoot { public get; }

Implements

ICollection.SyncRoot

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection Methods

The methods of the SQLiteParameterCollection class are listed below. For a complete list of SQLiteParameterCollection class members, see the SQLiteParameterCollection Members topic.

Public Instance Methods

Add | Overloaded. Adds a parameter to the collection
AddRange | Overloaded. Adds an array of parameters to the collection
AddWithValue | Adds a named/unnamed parameter and its value to the parameter collection.
Clear | Clears the array and resets the collection
Contains | Overloaded. Determines if the named parameter exists in the collection
CopyTo | Not implemented
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetEnumerator | Retrieves an enumerator for the collection
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
IndexOf | Overloaded. Returns the index of a parameter given its name
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Insert | Inserts a parameter into the array at the specified location
Remove | Removes a parameter from the collection
RemoveAt | Overloaded. Removes a parameter from the collection given its name
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetParameter | Overloaded. Retrieve a parameter by name from the collection
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.
SetParameter | Overloaded. Re-assign the named parameter to a new parameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


Add Method

SQLite ADO.NET Provider

SQLiteParameterCollection.Add Method

Adds a parameter to the collection

Overload List

Adds a parameter to the collection

public int Add(SQLiteParameter)

Adds a parameter to the collection

public override int Add(object)

Adds a parameter to the collection

public SQLiteParameter Add(string,DbType)

Adds a parameter to the collection

public SQLiteParameter Add(string,DbType,int)

Adds a parameter to the collection

public SQLiteParameter Add(string,DbType,int,string)

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.Add(SQLiteParameter) Method

Adds a parameter to the collection

public int Add(
SQLiteParameter parameter
);

Parameters

parameter
The parameter to add

Return Value

A zero-based index of where the parameter is located in the array

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Add Overload List


SQLiteParameterCollection.Add(Object) Method

Adds a parameter to the collection

public override int Add(
object value
);

Parameters

value
The parameter to add

Return Value

A zero-based index of where the parameter is located in the array

Implements

IList.Add

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Add Overload List


SQLiteParameterCollection.Add(String, DbType) Method

Adds a parameter to the collection

public SQLiteParameter Add(
string parameterName,
DbType parameterType
);

Parameters

parameterName
The parameter name
parameterType
The data type

Return Value

A SQLiteParameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Add Overload List


SQLiteParameterCollection.Add(String, DbType, Int32) Method

Adds a parameter to the collection

public SQLiteParameter Add(
string parameterName,
DbType parameterType,
int parameterSize
);

Parameters

parameterName
The parameter name
parameterType
The data type
parameterSize
The size of the value

Return Value

A SQLiteParameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Add Overload List


SQLiteParameterCollection.Add(String, DbType, Int32, String) Method

Adds a parameter to the collection

public SQLiteParameter Add(
string parameterName,
DbType parameterType,
int parameterSize,
string sourceColumn
);

Parameters

parameterName
The parameter name
parameterType
The data type
parameterSize
The size of the value
sourceColumn
The source column

Return Value

A SQLiteParameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Add Overload List


AddRange Method

SQLite ADO.NET Provider

SQLiteParameterCollection.AddRange Method

Adds an array of parameters to the collection

Overload List

Adds an array of parameters to the collection

public override void AddRange(Array)

Adds an array of parameters to the collection

public void AddRange(SQLiteParameter[])

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.AddRange(Array) Method

Adds an array of parameters to the collection

public override void AddRange(
Array values
);

Parameters

values
The array of parameters to add

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.AddRange Overload List


SQLiteParameterCollection.AddRange(SQLiteParameter) Method

Adds an array of parameters to the collection

public void AddRange(
SQLiteParameter[] values
);

Parameters

values
The array of parameters to add

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.AddRange Overload List


SQLiteParameterCollection.AddWithValue Method

Adds a named/unnamed parameter and its value to the parameter collection.

public SQLiteParameter AddWithValue(
string parameterName,
object value
);

Parameters

parameterName
Name of the parameter, or null to indicate an unnamed parameter
value
The initial value of the parameter

Return Value

Returns the SQLiteParameter object created during the call.

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.Clear Method

Clears the array and resets the collection

public override void Clear();

Implements

IList.Clear

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


Contains Method

SQLite ADO.NET Provider

SQLiteParameterCollection.Contains Method

Determines if the parameter exists in the collection

Overload List

Determines if the parameter exists in the collection

public override bool Contains(object)

Determines if the named parameter exists in the collection

public override bool Contains(string)

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.Contains(Object) Method

Determines if the parameter exists in the collection

public override bool Contains(
object value
);

Parameters

value
The SQLiteParameter to check

Return Value

True if the parameter is in the collection

Implements

IList.Contains

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Contains Overload List


SQLiteParameterCollection.Contains(String) Method

Determines if the named parameter exists in the collection

public override bool Contains(
string parameterName
);

Parameters

parameterName
The name of the parameter to check

Return Value

True if the parameter is in the collection

Implements

IDataParameterCollection.Contains

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.Contains Overload List


SQLiteParameterCollection.CopyTo Method

Not implemented

public override void CopyTo(
Array array,
int index
);

Parameters

array
index

Implements

ICollection.CopyTo

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.GetEnumerator Method

Retrieves an enumerator for the collection

public override IEnumerator GetEnumerator();

Return Value

An enumerator for the underlying array

Implements

IEnumerable.GetEnumerator

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


GetParameter Method

SQLite ADO.NET Provider

SQLiteParameterCollection.GetParameter Method

Retrieves a parameter by its index in the collection

Overload List

Retrieves a parameter by its index in the collection

protected override DbParameter GetParameter(int)

Retrieve a parameter by name from the collection

protected override DbParameter GetParameter(string)

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.GetParameter(Int32) Method

Retrieves a parameter by its index in the collection

protected override DbParameter GetParameter(
int index
);

Parameters

index
The index of the parameter to retrieve

Return Value

A DbParameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.GetParameter Overload List


SQLiteParameterCollection.GetParameter(String) Method

Retrieve a parameter by name from the collection

protected override DbParameter GetParameter(
string parameterName
);

Parameters

parameterName
The name of the parameter to fetch

Return Value

A DbParameter object

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.GetParameter Overload List


IndexOf Method

SQLite ADO.NET Provider

SQLiteParameterCollection.IndexOf Method

Returns the index of a parameter

Overload List

Returns the index of a parameter

public override int IndexOf(object)

Returns the index of a parameter given its name

public override int IndexOf(string)

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.IndexOf(Object) Method

Returns the index of a parameter

public override int IndexOf(
object value
);

Parameters

value
The parameter to find

Return Value

-1 if not found, otherwise a zero-based index of the parameter

Implements

IList.IndexOf

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.IndexOf Overload List


SQLiteParameterCollection.IndexOf(String) Method

Returns the index of a parameter given its name

public override int IndexOf(
string parameterName
);

Parameters

parameterName
The name of the parameter to find

Return Value

-1 if not found, otherwise a zero-based index of the parameter

Implements

IDataParameterCollection.IndexOf

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.IndexOf Overload List


SQLiteParameterCollection.Insert Method

Inserts a parameter into the array at the specified location

public override void Insert(
int index,
object value
);

Parameters

index
The zero-based index to insert the parameter at
value
The parameter to insert

Implements

IList.Insert

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.Remove Method

Removes a parameter from the collection

public override void Remove(
object value
);

Parameters

value
The parameter to remove

Implements

IList.Remove

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


RemoveAt Method

SQLite ADO.NET Provider

SQLiteParameterCollection.RemoveAt Method

Removes a parameter from the collection given its index

Overload List

Removes a parameter from the collection given its index

public override void RemoveAt(int)

Removes a parameter from the collection given its name

public override void RemoveAt(string)

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.RemoveAt(Int32) Method

Removes a parameter from the collection given its index

public override void RemoveAt(
int index
);

Parameters

index
The zero-based parameter index to remove

Implements

IList.RemoveAt

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.RemoveAt Overload List


SQLiteParameterCollection.RemoveAt(String) Method

Removes a parameter from the collection given its name

public override void RemoveAt(
string parameterName
);

Parameters

parameterName
The name of the parameter to remove

Implements

IDataParameterCollection.RemoveAt

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.RemoveAt Overload List


SetParameter Method

SQLite ADO.NET Provider

SQLiteParameterCollection.SetParameter Method

Re-assign a parameter at the specified index

Overload List

Re-assign a parameter at the specified index

protected override void SetParameter(int,DbParameter)

Re-assign the named parameter to a new parameter object

protected override void SetParameter(string,DbParameter)

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace


SQLiteParameterCollection.SetParameter(Int32, DbParameter) Method

Re-assign a parameter at the specified index

protected override void SetParameter(
int index,
DbParameter value
);

Parameters

index
The zero-based index of the parameter to replace
value
The new parameter

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.SetParameter Overload List


SQLiteParameterCollection.SetParameter(String, DbParameter) Method

Re-assign the named parameter to a new parameter object

protected override void SetParameter(
string parameterName,
DbParameter value
);

Parameters

parameterName
The name of the parameter to replace
value
The new parameter

See Also

SQLiteParameterCollection Class | System.Data.SQLite Namespace | SQLiteParameterCollection.SetParameter Overload List


SQLiteProgressEventHandler Delegate

Raised each time the number of virtual machine instructions is approximately equal to the value of the ProgressOps property.

public delegate void SQLiteProgressEventHandler(
object sender,
ProgressEventArgs e
);

Parameters

sender
The connection performing the operation.
e
A ProgressEventArgs that contains the event data.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteProgressReturnCode Enumeration

The possible return codes for the progress callback.

public enum SQLiteProgressReturnCode

Members

Member Name | Description
Continue | The operation should continue.
Interrupt | The operation should be interrupted.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteReadArrayEventArgs Class

This class represents the parameters that are provided to the GetBytes and GetChars methods, with the exception of the column index (provided separately).

For a list of all members of this type, see SQLiteReadArrayEventArgs Members .

System.Object
EventArgs
SQLiteReadEventArgs
SQLiteReadArrayEventArgs

public class SQLiteReadArrayEventArgs : SQLiteReadEventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteReadArrayEventArgs Members | System.Data.SQLite Namespace


SQLiteReadArrayEventArgs Members

SQLiteReadArrayEventArgs overview

Public Instance Properties

BufferOffset | The value that was originally specified for the "bufferOffset" parameter to the GetBytes or GetChars methods.
ByteBuffer | The value that was originally specified for the "buffer" parameter to the GetBytes method.
CharBuffer | The value that was originally specified for the "buffer" parameter to the GetChars method.
DataOffset | The value that was originally specified for the "dataOffset" parameter to the GetBytes or GetChars methods.
Length | The value that was originally specified for the "length" parameter to the GetBytes or GetChars methods.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


SQLiteReadArrayEventArgs Properties

The properties of the SQLiteReadArrayEventArgs class are listed below. For a complete list of SQLiteReadArrayEventArgs class members, see the SQLiteReadArrayEventArgs Members topic.

Public Instance Properties

BufferOffset | The value that was originally specified for the "bufferOffset" parameter to the GetBytes or GetChars methods.
ByteBuffer | The value that was originally specified for the "buffer" parameter to the GetBytes method.
CharBuffer | The value that was originally specified for the "buffer" parameter to the GetChars method.
DataOffset | The value that was originally specified for the "dataOffset" parameter to the GetBytes or GetChars methods.
Length | The value that was originally specified for the "length" parameter to the GetBytes or GetChars methods.

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


BufferOffset Property

SQLite ADO.NET Provider

SQLiteReadArrayEventArgs.BufferOffset Property

The value that was originally specified for the "bufferOffset" parameter to the GetBytes or GetChars methods.

public int BufferOffset { public get; public set; }

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


ByteBuffer Property

SQLite ADO.NET Provider

SQLiteReadArrayEventArgs.ByteBuffer Property

The value that was originally specified for the "buffer" parameter to the GetBytes method.

public byte[] ByteBuffer { public get; }

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


CharBuffer Property

SQLite ADO.NET Provider

SQLiteReadArrayEventArgs.CharBuffer Property

The value that was originally specified for the "buffer" parameter to the GetChars method.

public char[] CharBuffer { public get; }

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


DataOffset Property

SQLite ADO.NET Provider

SQLiteReadArrayEventArgs.DataOffset Property

The value that was originally specified for the "dataOffset" parameter to the GetBytes or GetChars methods.

public long DataOffset { public get; public set; }

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


Length Property

SQLite ADO.NET Provider

SQLiteReadArrayEventArgs.Length Property

The value that was originally specified for the "length" parameter to the GetBytes or GetChars methods.

public int Length { public get; public set; }

See Also

SQLiteReadArrayEventArgs Class | System.Data.SQLite Namespace


SQLiteReadBlobEventArgs Class

This class represents the parameters that are provided to the GetBlob method, with the exception of the column index (provided separately).

For a list of all members of this type, see SQLiteReadBlobEventArgs Members .

System.Object
EventArgs
SQLiteReadEventArgs
SQLiteReadBlobEventArgs

public class SQLiteReadBlobEventArgs : SQLiteReadEventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteReadBlobEventArgs Members | System.Data.SQLite Namespace


SQLiteReadBlobEventArgs Members

SQLiteReadBlobEventArgs overview

Public Instance Properties

ReadOnly The value that was originally specified for the "readOnly" parameter to the GetBlob method.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteReadBlobEventArgs Class | System.Data.SQLite Namespace


SQLiteReadBlobEventArgs Properties

The properties of the SQLiteReadBlobEventArgs class are listed below. For a complete list of SQLiteReadBlobEventArgs class members, see the SQLiteReadBlobEventArgs Members topic.

Public Instance Properties

ReadOnly The value that was originally specified for the "readOnly" parameter to the GetBlob method.

See Also

SQLiteReadBlobEventArgs Class | System.Data.SQLite Namespace


ReadOnly Property

SQLite ADO.NET Provider

SQLiteReadBlobEventArgs.ReadOnly Property

The value that was originally specified for the "readOnly" parameter to the GetBlob method.

public bool ReadOnly { public get; public set; }

See Also

SQLiteReadBlobEventArgs Class | System.Data.SQLite Namespace


SQLiteReadEventArgs Class

This class represents the parameters that are provided to the SQLiteDataReader methods, with the exception of the column index (provided separately).

For a list of all members of this type, see SQLiteReadEventArgs Members .

System.Object
EventArgs
SQLiteReadEventArgs
SQLiteReadArrayEventArgs
SQLiteReadBlobEventArgs
SQLiteReadValueEventArgs

public abstract class SQLiteReadEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteReadEventArgs Members | System.Data.SQLite Namespace


SQLiteReadEventArgs Members

SQLiteReadEventArgs overview

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Constructors

SQLiteReadEventArgs Constructor Initializes a new instance of the SQLiteReadEventArgs class.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteReadEventArgs Class | System.Data.SQLite Namespace


SQLiteReadEventArgs Constructor

Initializes a new instance of the SQLiteReadEventArgs class.

SQLiteReadEventArgs();

See Also

SQLiteReadEventArgs Class | System.Data.SQLite Namespace


SQLiteReadValueCallback Delegate

This represents a method that will be called in response to a request to read a value from a data reader. If an exception is thrown, it will cause the data reader operation to fail -AND- it will continue to unwind the call stack.

public delegate void SQLiteReadValueCallback(
SQLiteConvert convert,
SQLiteDataReader dataReader,
SQLiteConnectionFlags flags,
SQLiteReadEventArgs eventArgs,
string typeName,
int index,
object userData,
out bool complete
);

Parameters

convert
The SQLiteConvert instance in use.
dataReader
The SQLiteDataReader instance in use.
flags
The flags associated with the SQLiteConnection instance in use.
eventArgs
The parameter and return type data for the column being read from the data reader.
typeName
The database type name associated with this callback.
index
The zero based index of the column being read from the data reader.
userData
The data originally used when registering this callback.
complete
Non-zero if the default handling for the data reader call should be skipped. If this is set to non-zero and the necessary return value is unavailable or unsuitable, an exception will be thrown.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteReadValueEventArgs Class

This class represents the parameters and return values for the GetBlob, GetBoolean, GetByte, GetBytes, GetChar, GetChars, GetDateTime, GetDecimal, GetDouble, GetFloat, GetGuid, GetInt16, GetInt32, GetInt64, GetString, and GetValue methods.

For a list of all members of this type, see SQLiteReadValueEventArgs Members .

System.Object
EventArgs
SQLiteReadEventArgs
SQLiteReadValueEventArgs

public class SQLiteReadValueEventArgs : SQLiteReadEventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteReadValueEventArgs Members | System.Data.SQLite Namespace


SQLiteReadValueEventArgs Members

SQLiteReadValueEventArgs overview

Public Instance Properties

ExtraEventArgs | If the GetBytes or GetChars method is being called, this object will contain the array related parameters for that method. If the GetBlob method is being called, this object will contain the blob related parameters for that method.
MethodName | The name of the SQLiteDataReader method that was responsible for invoking this callback.
Value | This may be used by the callback to set the return value for the called SQLiteDataReader method.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteReadValueEventArgs Class | System.Data.SQLite Namespace


SQLiteReadValueEventArgs Properties

The properties of the SQLiteReadValueEventArgs class are listed below. For a complete list of SQLiteReadValueEventArgs class members, see the SQLiteReadValueEventArgs Members topic.

Public Instance Properties

ExtraEventArgs | If the GetBytes or GetChars method is being called, this object will contain the array related parameters for that method. If the GetBlob method is being called, this object will contain the blob related parameters for that method.
MethodName | The name of the SQLiteDataReader method that was responsible for invoking this callback.
Value | This may be used by the callback to set the return value for the called SQLiteDataReader method.

See Also

SQLiteReadValueEventArgs Class | System.Data.SQLite Namespace


ExtraEventArgs Property

SQLite ADO.NET Provider

SQLiteReadValueEventArgs.ExtraEventArgs Property

If the GetBytes or GetChars method is being called, this object will contain the array related parameters for that method. If the GetBlob method is being called, this object will contain the blob related parameters for that method.

public SQLiteReadEventArgs ExtraEventArgs { public get; }

See Also

SQLiteReadValueEventArgs Class | System.Data.SQLite Namespace


MethodName Property

SQLite ADO.NET Provider

SQLiteReadValueEventArgs.MethodName Property

The name of the SQLiteDataReader method that was responsible for invoking this callback.

public string MethodName { public get; }

See Also

SQLiteReadValueEventArgs Class | System.Data.SQLite Namespace


Value Property

SQLite ADO.NET Provider

SQLiteReadValueEventArgs.Value Property

This may be used by the callback to set the return value for the called SQLiteDataReader method.

public SQLiteDataReaderValue Value { public get; }

See Also

SQLiteReadValueEventArgs Class | System.Data.SQLite Namespace


SQLiteStepDelegate Delegate

This Delegate type is used with the Step method.

public delegate void SQLiteStepDelegate(
string param0,
object[] args,
int stepNumber,
ref object contextData
);

Parameters

param0
This is always the string literal "Step".
args
The arguments for the aggregate function.
stepNumber
The step number (one based). This is incrememted each time the Step method is called.
contextData
A placeholder for implementers to store contextual data pertaining to the current context.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteTraceEventHandler Delegate

Raised when a statement first begins executing on a given connection

public delegate void SQLiteTraceEventHandler(
object sender,
TraceEventArgs e
);

Parameters

sender
The connection executing the statement
e
Event arguments of the trace

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteTraceFlags Enumeration

These constants are used with the sqlite3_trace_v2() API and the callbacks registered by it.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum SQLiteTraceFlags

Members

Member Name | Description | Value
SQLITE_TRACE_NONE | This value represents a mask where no trace events should be generated. | 0
SQLITE_TRACE_STMT | The trace event invoked when a prepared statement first begins running and possibly at other times during the execution of the prepared statement, such as at the start of each trigger subprogram. | 1
SQLITE_TRACE_PROFILE | The trace event invoked when a prepared statement finishes. It provides a 64-bit integer which is the estimated of the number of nanosecond that the prepared statement took to run. | 2
SQLITE_TRACE_ROW | The trace event invoked when a prepared statement generates a single row of result. | 4
SQLITE_TRACE_CLOSE | The trace event invoked when a database connection closes. | 8
SQLITE_TRACE_ALL | This value represents a mask where all supported trace events should be generated. This value is subject to change, e.g. when additional trace events are added by the SQLite core library. | 15

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteTransaction Class

SQLite implementation of DbTransaction that does not support nested transactions.

For a list of all members of this type, see SQLiteTransaction Members .

System.Object
MarshalByRefObject
DbTransaction
SQLiteTransactionBase
SQLiteTransaction
SQLiteTransaction2

public class SQLiteTransaction : SQLiteTransactionBase

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteTransaction Members | System.Data.SQLite Namespace


SQLiteTransaction Members

SQLiteTransaction overview

Public Instance Properties

Connection (inherited from SQLiteTransactionBase) | Returns the underlying connection to which this transaction applies.
IsolationLevel (inherited from SQLiteTransactionBase) | Gets the isolation level of the transaction. SQLite only supports Serializable transactions.

Public Instance Methods

Commit | Commits the current transaction.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbTransaction) | Overloaded. Releases the unmanaged resources used by the DbTransaction.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Rollback (inherited from SQLiteTransactionBase) | Rolls back the active transaction.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Properties

DbConnection (inherited from SQLiteTransactionBase) Forwards to the local Connection property

Protected Instance Methods

Begin | Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.
Dispose | Overloaded. Disposes the transaction. If it is currently active, any changes are rolled back.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
IssueRollback | Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace


SQLiteTransaction Methods

The methods of the SQLiteTransaction class are listed below. For a complete list of SQLiteTransaction class members, see the SQLiteTransaction Members topic.

Public Instance Methods

Commit | Commits the current transaction.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbTransaction) | Overloaded. Releases the unmanaged resources used by the DbTransaction.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Rollback (inherited from SQLiteTransactionBase) | Rolls back the active transaction.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Begin | Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.
Dispose | Overloaded. Disposes the transaction. If it is currently active, any changes are rolled back.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
IssueRollback | Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace


SQLiteTransaction.Begin Method

Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.

protected override void Begin(
bool deferredLock
);

Parameters

deferredLock
TRUE to defer the writelock, or FALSE to lock immediately

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace


SQLiteTransaction.Commit Method

Commits the current transaction.

public override void Commit();

Implements

IDbTransaction.Commit

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteTransaction.Dispose Method

Disposes the transaction. If it is currently active, any changes are rolled back.

Overload List

Inherited from DbTransaction.

public void Dispose()

Disposes the transaction. If it is currently active, any changes are rolled back.

protected override void Dispose(bool)

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace


SQLiteTransaction.Dispose(Boolean) Method

Disposes the transaction. If it is currently active, any changes are rolled back.

protected override void Dispose(
bool disposing
);

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace | SQLiteTransaction.Dispose Overload List


SQLiteTransaction.IssueRollback Method

Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.

protected override void IssueRollback(
bool throwError
);

Parameters

throwError
Non-zero to re-throw caught exceptions.

See Also

SQLiteTransaction Class | System.Data.SQLite Namespace


SQLiteTransaction2 Class

SQLite implementation of DbTransaction that does support nested transactions.

For a list of all members of this type, see SQLiteTransaction2 Members .

System.Object
MarshalByRefObject
DbTransaction
SQLiteTransactionBase
SQLiteTransaction
SQLiteTransaction2

public sealed class SQLiteTransaction2 : SQLiteTransaction

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteTransaction2 Members | System.Data.SQLite Namespace


SQLiteTransaction2 Members

SQLiteTransaction2 overview

Public Instance Properties

Connection (inherited from SQLiteTransactionBase) | Returns the underlying connection to which this transaction applies.
IsolationLevel (inherited from SQLiteTransactionBase) | Gets the isolation level of the transaction. SQLite only supports Serializable transactions.

Public Instance Methods

Commit | Commits the current transaction.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbTransaction) | Overloaded. Releases the unmanaged resources used by the DbTransaction.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Rollback (inherited from SQLiteTransactionBase) | Rolls back the active transaction.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Properties

DbConnection (inherited from SQLiteTransactionBase) Forwards to the local Connection property

Protected Instance Methods

Begin | Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.
Dispose | Overloaded. Disposes the transaction. If it is currently active, any changes are rolled back.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
IssueRollback | Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace


SQLiteTransaction2 Methods

The methods of the SQLiteTransaction2 class are listed below. For a complete list of SQLiteTransaction2 class members, see the SQLiteTransaction2 Members topic.

Public Instance Methods

Commit | Commits the current transaction.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbTransaction) | Overloaded. Releases the unmanaged resources used by the DbTransaction.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Rollback (inherited from SQLiteTransactionBase) | Rolls back the active transaction.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Begin | Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.
Dispose | Overloaded. Disposes the transaction. If it is currently active, any changes are rolled back.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
IssueRollback | Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace


SQLiteTransaction2.Begin Method

Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.

protected override void Begin(
bool deferredLock
);

Parameters

deferredLock
TRUE to defer the writelock, or FALSE to lock immediately

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace


SQLiteTransaction2.Commit Method

Commits the current transaction.

public override void Commit();

Implements

IDbTransaction.Commit

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteTransaction2.Dispose Method

Disposes the transaction. If it is currently active, any changes are rolled back.

Overload List

Inherited from DbTransaction.

public void Dispose()

Disposes the transaction. If it is currently active, any changes are rolled back.

protected override void Dispose(bool)

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace


SQLiteTransaction2.Dispose(Boolean) Method

Disposes the transaction. If it is currently active, any changes are rolled back.

protected override void Dispose(
bool disposing
);

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace | SQLiteTransaction2.Dispose Overload List


SQLiteTransaction2.IssueRollback Method

Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.

protected override void IssueRollback(
bool throwError
);

Parameters

throwError
Non-zero to re-throw caught exceptions.

See Also

SQLiteTransaction2 Class | System.Data.SQLite Namespace


SQLiteTransactionBase Class

Base class used by to implement DbTransaction for SQLite.

For a list of all members of this type, see SQLiteTransactionBase Members .

System.Object
MarshalByRefObject
DbTransaction
SQLiteTransactionBase
SQLiteTransaction

public abstract class SQLiteTransactionBase : DbTransaction

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteTransactionBase Members | System.Data.SQLite Namespace


SQLiteTransactionBase Members

SQLiteTransactionBase overview

Public Instance Properties

Connection | Overloaded. Returns the underlying connection to which this transaction applies.
IsolationLevel | Gets the isolation level of the transaction. SQLite only supports Serializable transactions.

Public Instance Methods

Commit (inherited from DbTransaction) | Commits the database transaction.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbTransaction) | Overloaded. Releases the unmanaged resources used by the DbTransaction.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Rollback | Rolls back the active transaction.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Properties

DbConnection Forwards to the local Connection property

Protected Instance Methods

Begin | Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.
Dispose | Overloaded. Disposes the transaction. If it is currently active, any changes are rolled back.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
IssueRollback | Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


SQLiteTransactionBase Properties

The properties of the SQLiteTransactionBase class are listed below. For a complete list of SQLiteTransactionBase class members, see the SQLiteTransactionBase Members topic.

Public Instance Properties

Connection | Overloaded. Returns the underlying connection to which this transaction applies.
IsolationLevel | Gets the isolation level of the transaction. SQLite only supports Serializable transactions.

Protected Instance Properties

DbConnection Forwards to the local Connection property

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


Connection Property

SQLite ADO.NET Provider

SQLiteTransactionBase.Connection Property

Returns the underlying connection to which this transaction applies.

new public SQLiteConnection Connection { public get; }

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


DbConnection Property

SQLite ADO.NET Provider

SQLiteTransactionBase.DbConnection Property

Forwards to the local Connection property

protected override DbConnection DbConnection { protected get; }

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


IsolationLevel Property

SQLite ADO.NET Provider

SQLiteTransactionBase.IsolationLevel Property

Gets the isolation level of the transaction. SQLite only supports Serializable transactions.

public override IsolationLevel IsolationLevel { public get; }

Implements

IDbTransaction.IsolationLevel

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


SQLiteTransactionBase Methods

The methods of the SQLiteTransactionBase class are listed below. For a complete list of SQLiteTransactionBase class members, see the SQLiteTransactionBase Members topic.

Public Instance Methods

Commit (inherited from DbTransaction) | Commits the database transaction.
CreateObjRef (inherited from MarshalByRefObject) | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
Dispose (inherited from DbTransaction) | Overloaded. Releases the unmanaged resources used by the DbTransaction.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetLifetimeService (inherited from MarshalByRefObject) | Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType (inherited from Object) | Gets the Type of the current instance.
InitializeLifetimeService (inherited from MarshalByRefObject) | Obtains a lifetime service object to control the lifetime policy for this instance.
Rollback | Rolls back the active transaction.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Begin | Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.
Dispose | Overloaded. Disposes the transaction. If it is currently active, any changes are rolled back.
Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
IssueRollback | Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.
MemberwiseClone (inherited from MarshalByRefObject) | Overloaded. Creates a shallow copy of the current MarshalByRefObject object.
MemberwiseClone (inherited from Object) | Overloaded. Creates a shallow copy of the current Object.

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


SQLiteTransactionBase.Begin Method

Attempts to start a transaction. An exception will be thrown if the transaction cannot be started for any reason.

protected abstract void Begin(
bool deferredLock
);

Parameters

deferredLock
TRUE to defer the writelock, or FALSE to lock immediately

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteTransactionBase.Dispose Method

Disposes the transaction. If it is currently active, any changes are rolled back.

Overload List

Inherited from DbTransaction.

public void Dispose()

Disposes the transaction. If it is currently active, any changes are rolled back.

protected override void Dispose(bool)

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


SQLiteTransactionBase.Dispose(Boolean) Method

Disposes the transaction. If it is currently active, any changes are rolled back.

protected override void Dispose(
bool disposing
);

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace | SQLiteTransactionBase.Dispose Overload List


SQLiteTransactionBase.IssueRollback Method

Issue a ROLLBACK command against the database connection, optionally re-throwing any caught exception.

protected abstract void IssueRollback(
bool throwError
);

Parameters

throwError
Non-zero to re-throw caught exceptions.

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


SQLiteTransactionBase.Rollback Method

Rolls back the active transaction.

public override void Rollback();

Implements

IDbTransaction.Rollback

See Also

SQLiteTransactionBase Class | System.Data.SQLite Namespace


SQLiteTypeCallbacks Class

This class represents the custom data type handling callbacks for a single type name.

For a list of all members of this type, see SQLiteTypeCallbacks Members .

System.Object
SQLiteTypeCallbacks

public sealed class SQLiteTypeCallbacks

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteTypeCallbacks Members | System.Data.SQLite Namespace


SQLiteTypeCallbacks Members

SQLiteTypeCallbacks overview

Public Static Methods

Create Creates an instance of the SQLiteTypeCallbacks class.

Public Instance Properties

BindValueCallback | The custom paramater binding callback. This value may be null.
BindValueUserData | The extra data to pass into the parameter binding callback. This value may be null.
ReadValueCallback | The custom data reader value callback. This value may be null.
ReadValueUserData | The extra data to pass into the data reader value callback. This value may be null.
TypeName | The database type name that the callbacks contained in this class will apply to. This value may not be null.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


SQLiteTypeCallbacks Properties

The properties of the SQLiteTypeCallbacks class are listed below. For a complete list of SQLiteTypeCallbacks class members, see the SQLiteTypeCallbacks Members topic.

Public Instance Properties

BindValueCallback | The custom paramater binding callback. This value may be null.
BindValueUserData | The extra data to pass into the parameter binding callback. This value may be null.
ReadValueCallback | The custom data reader value callback. This value may be null.
ReadValueUserData | The extra data to pass into the data reader value callback. This value may be null.
TypeName | The database type name that the callbacks contained in this class will apply to. This value may not be null.

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


BindValueCallback Property

SQLite ADO.NET Provider

SQLiteTypeCallbacks.BindValueCallback Property

The custom paramater binding callback. This value may be null.

public SQLiteBindValueCallback BindValueCallback { public get; }

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


BindValueUserData Property

SQLite ADO.NET Provider

SQLiteTypeCallbacks.BindValueUserData Property

The extra data to pass into the parameter binding callback. This value may be null.

public object BindValueUserData { public get; }

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


ReadValueCallback Property

SQLite ADO.NET Provider

SQLiteTypeCallbacks.ReadValueCallback Property

The custom data reader value callback. This value may be null.

public SQLiteReadValueCallback ReadValueCallback { public get; }

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


ReadValueUserData Property

SQLite ADO.NET Provider

SQLiteTypeCallbacks.ReadValueUserData Property

The extra data to pass into the data reader value callback. This value may be null.

public object ReadValueUserData { public get; }

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


TypeName Property

SQLite ADO.NET Provider

SQLiteTypeCallbacks.TypeName Property

The database type name that the callbacks contained in this class will apply to. This value may not be null.

public string TypeName { public get; internal set; }

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


SQLiteTypeCallbacks Methods

The methods of the SQLiteTypeCallbacks class are listed below. For a complete list of SQLiteTypeCallbacks class members, see the SQLiteTypeCallbacks Members topic.

Public Static Methods

Create Creates an instance of the SQLiteTypeCallbacks class.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


SQLiteTypeCallbacks.Create Method

Creates an instance of the SQLiteTypeCallbacks class.

public static SQLiteTypeCallbacks Create(
SQLiteBindValueCallback bindValueCallback,
SQLiteReadValueCallback readValueCallback,
object bindValueUserData,
object readValueUserData
);

Parameters

bindValueCallback
The custom paramater binding callback. This parameter may be null.
readValueCallback
The custom data reader value callback. This parameter may be null.
bindValueUserData
The extra data to pass into the parameter binding callback. This parameter may be null.
readValueUserData
The extra data to pass into the data reader value callback. This parameter may be null.

See Also

SQLiteTypeCallbacks Class | System.Data.SQLite Namespace


SQLiteUpdateEventHandler Delegate

Raised when data is inserted, updated and deleted on a given connection

public delegate void SQLiteUpdateEventHandler(
object sender,
UpdateEventArgs e
);

Parameters

sender
The connection committing the transaction
e
The event parameters which triggered the event

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


SQLiteValue Class

This class represents a value from the SQLite core library that can be passed to the sqlite3_value_*() and associated functions.

For a list of all members of this type, see SQLiteValue Members .

System.Object
SQLiteValue

public sealed class SQLiteValue : ISQLiteNativeHandle

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteValue Members | System.Data.SQLite Namespace


SQLiteValue Members

SQLiteValue overview

Public Instance Properties

FromBind | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that "from bind" flag is returned; otherwise, an exception is thrown.
NativeHandle | Returns the underlying SQLite native handle associated with this object instance.
NoChange | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that "no change" flag is returned; otherwise, an exception is thrown.
Persisted | Returns non-zero if the native SQLite value has been successfully persisted as a managed value within this object instance (i.e. the Value property may then be read successfully).
SubType | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that sub-type is returned; otherwise, an exception is thrown.
Value | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that value is returned; otherwise, an exception is thrown. The returned value may be null.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBlob | Gets and returns the Byte array associated with this value.
GetBytes | Gets and returns the number of bytes associated with this value, if it refers to a UTF-8 encoded string.
GetDouble | Gets and returns the Double associated with this value.
GetFromBind | Gets and returns the "from bind" flag associated with this value.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetInt | Gets and returns the Int32 associated with this value.
GetInt64 | Gets and returns the Int64 associated with this value.
GetNoChange | Gets and returns the "no change" flag associated with this value.
GetNumericType | Attempts to convert this value to numeric and then gets and returns the new type affinity associated with this value.
GetObject | Gets and returns an Object instance associated with this value.
GetString | Gets and returns the String associated with this value.
GetSubType | Gets and returns the sub-type associated with this value.
GetType (inherited from Object) | Gets the Type of the current instance.
GetTypeAffinity | Gets and returns the type affinity associated with this value.
Persist | Uses the native value handle to obtain and store the managed value for this object instance, thus saving it for later use. The type of the managed value is determined by the type affinity of the native value. If the type affinity is not recognized by this method, no work is done and false is returned.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue Properties

The properties of the SQLiteValue class are listed below. For a complete list of SQLiteValue class members, see the SQLiteValue Members topic.

Public Instance Properties

FromBind | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that "from bind" flag is returned; otherwise, an exception is thrown.
NativeHandle | Returns the underlying SQLite native handle associated with this object instance.
NoChange | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that "no change" flag is returned; otherwise, an exception is thrown.
Persisted | Returns non-zero if the native SQLite value has been successfully persisted as a managed value within this object instance (i.e. the Value property may then be read successfully).
SubType | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that sub-type is returned; otherwise, an exception is thrown.
Value | If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that value is returned; otherwise, an exception is thrown. The returned value may be null.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


FromBind Property

SQLite ADO.NET Provider

SQLiteValue.FromBind Property

If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that "from bind" flag is returned; otherwise, an exception is thrown.

public int FromBind { public get; }

See Also

SQLiteValue Class | System.Data.SQLite Namespace


NativeHandle Property

SQLite ADO.NET Provider

SQLiteValue.NativeHandle Property

Returns the underlying SQLite native handle associated with this object instance.

public IntPtr NativeHandle { public get; }

Implements

ISQLiteNativeHandle.NativeHandle

See Also

SQLiteValue Class | System.Data.SQLite Namespace


NoChange Property

SQLite ADO.NET Provider

SQLiteValue.NoChange Property

If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that "no change" flag is returned; otherwise, an exception is thrown.

public int NoChange { public get; }

See Also

SQLiteValue Class | System.Data.SQLite Namespace


Persisted Property

SQLite ADO.NET Provider

SQLiteValue.Persisted Property

Returns non-zero if the native SQLite value has been successfully persisted as a managed value within this object instance (i.e. the Value property may then be read successfully).

public bool Persisted { public get; }

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SubType Property

SQLite ADO.NET Provider

SQLiteValue.SubType Property

If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that sub-type is returned; otherwise, an exception is thrown.

public uint SubType { public get; }

See Also

SQLiteValue Class | System.Data.SQLite Namespace


Value Property

SQLite ADO.NET Provider

SQLiteValue.Value Property

If the managed value for this object instance is available (i.e. it has been previously persisted via the Persist) method, that value is returned; otherwise, an exception is thrown. The returned value may be null.

public object Value { public get; }

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue Methods

The methods of the SQLiteValue class are listed below. For a complete list of SQLiteValue class members, see the SQLiteValue Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetBlob | Gets and returns the Byte array associated with this value.
GetBytes | Gets and returns the number of bytes associated with this value, if it refers to a UTF-8 encoded string.
GetDouble | Gets and returns the Double associated with this value.
GetFromBind | Gets and returns the "from bind" flag associated with this value.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetInt | Gets and returns the Int32 associated with this value.
GetInt64 | Gets and returns the Int64 associated with this value.
GetNoChange | Gets and returns the "no change" flag associated with this value.
GetNumericType | Attempts to convert this value to numeric and then gets and returns the new type affinity associated with this value.
GetObject | Gets and returns an Object instance associated with this value.
GetString | Gets and returns the String associated with this value.
GetSubType | Gets and returns the sub-type associated with this value.
GetType (inherited from Object) | Gets the Type of the current instance.
GetTypeAffinity | Gets and returns the type affinity associated with this value.
Persist | Uses the native value handle to obtain and store the managed value for this object instance, thus saving it for later use. The type of the managed value is determined by the type affinity of the native value. If the type affinity is not recognized by this method, no work is done and false is returned.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetBlob Method

Gets and returns the Byte array associated with this value.

public byte[] GetBlob();

Return Value

The Byte array associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetBytes Method

Gets and returns the number of bytes associated with this value, if it refers to a UTF-8 encoded string.

public int GetBytes();

Return Value

The number of bytes associated with this value. The returned value may be zero.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetDouble Method

Gets and returns the Double associated with this value.

public double GetDouble();

Return Value

The Double associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetFromBind Method

Gets and returns the "from bind" flag associated with this value.

public int GetFromBind();

Return Value

The "from bind" flag associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetInt Method

Gets and returns the Int32 associated with this value.

public int GetInt();

Return Value

The Int32 associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetInt64 Method

Gets and returns the Int64 associated with this value.

public long GetInt64();

Return Value

The Int64 associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetNoChange Method

Gets and returns the "no change" flag associated with this value.

public int GetNoChange();

Return Value

The "no change" flag associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetNumericType Method

Attempts to convert this value to numeric and then gets and returns the new type affinity associated with this value.

public TypeAffinity GetNumericType();

Return Value

The new type affinity associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetObject Method

Gets and returns an Object instance associated with this value.

public object GetObject();

Return Value

The Object associated with this value. If the type affinity of the object is unknown or cannot be determined, a null value will be returned.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetString Method

Gets and returns the String associated with this value.

public string GetString();

Return Value

The String associated with this value. The value is converted from the UTF-8 encoding prior to being returned.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetSubType Method

Gets and returns the sub-type associated with this value.

public uint GetSubType();

Return Value

The sub-type associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.GetTypeAffinity Method

Gets and returns the type affinity associated with this value.

public TypeAffinity GetTypeAffinity();

Return Value

The type affinity associated with this value.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteValue.Persist Method

Uses the native value handle to obtain and store the managed value for this object instance, thus saving it for later use. The type of the managed value is determined by the type affinity of the native value. If the type affinity is not recognized by this method, no work is done and false is returned.

public bool Persist();

Return Value

Non-zero if the native value was persisted successfully.

See Also

SQLiteValue Class | System.Data.SQLite Namespace


SQLiteVirtualTable Class

This class represents a managed virtual table implementation. It is not sealed and should be used as the base class for any user-defined virtual table classes implemented in managed code.

For a list of all members of this type, see SQLiteVirtualTable Members .

System.Object
SQLiteVirtualTable

public class SQLiteVirtualTable : ISQLiteNativeHandle, IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteVirtualTable Members | System.Data.SQLite Namespace


SQLiteVirtualTable Members

SQLiteVirtualTable overview

Public Instance Constructors

SQLiteVirtualTable Constructor Constructs an instance of this class.

Public Instance Properties

Arguments | The original array of strings provided to the Create and Connect methods.
DatabaseName | The name of the database containing this virtual table.
Index | The SQLiteIndex object instance containing all the data for the inputs and outputs relating to the most recent index selection.
ModuleName | The name of the module implementing this virtual table.
NativeHandle | Returns the underlying SQLite native handle associated with this object instance.
TableName | The name of the virtual table.

Public Instance Methods

BestIndex | This method should normally be used by the BestIndex method in order to perform index selection based on the constraints provided by the SQLite core library.
Dispose | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Rename | Attempts to record the renaming of the virtual table associated with this object instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTable Constructor

Constructs an instance of this class.

SQLiteVirtualTable(
string[] arguments
);

Parameters

arguments
The original array of strings provided to the Create and Connect methods.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTable Properties

The properties of the SQLiteVirtualTable class are listed below. For a complete list of SQLiteVirtualTable class members, see the SQLiteVirtualTable Members topic.

Public Instance Properties

Arguments | The original array of strings provided to the Create and Connect methods.
DatabaseName | The name of the database containing this virtual table.
Index | The SQLiteIndex object instance containing all the data for the inputs and outputs relating to the most recent index selection.
ModuleName | The name of the module implementing this virtual table.
NativeHandle | Returns the underlying SQLite native handle associated with this object instance.
TableName | The name of the virtual table.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


Arguments Property

SQLite ADO.NET Provider

SQLiteVirtualTable.Arguments Property

The original array of strings provided to the Create and Connect methods.

public virtual string[] Arguments { public get; }

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


DatabaseName Property

SQLite ADO.NET Provider

SQLiteVirtualTable.DatabaseName Property

The name of the database containing this virtual table.

public virtual string DatabaseName { public get; }

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


Index Property

SQLite ADO.NET Provider

SQLiteVirtualTable.Index Property

The SQLiteIndex object instance containing all the data for the inputs and outputs relating to the most recent index selection.

public virtual SQLiteIndex Index { public get; }

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


ModuleName Property

SQLite ADO.NET Provider

SQLiteVirtualTable.ModuleName Property

The name of the module implementing this virtual table.

public virtual string ModuleName { public get; }

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


NativeHandle Property

SQLite ADO.NET Provider

SQLiteVirtualTable.NativeHandle Property

Returns the underlying SQLite native handle associated with this object instance.

public virtual IntPtr NativeHandle { public get; internal set; }

Implements

ISQLiteNativeHandle.NativeHandle

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


TableName Property

SQLite ADO.NET Provider

SQLiteVirtualTable.TableName Property

The name of the virtual table.

public virtual string TableName { public get; }

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTable Methods

The methods of the SQLiteVirtualTable class are listed below. For a complete list of SQLiteVirtualTable class members, see the SQLiteVirtualTable Members topic.

Public Instance Methods

BestIndex | This method should normally be used by the BestIndex method in order to perform index selection based on the constraints provided by the SQLite core library.
Dispose | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Rename | Attempts to record the renaming of the virtual table associated with this object instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTable.BestIndex Method

This method should normally be used by the BestIndex method in order to perform index selection based on the constraints provided by the SQLite core library.

public virtual bool BestIndex(
SQLiteIndex index
);

Parameters

index
The SQLiteIndex object instance containing all the data for the inputs and outputs relating to index selection.

Return Value

Non-zero upon success.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteVirtualTable.Dispose Method

Disposes of this object instance.

Overload List

Disposes of this object instance.

public void Dispose()

Disposes of this object instance.

protected virtual void Dispose(bool)

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTable.Dispose() Method

Disposes of this object instance.

public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace | SQLiteVirtualTable.Dispose Overload List


SQLiteVirtualTable.Dispose(Boolean) Method

Disposes of this object instance.

protected virtual void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace | SQLiteVirtualTable.Dispose Overload List


SQLiteVirtualTable.Finalize Method

Finalizes this object instance.

protected override void Finalize();

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTable.Rename Method

Attempts to record the renaming of the virtual table associated with this object instance.

public virtual bool Rename(
string name
);

Parameters

name
The new name for the virtual table.

Return Value

Non-zero upon success.

See Also

SQLiteVirtualTable Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor Class

This class represents a managed virtual table cursor implementation. It is not sealed and should be used as the base class for any user-defined virtual table cursor classes implemented in managed code.

For a list of all members of this type, see SQLiteVirtualTableCursor Members .

System.Object
SQLiteVirtualTableCursor
SQLiteVirtualTableCursorEnumerator

public class SQLiteVirtualTableCursor : ISQLiteNativeHandle, IDisposable

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteVirtualTableCursor Members | System.Data.SQLite Namespace


SQLiteVirtualTableCursor Members

SQLiteVirtualTableCursor overview

Protected Static Fields

InvalidRowIndex This value represents an invalid integer row sequence number.

Public Instance Constructors

SQLiteVirtualTableCursor Constructor Constructs an instance of this class.

Public Instance Properties

IndexNumber | Number used to help identify the selected index. This value will be set via the Filter method.
IndexString | String used to help identify the selected index. This value will be set via the Filter method.
NativeHandle | Returns the underlying SQLite native handle associated with this object instance.
Table | The SQLiteVirtualTable object instance associated with this object instance.
Values | The values used to filter the rows returned via this cursor object instance. This value will be set via the Filter method.

Public Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetRowIndex | Determines the integer row sequence number for the current row.
GetType (inherited from Object) | Gets the Type of the current instance.
NextRowIndex | Adjusts the integer row sequence number so that it refers to the next row.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
TryPersistValues | Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor Constructor

Constructs an instance of this class.

SQLiteVirtualTableCursor(
SQLiteVirtualTable table
);

Parameters

table
The SQLiteVirtualTable object instance associated with this object instance.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor Fields

The fields of the SQLiteVirtualTableCursor class are listed below. For a complete list of SQLiteVirtualTableCursor class members, see the SQLiteVirtualTableCursor Members topic.

Protected Static Fields

InvalidRowIndex This value represents an invalid integer row sequence number.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor.InvalidRowIndex Field

This value represents an invalid integer row sequence number.

protected static readonly int InvalidRowIndex;

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor Properties

The properties of the SQLiteVirtualTableCursor class are listed below. For a complete list of SQLiteVirtualTableCursor class members, see the SQLiteVirtualTableCursor Members topic.

Public Instance Properties

IndexNumber | Number used to help identify the selected index. This value will be set via the Filter method.
IndexString | String used to help identify the selected index. This value will be set via the Filter method.
NativeHandle | Returns the underlying SQLite native handle associated with this object instance.
Table | The SQLiteVirtualTable object instance associated with this object instance.
Values | The values used to filter the rows returned via this cursor object instance. This value will be set via the Filter method.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


IndexNumber Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursor.IndexNumber Property

Number used to help identify the selected index. This value will be set via the Filter method.

public virtual int IndexNumber { public get; }

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


IndexString Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursor.IndexString Property

String used to help identify the selected index. This value will be set via the Filter method.

public virtual string IndexString { public get; }

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


NativeHandle Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursor.NativeHandle Property

Returns the underlying SQLite native handle associated with this object instance.

public virtual IntPtr NativeHandle { public get; internal set; }

Implements

ISQLiteNativeHandle.NativeHandle

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


Table Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursor.Table Property

The SQLiteVirtualTable object instance associated with this object instance.

public virtual SQLiteVirtualTable Table { public get; }

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


Values Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursor.Values Property

The values used to filter the rows returned via this cursor object instance. This value will be set via the Filter method.

public virtual SQLiteValue[] Values { public get; }

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor Methods

The methods of the SQLiteVirtualTableCursor class are listed below. For a complete list of SQLiteVirtualTableCursor class members, see the SQLiteVirtualTableCursor Members topic.

Public Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter | This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetRowIndex | Determines the integer row sequence number for the current row.
GetType (inherited from Object) | Gets the Type of the current instance.
NextRowIndex | Adjusts the integer row sequence number so that it refers to the next row.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
TryPersistValues | Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteVirtualTableCursor.Dispose Method

Disposes of this object instance.

Overload List

Disposes of this object instance.

public void Dispose()

Disposes of this object instance.

protected virtual void Dispose(bool)

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor.Dispose() Method

Disposes of this object instance.

public void Dispose();

Implements

IDisposable.Dispose

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace | SQLiteVirtualTableCursor.Dispose Overload List


SQLiteVirtualTableCursor.Dispose(Boolean) Method

Disposes of this object instance.

protected virtual void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace | SQLiteVirtualTableCursor.Dispose Overload List


SQLiteVirtualTableCursor.Filter Method

This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.

public virtual void Filter(
int indexNumber,
string indexString,
SQLiteValue[] values
);

Parameters

indexNumber
Number used to help identify the selected index.
indexString
String used to help identify the selected index.
values
The values corresponding to each column in the selected index.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor.Finalize Method

Finalizes this object instance.

protected override void Finalize();

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor.GetRowIndex Method

Determines the integer row sequence number for the current row.

public virtual int GetRowIndex();

Return Value

The integer row sequence number for the current row -OR- zero if it cannot be determined.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor.NextRowIndex Method

Adjusts the integer row sequence number so that it refers to the next row.

public virtual void NextRowIndex();

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursor.TryPersistValues Method

Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

protected virtual int TryPersistValues(
SQLiteValue[] values
);

Parameters

values
The array of SQLiteValue object instances to be persisted.

Return Value

The number of SQLiteValue object instances that were successfully persisted.

See Also

SQLiteVirtualTableCursor Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator Class

This class represents a virtual table cursor to be used with the SQLiteModuleEnumerable class. It is not sealed and may be used as the base class for any user-defined virtual table cursor class that wraps an IEnumerator object instance.

For a list of all members of this type, see SQLiteVirtualTableCursorEnumerator Members .

System.Object
SQLiteVirtualTableCursor
SQLiteVirtualTableCursorEnumerator
SQLiteVirtualTableCursorEnumerator(T)

public class SQLiteVirtualTableCursorEnumerator : SQLiteVirtualTableCursor, IEnumerator

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteVirtualTableCursorEnumerator Members | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator Members

SQLiteVirtualTableCursorEnumerator overview

Public Instance Constructors

SQLiteVirtualTableCursorEnumerator Constructor Constructs an instance of this class.

Public Instance Properties

Current | Returns the value for the current row of the virtual table cursor using the Current property of the IEnumerator object instance.
EndOfEnumerator | Returns non-zero if the end of the virtual table cursor has been seen (i.e. no more rows are available, including the current one).
IndexNumber (inherited from SQLiteVirtualTableCursor) | Number used to help identify the selected index. This value will be set via the Filter method.
IndexString (inherited from SQLiteVirtualTableCursor) | String used to help identify the selected index. This value will be set via the Filter method.
IsOpen | Returns non-zero if the virtual table cursor is open.
NativeHandle (inherited from SQLiteVirtualTableCursor) | Returns the underlying SQLite native handle associated with this object instance.
Table (inherited from SQLiteVirtualTableCursor) | The SQLiteVirtualTable object instance associated with this object instance.
Values (inherited from SQLiteVirtualTableCursor) | The values used to filter the rows returned via this cursor object instance. This value will be set via the Filter method.

Public Instance Methods

CheckClosed | Throws an InvalidOperationException if the virtual table cursor has been closed.
Close | Closes the virtual table cursor. This method must not throw any exceptions.
Dispose (inherited from SQLiteVirtualTableCursor) | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteVirtualTableCursor) | This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetRowIndex (inherited from SQLiteVirtualTableCursor) | Determines the integer row sequence number for the current row.
GetType (inherited from Object) | Gets the Type of the current instance.
MoveNext | Advances to the next row of the virtual table cursor using the MoveNext method of the IEnumerator object instance.
NextRowIndex (inherited from SQLiteVirtualTableCursor) | Adjusts the integer row sequence number so that it refers to the next row.
Reset | Resets the virtual table cursor position, also invalidating the current row, using the Reset method of the IEnumerator object instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteVirtualTableCursor) | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
TryPersistValues (inherited from SQLiteVirtualTableCursor) | Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator Constructor

Constructs an instance of this class.

SQLiteVirtualTableCursorEnumerator(
SQLiteVirtualTable table,
IEnumerator enumerator
);

Parameters

table
The SQLiteVirtualTable object instance associated with this object instance.
enumerator
The IEnumerator instance to expose as a virtual table cursor.

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator Properties

The properties of the SQLiteVirtualTableCursorEnumerator class are listed below. For a complete list of SQLiteVirtualTableCursorEnumerator class members, see the SQLiteVirtualTableCursorEnumerator Members topic.

Public Instance Properties

Current | Returns the value for the current row of the virtual table cursor using the Current property of the IEnumerator object instance.
EndOfEnumerator | Returns non-zero if the end of the virtual table cursor has been seen (i.e. no more rows are available, including the current one).
IndexNumber (inherited from SQLiteVirtualTableCursor) | Number used to help identify the selected index. This value will be set via the Filter method.
IndexString (inherited from SQLiteVirtualTableCursor) | String used to help identify the selected index. This value will be set via the Filter method.
IsOpen | Returns non-zero if the virtual table cursor is open.
NativeHandle (inherited from SQLiteVirtualTableCursor) | Returns the underlying SQLite native handle associated with this object instance.
Table (inherited from SQLiteVirtualTableCursor) | The SQLiteVirtualTable object instance associated with this object instance.
Values (inherited from SQLiteVirtualTableCursor) | The values used to filter the rows returned via this cursor object instance. This value will be set via the Filter method.

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


Current Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursorEnumerator.Current Property

Returns the value for the current row of the virtual table cursor using the Current property of the IEnumerator object instance.

public virtual object Current { public get; }

Implements

IEnumerator.Current

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


EndOfEnumerator Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursorEnumerator.EndOfEnumerator Property

Returns non-zero if the end of the virtual table cursor has been seen (i.e. no more rows are available, including the current one).

public virtual bool EndOfEnumerator { public get; }

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


IsOpen Property

SQLite ADO.NET Provider

SQLiteVirtualTableCursorEnumerator.IsOpen Property

Returns non-zero if the virtual table cursor is open.

public virtual bool IsOpen { public get; }

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator Methods

The methods of the SQLiteVirtualTableCursorEnumerator class are listed below. For a complete list of SQLiteVirtualTableCursorEnumerator class members, see the SQLiteVirtualTableCursorEnumerator Members topic.

Public Instance Methods

CheckClosed | Throws an InvalidOperationException if the virtual table cursor has been closed.
Close | Closes the virtual table cursor. This method must not throw any exceptions.
Dispose (inherited from SQLiteVirtualTableCursor) | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteVirtualTableCursor) | This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetRowIndex (inherited from SQLiteVirtualTableCursor) | Determines the integer row sequence number for the current row.
GetType (inherited from Object) | Gets the Type of the current instance.
MoveNext | Advances to the next row of the virtual table cursor using the MoveNext method of the IEnumerator object instance.
NextRowIndex (inherited from SQLiteVirtualTableCursor) | Adjusts the integer row sequence number so that it refers to the next row.
Reset | Resets the virtual table cursor position, also invalidating the current row, using the Reset method of the IEnumerator object instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteVirtualTableCursor) | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
TryPersistValues (inherited from SQLiteVirtualTableCursor) | Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator.CheckClosed Method

Throws an InvalidOperationException if the virtual table cursor has been closed.

public virtual void CheckClosed();

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator.Close Method

Closes the virtual table cursor. This method must not throw any exceptions.

public virtual void Close();

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteVirtualTableCursorEnumerator.Dispose Method

Disposes of this object instance.

Overload List

Inherited from SQLiteVirtualTableCursor.

public void Dispose()

Disposes of this object instance.

protected override void Dispose(bool)

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator.Dispose(Boolean) Method

Disposes of this object instance.

protected override void Dispose(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace | SQLiteVirtualTableCursorEnumerator.Dispose Overload List


SQLiteVirtualTableCursorEnumerator.MoveNext Method

Advances to the next row of the virtual table cursor using the MoveNext method of the IEnumerator object instance.

public virtual bool MoveNext();

Return Value

Non-zero if the current row is valid; zero otherwise. If zero is returned, no further rows are available.

Implements

IEnumerator.MoveNext

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SQLiteVirtualTableCursorEnumerator.Reset Method

Resets the virtual table cursor position, also invalidating the current row, using the Reset method of the IEnumerator object instance.

public virtual void Reset();

Implements

IEnumerator.Reset

See Also

SQLiteVirtualTableCursorEnumerator Class | System.Data.SQLite Namespace


SynchronizationModes Enumeration

The I/O file cache flushing behavior for the connection

public enum SynchronizationModes

Members

Member Name | Description
Normal | Normal file flushing at critical sections of the code
Full | Full file flushing after every write operation
Off | Use the default operating system's file flushing, SQLite does not explicitly flush the file buffers after writing

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


TraceEventArgs Class

Passed during an Trace callback, these event arguments contain the UTF-8 rendering of the SQL statement text

For a list of all members of this type, see TraceEventArgs Members .

System.Object
EventArgs
TraceEventArgs

public class TraceEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

TraceEventArgs Members | System.Data.SQLite Namespace


TraceEventArgs Members

TraceEventArgs overview

Public Instance Fields

DatabaseConnection | Database connection associated with this event.
Elapsed | Elapsed time in nanoseconds associated with the prepared statement.
Flags | The flags associated with this trace event.
PreparedStatement | Prepared statement associated with this event.
Statement | SQL statement text as the statement first begins executing

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TraceEventArgs Fields

The fields of the TraceEventArgs class are listed below. For a complete list of TraceEventArgs class members, see the TraceEventArgs Members topic.

Public Instance Fields

DatabaseConnection | Database connection associated with this event.
Elapsed | Elapsed time in nanoseconds associated with the prepared statement.
Flags | The flags associated with this trace event.
PreparedStatement | Prepared statement associated with this event.
Statement | SQL statement text as the statement first begins executing

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TraceEventArgs.DatabaseConnection Field

Database connection associated with this event.

public readonly IntPtr? DatabaseConnection;

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TraceEventArgs.Elapsed Field

Elapsed time in nanoseconds associated with the prepared statement.

public readonly long? Elapsed;

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TraceEventArgs.Flags Field

The flags associated with this trace event.

public readonly SQLiteTraceFlags? Flags;

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TraceEventArgs.PreparedStatement Field

Prepared statement associated with this event.

public readonly IntPtr? PreparedStatement;

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TraceEventArgs.Statement Field

SQL statement text as the statement first begins executing

public readonly string Statement;

See Also

TraceEventArgs Class | System.Data.SQLite Namespace


TypeAffinity Enumeration

SQLite has very limited types, and is inherently text-based. The first 5 types below represent the sum of all types SQLite understands. The DateTime extension to the spec is for internal use only.

public enum TypeAffinity

Members

Member Name | Description
Uninitialized | Not used
Int64 | All integers in SQLite default to Int64
Double | All floating point numbers in SQLite default to double
Text | The default data type of SQLite is text
Blob | Typically blob types are only seen when returned from a function
Null | Null types can be returned from functions
DateTime | Used internally by this provider
None | Used internally by this provider

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


UpdateEventArgs Class

Passed during an Update callback, these event arguments detail the type of update operation being performed on the given connection.

For a list of all members of this type, see UpdateEventArgs Members .

System.Object
EventArgs
UpdateEventArgs

public class UpdateEventArgs : EventArgs

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

UpdateEventArgs Members | System.Data.SQLite Namespace


UpdateEventArgs Members

UpdateEventArgs overview

Public Instance Fields

Database | The name of the database being updated (usually "main" but can be any attached or temporary database)
Event | The type of update being performed (insert/update/delete)
RowId | The RowId affected by this update.
Table | The name of the table being updated

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Finalize (inherited from Object) | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.

See Also

UpdateEventArgs Class | System.Data.SQLite Namespace


UpdateEventArgs Fields

The fields of the UpdateEventArgs class are listed below. For a complete list of UpdateEventArgs class members, see the UpdateEventArgs Members topic.

Public Instance Fields

Database | The name of the database being updated (usually "main" but can be any attached or temporary database)
Event | The type of update being performed (insert/update/delete)
RowId | The RowId affected by this update.
Table | The name of the table being updated

See Also

UpdateEventArgs Class | System.Data.SQLite Namespace


UpdateEventArgs.Database Field

The name of the database being updated (usually "main" but can be any attached or temporary database)

public readonly string Database;

See Also

UpdateEventArgs Class | System.Data.SQLite Namespace


UpdateEventArgs.Event Field

The type of update being performed (insert/update/delete)

public readonly UpdateEventType Event;

See Also

UpdateEventArgs Class | System.Data.SQLite Namespace


UpdateEventArgs.RowId Field

The RowId affected by this update.

public readonly long RowId;

See Also

UpdateEventArgs Class | System.Data.SQLite Namespace


UpdateEventArgs.Table Field

The name of the table being updated

public readonly string Table;

See Also

UpdateEventArgs Class | System.Data.SQLite Namespace


UpdateEventType Enumeration

Whenever an update event is triggered on a connection, this enum will indicate exactly what type of operation is being performed.

public enum UpdateEventType

Members

Member Name | Description
Delete | A row is being deleted from the given database and table
Insert | A row is being inserted into the table.
Update | A row is being updated in the table.

Requirements

Namespace: System.Data.SQLite

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

System.Data.SQLite Namespace


System.Data.SQLite.Generic

SQLite ADO.NET Provider

System.Data.SQLite.Generic Namespace

Namespace Hierarchy

Classes

Class | Description
SQLiteModuleEnumerable(T) | This class implements a virtual table module that exposes an IEnumerable`1 object instance as a read-only virtual table. It is not sealed and may be used as the base class for any user-defined virtual table class that wraps an IEnumerable`1 object instance.
SQLiteVirtualTableCursorEnumerator(T) | This class represents a virtual table cursor to be used with the SQLiteModuleEnumerable class. It is not sealed and may be used as the base class for any user-defined virtual table cursor class that wraps an IEnumerator`1 object instance.


SQLiteModuleEnumerable(T) Class

This class implements a virtual table module that exposes an IEnumerable`1 object instance as a read-only virtual table. It is not sealed and may be used as the base class for any user-defined virtual table class that wraps an IEnumerable`1 object instance.

For a list of all members of this type, see SQLiteModuleEnumerable(T) Members .

System.Object
SQLiteModule
SQLiteModuleNoop
SQLiteModuleCommon
SQLiteModuleEnumerable
SQLiteModuleEnumerable(T)

public class SQLiteModuleEnumerable<T> : SQLiteModuleEnumerable

Requirements

Namespace: System.Data.SQLite.Generic

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteModuleEnumerable(T) Members | System.Data.SQLite.Generic Namespace


SQLiteModuleEnumerable(T) Members

SQLiteModuleEnumerable(T) overview

Public Instance Constructors

SQLiteModuleEnumerable(T) Constructor Constructs an instance of this class.

Public Instance Properties

Declared (inherited from SQLiteModule) | Returns non-zero if the schema for the virtual table has been declared.
LogErrors (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptions (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, xDestroy method, and the Dispose method should be logged using the SQLiteLog class.
Name (inherited from SQLiteModule) | Returns the name of the module as it was registered with the SQLite core library.

Public Instance Methods

Begin (inherited from SQLiteModuleNoop) | See the Begin method.
BestIndex (inherited from SQLiteModuleEnumerable) | See the BestIndex method.
Close (inherited from SQLiteModuleEnumerable) | See the Close method.
Column | See the Column method.
Commit (inherited from SQLiteModuleNoop) | See the Commit method.
Connect (inherited from SQLiteModuleEnumerable) | See the Connect method.
Create (inherited from SQLiteModuleEnumerable) | See the Create method.
Destroy (inherited from SQLiteModuleEnumerable) | See the Destroy method.
Disconnect (inherited from SQLiteModuleEnumerable) | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof (inherited from SQLiteModuleEnumerable) | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteModuleEnumerable) | See the Filter method.
FindFunction (inherited from SQLiteModuleNoop) | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next (inherited from SQLiteModuleEnumerable) | See the Next method.
Open | See the Open method.
Release (inherited from SQLiteModuleNoop) | See the Release method.
Rename (inherited from SQLiteModuleEnumerable) | See the Rename method.
Rollback (inherited from SQLiteModuleNoop) | See the Rollback method.
RollbackTo (inherited from SQLiteModuleNoop) | See the RollbackTo method.
RowId (inherited from SQLiteModuleEnumerable) | See the RowId method.
Savepoint (inherited from SQLiteModuleNoop) | See the Savepoint method.
Sync (inherited from SQLiteModuleNoop) | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update (inherited from SQLiteModuleEnumerable) | See the Update method.

Protected Instance Properties

LogErrorsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether virtual table errors should be logged using the SQLiteLog class.
LogExceptionsNoThrow (inherited from SQLiteModule) | Returns or sets a boolean value indicating whether exceptions caught in the xDisconnect method, the xDestroy method, the SetTableError method, the SetTableError method, and the Dispose method should be logged using the SQLiteLog class.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorEndOfEnumeratorError (inherited from SQLiteModuleEnumerable) | Sets the table error message to one that indicates the virtual table cursor has no current row.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
CursorTypeMismatchError (inherited from SQLiteModuleCommon) | Sets the table error message to one that indicates the virtual table cursor is of the wrong type.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode (inherited from SQLiteModuleNoop) | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode (inherited from SQLiteModuleNoop) | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
GetRowIdFromObject (inherited from SQLiteModuleCommon) | Determines the unique row identifier for the current row.
GetSqlForDeclareTable (inherited from SQLiteModuleCommon) | Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.
GetStringFromObject (inherited from SQLiteModuleCommon) | Determines the string to return as the column value for the object instance value.
MakeRowId (inherited from SQLiteModuleCommon) | Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode (inherited from SQLiteModuleNoop) | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace


SQLiteModuleEnumerable(T) Constructor

Constructs an instance of this class.

SQLiteModuleEnumerable<T>(
string name,
IEnumerable<T> enumerable
);

Parameters

name
The name of the module. This parameter cannot be null.
enumerable
The IEnumerable`1 instance to expose as a virtual table. This parameter cannot be null.

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace


SQLiteModuleEnumerable(T) Methods

The methods of the SQLiteModuleEnumerable(T) class are listed below. For a complete list of SQLiteModuleEnumerable(T) class members, see the SQLiteModuleEnumerable(T) Members topic.

Public Instance Methods

Begin (inherited from SQLiteModuleNoop) | See the Begin method.
BestIndex (inherited from SQLiteModuleEnumerable) | See the BestIndex method.
Close (inherited from SQLiteModuleEnumerable) | See the Close method.
Column | See the Column method.
Commit (inherited from SQLiteModuleNoop) | See the Commit method.
Connect (inherited from SQLiteModuleEnumerable) | See the Connect method.
Create (inherited from SQLiteModuleEnumerable) | See the Create method.
Destroy (inherited from SQLiteModuleEnumerable) | See the Destroy method.
Disconnect (inherited from SQLiteModuleEnumerable) | See the Disconnect method.
Dispose (inherited from SQLiteModule) | Overloaded. Disposes of this object instance.
Eof (inherited from SQLiteModuleEnumerable) | See the Eof method.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteModuleEnumerable) | See the Filter method.
FindFunction (inherited from SQLiteModuleNoop) | See the FindFunction method.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
Next (inherited from SQLiteModuleEnumerable) | See the Next method.
Open | See the Open method.
Release (inherited from SQLiteModuleNoop) | See the Release method.
Rename (inherited from SQLiteModuleEnumerable) | See the Rename method.
Rollback (inherited from SQLiteModuleNoop) | See the Rollback method.
RollbackTo (inherited from SQLiteModuleNoop) | See the RollbackTo method.
RowId (inherited from SQLiteModuleEnumerable) | See the RowId method.
Savepoint (inherited from SQLiteModuleNoop) | See the Savepoint method.
Sync (inherited from SQLiteModuleNoop) | See the Sync method.
ToString (inherited from Object) | Returns a String that represents the current Object.
Update (inherited from SQLiteModuleEnumerable) | See the Update method.

Protected Instance Methods

AllocateCursor (inherited from SQLiteModule) | Allocates a native sqlite3_vtab_cursor derived structure and returns a native pointer to it.
AllocateTable (inherited from SQLiteModule) | Allocates a native sqlite3_vtab derived structure and returns a native pointer to it.
CreateNativeModuleImpl (inherited from SQLiteModule) | Creates and returns the ISQLiteNativeModule interface implementation corresponding to the current SQLiteModule object instance.
CursorEndOfEnumeratorError (inherited from SQLiteModuleEnumerable) | Sets the table error message to one that indicates the virtual table cursor has no current row.
CursorFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTableCursor object instance based on the native pointer to the sqlite3_vtab_cursor derived structure.
CursorToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab_cursor derived structure and creates an association between it and the specified SQLiteVirtualTableCursor object instance.
CursorTypeMismatchError (inherited from SQLiteModuleCommon) | Sets the table error message to one that indicates the virtual table cursor is of the wrong type.
DeclareFunction (inherited from SQLiteModule) | Calls the native SQLite core library in order to declare a virtual table function in response to a call into the xCreate or xConnect virtual table methods.
DeclareTable (inherited from SQLiteModule) | Attempts to declare the schema for the virtual table using the specified database connection.
Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteModule) | Finalizes this object instance.
FreeCursor (inherited from SQLiteModule) | Frees a native sqlite3_vtab_cursor structure using the provided native pointer to it.
FreeTable (inherited from SQLiteModule) | Frees a native sqlite3_vtab structure using the provided native pointer to it.
GetDefaultResultCode (inherited from SQLiteModuleNoop) | Determines the default SQLiteErrorCode value to be returned by methods of the ISQLiteManagedModule interface that lack an overridden implementation in all classes derived from the SQLiteModuleNoop class.
GetFunctionKey (inherited from SQLiteModule) | Deterimines the key that should be used to identify and store the SQLiteFunction object instance for the virtual table (i.e. to be returned via the xFindFunction method).
GetMethodResultCode (inherited from SQLiteModuleNoop) | Determines the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation. If no specific SQLiteErrorCode value is available (or set) for the specified method, the SQLiteErrorCode value returned by the GetDefaultResultCode method will be returned instead.
GetNativeModuleImpl (inherited from SQLiteModule) | Gets and returns the ISQLiteNativeModule interface implementation to be used when creating the native sqlite3_module structure. Derived classes may override this method to supply an alternate implementation for the ISQLiteNativeModule interface.
GetRowIdFromObject (inherited from SQLiteModuleCommon) | Determines the unique row identifier for the current row.
GetSqlForDeclareTable (inherited from SQLiteModuleCommon) | Determines the SQL statement used to declare the virtual table. This method should be overridden in derived classes if they require a custom virtual table schema.
GetStringFromObject (inherited from SQLiteModuleCommon) | Determines the string to return as the column value for the object instance value.
MakeRowId (inherited from SQLiteModuleCommon) | Constructs an Int64 unique row identifier from two Int32 values. The first Int32 value must contain the row sequence number for the current row and the second value must contain the hash code of the key column value for the current row.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
ResultCodeToEofResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the Eof method.
ResultCodeToFindFunctionResult (inherited from SQLiteModuleNoop) | Converts a SQLiteErrorCode value into a boolean return value for use with the FindFunction method.
SetCursorError (inherited from SQLiteModule) | Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
SetEstimatedCost (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated cost.
SetEstimatedRows (inherited from SQLiteModule) | Overloaded. Modifies the specified SQLiteIndex object instance to contain the specified estimated rows.
SetIndexFlags (inherited from SQLiteModule) | Overloaded.
SetMethodResultCode (inherited from SQLiteModuleNoop) | Sets the SQLiteErrorCode value that should be returned by the specified ISQLiteManagedModule interface method if it lack an overridden implementation.
SetTableError (inherited from SQLiteModule) | Overloaded. Arranges for the specified error message to be placed into the zErrMsg field of a sqlite3_vtab derived structure, freeing the existing error message, if any.
TableFromCursor (inherited from SQLiteModule) | Reads and returns the native pointer to the sqlite3_vtab derived structure based on the native pointer to the sqlite3_vtab_cursor derived structure.
TableFromIntPtr (inherited from SQLiteModule) | Looks up and returns the SQLiteVirtualTable object instance based on the native pointer to the sqlite3_vtab derived structure.
TableToIntPtr (inherited from SQLiteModule) | Allocates and returns a native pointer to a sqlite3_vtab derived structure and creates an association between it and the specified SQLiteVirtualTable object instance.
ZeroTable (inherited from SQLiteModule) | Zeros out the fields of a native sqlite3_vtab derived structure.

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace


SQLiteModuleEnumerable(T).Column Method

See the Column method.

public override SQLiteErrorCode SQLiteModuleEnumerable(
SQLiteVirtualTableCursor cursor,
SQLiteContext context,
int index
);

Parameters

cursor
See the Column method.
context
See the Column method.
index
See the Column method.

Return Value

See the Column method.

Implements

ISQLiteManagedModule.Column

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteModuleEnumerable`1.Dispose Method

Disposes of this object instance.

Overload List

Inherited from SQLiteModule.

public void Dispose()

Disposes of this object instance.

protected override void Dispose(bool)

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace


SQLiteModuleEnumerable(T).Dispose(Boolean) Method

Disposes of this object instance.

protected override void SQLiteModuleEnumerable(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace | SQLiteModuleEnumerable<T>.Dispose Overload List


SQLiteModuleEnumerable(T).Open Method

See the Open method.

public override SQLiteErrorCode SQLiteModuleEnumerable(
SQLiteVirtualTable table,
ref SQLiteVirtualTableCursor cursor
);

Parameters

table
See the Open method.
cursor
See the Open method.

Return Value

See the Open method.

Implements

ISQLiteManagedModule.Open

See Also

SQLiteModuleEnumerable<T> Class | System.Data.SQLite.Generic Namespace


SQLiteVirtualTableCursorEnumerator(T) Class

This class represents a virtual table cursor to be used with the SQLiteModuleEnumerable class. It is not sealed and may be used as the base class for any user-defined virtual table cursor class that wraps an IEnumerator`1 object instance.

For a list of all members of this type, see SQLiteVirtualTableCursorEnumerator(T) Members .

System.Object
SQLiteVirtualTableCursor
SQLiteVirtualTableCursorEnumerator
SQLiteVirtualTableCursorEnumerator(T)

public class SQLiteVirtualTableCursorEnumerator<T> : SQLiteVirtualTableCursorEnumerator, IEnumerator<T>

Requirements

Namespace: System.Data.SQLite.Generic

Assembly: System.Data.SQLite (in System.Data.SQLite.dll)

See Also

SQLiteVirtualTableCursorEnumerator(T) Members | System.Data.SQLite.Generic Namespace


SQLiteVirtualTableCursorEnumerator(T) Members

SQLiteVirtualTableCursorEnumerator(T) overview

Public Instance Constructors

SQLiteVirtualTableCursorEnumerator(T) Constructor Constructs an instance of this class.

Public Instance Properties

Current (inherited from SQLiteVirtualTableCursorEnumerator) | Returns the value for the current row of the virtual table cursor using the Current property of the IEnumerator object instance.
EndOfEnumerator (inherited from SQLiteVirtualTableCursorEnumerator) | Returns non-zero if the end of the virtual table cursor has been seen (i.e. no more rows are available, including the current one).
IndexNumber (inherited from SQLiteVirtualTableCursor) | Number used to help identify the selected index. This value will be set via the Filter method.
IndexString (inherited from SQLiteVirtualTableCursor) | String used to help identify the selected index. This value will be set via the Filter method.
IsOpen (inherited from SQLiteVirtualTableCursorEnumerator) | Returns non-zero if the virtual table cursor is open.
NativeHandle (inherited from SQLiteVirtualTableCursor) | Returns the underlying SQLite native handle associated with this object instance.
Table (inherited from SQLiteVirtualTableCursor) | The SQLiteVirtualTable object instance associated with this object instance.
Values (inherited from SQLiteVirtualTableCursor) | The values used to filter the rows returned via this cursor object instance. This value will be set via the Filter method.

Public Instance Methods

CheckClosed (inherited from SQLiteVirtualTableCursorEnumerator) | Throws an InvalidOperationException if the virtual table cursor has been closed.
Close | Closes the virtual table cursor. This method must not throw any exceptions.
Dispose (inherited from SQLiteVirtualTableCursor) | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteVirtualTableCursor) | This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetRowIndex (inherited from SQLiteVirtualTableCursor) | Determines the integer row sequence number for the current row.
GetType (inherited from Object) | Gets the Type of the current instance.
MoveNext (inherited from SQLiteVirtualTableCursorEnumerator) | Advances to the next row of the virtual table cursor using the MoveNext method of the IEnumerator object instance.
NextRowIndex (inherited from SQLiteVirtualTableCursor) | Adjusts the integer row sequence number so that it refers to the next row.
Reset (inherited from SQLiteVirtualTableCursorEnumerator) | Resets the virtual table cursor position, also invalidating the current row, using the Reset method of the IEnumerator object instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteVirtualTableCursor) | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
TryPersistValues (inherited from SQLiteVirtualTableCursor) | Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

See Also

SQLiteVirtualTableCursorEnumerator<T> Class | System.Data.SQLite.Generic Namespace


SQLiteVirtualTableCursorEnumerator(T) Constructor

Constructs an instance of this class.

SQLiteVirtualTableCursorEnumerator<T>(
SQLiteVirtualTable table,
IEnumerator<T> enumerator
);

Parameters

table
The SQLiteVirtualTable object instance associated with this object instance.
enumerator
The IEnumerator`1 instance to expose as a virtual table cursor.

See Also

SQLiteVirtualTableCursorEnumerator<T> Class | System.Data.SQLite.Generic Namespace


SQLiteVirtualTableCursorEnumerator(T) Methods

The methods of the SQLiteVirtualTableCursorEnumerator(T) class are listed below. For a complete list of SQLiteVirtualTableCursorEnumerator(T) class members, see the SQLiteVirtualTableCursorEnumerator(T) Members topic.

Public Instance Methods

CheckClosed (inherited from SQLiteVirtualTableCursorEnumerator) | Throws an InvalidOperationException if the virtual table cursor has been closed.
Close | Closes the virtual table cursor. This method must not throw any exceptions.
Dispose (inherited from SQLiteVirtualTableCursor) | Overloaded. Disposes of this object instance.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
Filter (inherited from SQLiteVirtualTableCursor) | This method should normally be used by the Filter method in order to perform filtering of the result rows and/or to record the filtering criteria provided by the SQLite core library.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetRowIndex (inherited from SQLiteVirtualTableCursor) | Determines the integer row sequence number for the current row.
GetType (inherited from Object) | Gets the Type of the current instance.
MoveNext (inherited from SQLiteVirtualTableCursorEnumerator) | Advances to the next row of the virtual table cursor using the MoveNext method of the IEnumerator object instance.
NextRowIndex (inherited from SQLiteVirtualTableCursor) | Adjusts the integer row sequence number so that it refers to the next row.
Reset (inherited from SQLiteVirtualTableCursorEnumerator) | Resets the virtual table cursor position, also invalidating the current row, using the Reset method of the IEnumerator object instance.
ToString (inherited from Object) | Returns a String that represents the current Object.

Protected Instance Methods

Dispose | Overloaded. Disposes of this object instance.
Finalize (inherited from SQLiteVirtualTableCursor) | Finalizes this object instance.
MemberwiseClone (inherited from Object) | Creates a shallow copy of the current Object.
TryPersistValues (inherited from SQLiteVirtualTableCursor) | Attempts to persist the specified SQLiteValue object instances in order to make them available after the Filter method returns.

See Also

SQLiteVirtualTableCursorEnumerator<T> Class | System.Data.SQLite.Generic Namespace


SQLiteVirtualTableCursorEnumerator(T).Close Method

Closes the virtual table cursor. This method must not throw any exceptions.

public override void SQLiteVirtualTableCursorEnumerator();

See Also

SQLiteVirtualTableCursorEnumerator<T> Class | System.Data.SQLite.Generic Namespace


Dispose Method

SQLite ADO.NET Provider

SQLiteVirtualTableCursorEnumerator`1.Dispose Method

Disposes of this object instance.

Overload List

Inherited from SQLiteVirtualTableCursor.

public void Dispose()

Disposes of this object instance.

protected override void Dispose(bool)

See Also

SQLiteVirtualTableCursorEnumerator<T> Class | System.Data.SQLite.Generic Namespace


SQLiteVirtualTableCursorEnumerator(T).Dispose(Boolean) Method

Disposes of this object instance.

protected override void SQLiteVirtualTableCursorEnumerator(
bool disposing
);

Parameters

disposing
Non-zero if this method is being called from the Dispose method. Zero if this method is being called from the finalizer.

See Also

SQLiteVirtualTableCursorEnumerator<T> Class | System.Data.SQLite.Generic Namespace | SQLiteVirtualTableCursorEnumerator<T>.Dispose Overload List


System.Data.SQLite.GenericHierarchy

SQLite ADO.NET Provider

System.Data.SQLite.Generic Hierarchy

Object
SQLiteModule ---- ISQLiteManagedModule, IDisposable
SQLiteModuleNoop
SQLiteModuleCommon
SQLiteModuleEnumerable
SQLiteModuleEnumerable(T)
SQLiteVirtualTableCursor ---- ISQLiteNativeHandle, IDisposable
SQLiteVirtualTableCursorEnumerator ---- IEnumerator
SQLiteVirtualTableCursorEnumerator(T) ---- IEnumerator(T)

See Also

System.Data.SQLite.Generic Namespace


System.Data.SQLiteHierarchy

SQLite ADO.NET Provider

System.Data.SQLite Hierarchy

Object
Attribute
AssemblySourceIdAttribute
AssemblySourceTimeStampAttribute
SQLiteFunctionAttribute
DbConnectionStringBuilder ---- ICollection, IDictionary, IEnumerable, ICustomTypeDescriptor
SQLiteConnectionStringBuilder
DbProviderFactory
SQLiteFactory ---- IDisposable, IServiceProvider
ISQLiteChangeGroup ---- IDisposable
ISQLiteChangeSet ---- IEnumerable(T), IEnumerable, IDisposable
ISQLiteChangeSetMetadataItem ---- IDisposable
ISQLiteConnectionPool
ISQLiteConnectionPool2 ---- ISQLiteConnectionPool
ISQLiteManagedModule
ISQLiteNativeHandle
ISQLiteNativeModule
ISQLiteSchemaExtensions
ISQLiteSession ---- IDisposable
SQLiteBlob ---- IDisposable
SQLiteContext ---- ISQLiteNativeHandle
SQLiteConvert
SQLiteDataReaderValue
SQLiteFunction ---- IDisposable
SQLiteDelegateFunction
SQLiteFunctionEx
SQLiteIndex
SQLiteIndexConstraint
SQLiteIndexConstraintUsage
SQLiteIndexInputs
SQLiteIndexOrderBy
SQLiteIndexOutputs
SQLiteLog
SQLiteMetaDataCollectionNames
SQLiteModule ---- ISQLiteManagedModule, IDisposable
SQLiteModuleNoop
SQLiteModuleCommon
SQLiteModuleEnumerable
SQLiteTypeCallbacks
SQLiteValue ---- ISQLiteNativeHandle
SQLiteVirtualTable ---- ISQLiteNativeHandle, IDisposable
SQLiteVirtualTableCursor ---- ISQLiteNativeHandle, IDisposable
SQLiteVirtualTableCursorEnumerator ---- IEnumerator
Delegate ---- ICloneable, ISerializable
MulticastDelegate
SessionConflictCallback
SessionTableFilterCallback
SQLiteAuthorizerEventHandler
SQLiteBackupCallback
SQLiteBindValueCallback
SQLiteBusyEventHandler
SQLiteCallback
SQLiteCommitHandler
SQLiteCompareDelegate
SQLiteConnectionEventHandler
SQLiteFinalDelegate
SQLiteInvokeDelegate
SQLiteLogEventHandler
SQLiteProgressEventHandler
SQLiteReadValueCallback
SQLiteStepDelegate
SQLiteTraceEventHandler
SQLiteUpdateEventHandler
EventArgs
AuthorizerEventArgs
BusyEventArgs
CommitEventArgs
ConnectionEventArgs
LogEventArgs
ProgressEventArgs
SQLiteReadEventArgs
SQLiteReadArrayEventArgs
SQLiteReadBlobEventArgs
SQLiteReadValueEventArgs
TraceEventArgs
UpdateEventArgs
Exception ---- ISerializable
SystemException
ExternalException
DbException
SQLiteException
MarshalByRefObject
Component ---- IComponent, IDisposable
DataAdapter ---- IDataAdapter
DbDataAdapter ---- IDbDataAdapter, ICloneable
SQLiteDataAdapter
DbCommand ---- IDbCommand
SQLiteCommand ---- ICloneable
DbCommandBuilder
SQLiteCommandBuilder
DbConnection ---- IDbConnection
SQLiteConnection ---- ICloneable
DbDataReader ---- IEnumerable, IDataReader, IDataRecord, IDisposable
SQLiteDataReader
DbParameter ---- IDataParameter, IDbDataParameter
SQLiteParameter ---- ICloneable
DbParameterCollection ---- ICollection, IEnumerable, IList, IDataParameterCollection
SQLiteParameterCollection
DbTransaction ---- IDbTransaction, IDisposable
SQLiteTransactionBase
SQLiteTransaction
SQLiteTransaction2
ValueType
CollationSequence
Enum ---- IComparable, IConvertible, IFormattable
CollationEncodingEnum
CollationTypeEnum
FunctionType
SQLiteAuthorizerActionCode
SQLiteAuthorizerReturnCode
SQLiteBusyReturnCode
SQLiteChangeSetConflictResult
SQLiteChangeSetConflictType
SQLiteChangeSetStartFlags
SQLiteConfigDbOpsEnum
SQLiteConnectionEventType
SQLiteConnectionFlags
SQLiteDateFormats
SQLiteErrorCode
SQLiteExecuteType
SQLiteFunctionFlags
SQLiteIndexConstraintOp
SQLiteIndexFlags
SQLiteJournalModeEnum
SQLiteLimitOpsEnum
SQLiteProgressReturnCode
SQLiteTraceFlags
SynchronizationModes
TypeAffinity
UpdateEventType

See Also

System.Data.SQLite Namespace


SQLite Syntax: aggregate-function-invocation

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

aggregate-function-invocation

aggregate-func ( DISTINCT expr ) filter-clause , *

References: expr filter-clause

See also: lang_aggfunc.html lang_expr.html


SQLite Syntax: alter-table-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

alter-table-stmt

ALTER TABLE schema-name . table-name RENAME TO new-table-name RENAME COLUMN column-name TO new-column-name ADD COLUMN column-def DROP COLUMN column-name

Used by: sql-stmt

References: column-def

See also: lang_altertable.html


SQLite Syntax: analyze-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

analyze-stmt

ANALYZE schema-name . table-or-index-name schema-name index-or-table-name

Used by: sql-stmt

See also: lang_analyze.html


SQLite Syntax: attach-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

attach-stmt

ATTACH DATABASE expr AS schema-name

Used by: sql-stmt

References: expr

See also: lang_attach.html


SQLite Syntax: begin-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

begin-stmt

BEGIN EXCLUSIVE TRANSACTION DEFERRED IMMEDIATE

Used by: sql-stmt

See also: lang_transaction.html


SQLite Syntax: column-constraint

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

column-constraint

CONSTRAINT name PRIMARY KEY DESC conflict-clause AUTOINCREMENT ASC NOT NULL conflict-clause UNIQUE conflict-clause CHECK ( expr ) DEFAULT ( expr ) literal-value signed-number COLLATE collation-name foreign-key-clause GENERATED ALWAYS AS ( expr ) VIRTUAL STORED

Used by: column-def

References: conflict-clause expr foreign-key-clause literal-value signed-number

See also: gencol.html lang_altertable.html lang_createtable.html


SQLite Syntax: column-def

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

column-def

column-name type-name column-constraint

Used by: alter-table-stmt create-table-stmt

References: column-constraint type-name

See also: lang_altertable.html lang_createtable.html


SQLite Syntax: column-name-list

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

column-name-list

( column-name ) ,

Used by: update-stmt update-stmt-limited upsert-clause

See also: lang_createtrigger.html lang_insert.html lang_update.html lang_upsert.html


SQLite Syntax: comment-syntax

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

comment-syntax

-- anything-except-newline newline end-of-input /* anything-except-*/ */

See also: lang_comment.html


SQLite Syntax: commit-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

commit-stmt

COMMIT TRANSACTION END

Used by: sql-stmt

See also: lang_transaction.html


SQLite Syntax: common-table-expression

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

common-table-expression

table-name ( column-name ) AS NOT MATERIALIZED ( select-stmt ) ,

Used by: compound-select-stmt delete-stmt delete-stmt-limited factored-select-stmt insert-stmt select-stmt simple-select-stmt update-stmt update-stmt-limited

References: select-stmt

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: compound-operator

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

compound-operator

UNION UNION INTERSECT EXCEPT ALL

Used by: factored-select-stmt select-stmt

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: compound-select-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

compound-select-stmt

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr UNION UNION ALL select-core INTERSECT EXCEPT ordering-term , OFFSET expr , expr

References: common-table-expression expr ordering-term select-core

See also: lang_select.html


SQLite Syntax: conflict-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

conflict-clause

ON CONFLICT ROLLBACK ABORT FAIL IGNORE REPLACE

Used by: column-constraint table-constraint

See also: lang_altertable.html lang_conflict.html lang_createtable.html


SQLite Syntax: create-index-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

create-index-stmt

CREATE UNIQUE INDEX IF NOT EXISTS schema-name . index-name ON table-name ( indexed-column ) , WHERE expr

Used by: sql-stmt

References: expr indexed-column

See also: lang_createindex.html partialindex.html


SQLite Syntax: create-table-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

create-table-stmt

CREATE TEMP TEMPORARY TABLE IF NOT EXISTS schema-name . table-name ( column-def table-constraint , ) table-options , AS select-stmt

Used by: sql-stmt

References: column-def select-stmt table-constraint table-options

See also: lang_createtable.html


SQLite Syntax: create-trigger-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

create-trigger-stmt

CREATE TEMP TEMPORARY TRIGGER IF NOT EXISTS schema-name . trigger-name BEFORE AFTER INSTEAD OF DELETE INSERT UPDATE OF column-name , ON table-name FOR EACH ROW WHEN expr BEGIN update-stmt ; END insert-stmt delete-stmt select-stmt

Used by: sql-stmt

References: delete-stmt expr insert-stmt select-stmt update-stmt

See also: lang_createtrigger.html


SQLite Syntax: create-view-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

create-view-stmt

CREATE TEMP TEMPORARY VIEW IF NOT EXISTS schema-name . view-name ( column-name ) AS select-stmt ,

Used by: sql-stmt

References: select-stmt

See also: lang_createview.html


SQLite Syntax: create-virtual-table-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

create-virtual-table-stmt

CREATE VIRTUAL TABLE IF NOT EXISTS schema-name . table-name USING module-name ( module-argument ) ,

Used by: sql-stmt

See also: lang_createvtab.html


SQLite Syntax: cte-table-name

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

cte-table-name

table-name ( column-name ) ,

Used by: recursive-cte with-clause

See also: lang_with.html


SQLite Syntax: delete-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

delete-stmt

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name returning-clause expr WHERE

Used by: create-trigger-stmt sql-stmt

References: common-table-expression expr qualified-table-name returning-clause

See also: lang_createtrigger.html lang_delete.html


SQLite Syntax: delete-stmt-limited

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

delete-stmt-limited

WITH RECURSIVE common-table-expression , DELETE FROM qualified-table-name WHERE expr returning-clause ORDER BY ordering-term , LIMIT expr OFFSET expr , expr

Used by: sql-stmt

References: common-table-expression expr ordering-term qualified-table-name returning-clause

See also: lang_delete.html


SQLite Syntax: detach-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

detach-stmt

DETACH DATABASE schema-name

Used by: sql-stmt

See also: lang_detach.html


SQLite Syntax: drop-index-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

drop-index-stmt

DROP INDEX IF EXISTS schema-name . index-name

Used by: sql-stmt

See also: lang_dropindex.html


SQLite Syntax: drop-table-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

drop-table-stmt

DROP TABLE IF EXISTS schema-name . table-name

Used by: sql-stmt

See also: lang_droptable.html


SQLite Syntax: drop-trigger-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

drop-trigger-stmt

DROP TRIGGER IF EXISTS schema-name . trigger-name

Used by: sql-stmt

See also: lang_droptrigger.html


SQLite Syntax: drop-view-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

drop-view-stmt

DROP VIEW IF EXISTS schema-name . view-name

Used by: sql-stmt

See also: lang_dropview.html


SQLite Syntax: expr

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

expr

literal-value bind-parameter schema-name . table-name . column-name unary-operator expr expr binary-operator expr function-name ( DISTINCT expr ) filter-clause over-clause , * ( expr ) , CAST ( expr AS type-name ) expr COLLATE collation-name expr NOT LIKE GLOB REGEXP MATCH expr expr ESCAPE expr expr ISNULL NOTNULL NOT NULL expr IS NOT DISTINCT FROM expr expr NOT BETWEEN expr AND expr expr NOT IN ( select-stmt ) expr , schema-name . table-function ( expr ) table-name , NOT EXISTS ( select-stmt ) CASE expr WHEN expr THEN expr ELSE expr END raise-function

Used by: aggregate-function-invocation attach-stmt column-constraint compound-select-stmt create-index-stmt create-trigger-stmt delete-stmt delete-stmt-limited factored-select-stmt filter-clause frame-spec indexed-column insert-stmt join-constraint ordering-term over-clause result-column returning-clause select-core select-stmt simple-function-invocation simple-select-stmt table-constraint table-or-subquery update-stmt update-stmt-limited upsert-clause window-defn window-function-invocation

References: filter-clause literal-value over-clause raise-function select-stmt type-name

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: factored-select-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

factored-select-stmt

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr compound-operator ordering-term , OFFSET expr , expr

References: common-table-expression compound-operator expr ordering-term select-core

See also: lang_select.html


SQLite Syntax: filter-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

filter-clause

FILTER ( WHERE expr )

Used by: aggregate-function-invocation expr window-function-invocation

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: foreign-key-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

foreign-key-clause

REFERENCES foreign-table ( column-name ) , ON DELETE SET NULL UPDATE SET DEFAULT CASCADE RESTRICT NO ACTION MATCH name NOT DEFERRABLE INITIALLY DEFERRED INITIALLY IMMEDIATE

Used by: column-constraint table-constraint

See also: lang_altertable.html lang_createtable.html


SQLite Syntax: frame-spec

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

frame-spec

GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING RANGE ROWS UNBOUNDED PRECEDING expr PRECEDING CURRENT ROW expr PRECEDING CURRENT ROW expr FOLLOWING expr PRECEDING CURRENT ROW expr FOLLOWING EXCLUDE CURRENT ROW EXCLUDE GROUP EXCLUDE TIES EXCLUDE NO OTHERS

Used by: over-clause window-defn

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: indexed-column

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

indexed-column

column-name COLLATE collation-name DESC expr ASC

Used by: create-index-stmt table-constraint upsert-clause

References: expr

See also: lang_createindex.html lang_createtable.html lang_createtrigger.html lang_insert.html lang_upsert.html partialindex.html


SQLite Syntax: insert-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

insert-stmt

WITH RECURSIVE common-table-expression , REPLACE INSERT OR ROLLBACK INTO ABORT FAIL IGNORE REPLACE schema-name . table-name AS alias ( column-name ) , VALUES ( expr ) , , upsert-clause select-stmt upsert-clause DEFAULT VALUES returning-clause

Used by: create-trigger-stmt sql-stmt

References: common-table-expression expr returning-clause select-stmt upsert-clause

See also: lang_createtrigger.html lang_insert.html


SQLite Syntax: join-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

join-clause

table-or-subquery join-operator table-or-subquery join-constraint

Used by: select-core select-stmt table-or-subquery update-stmt update-stmt-limited

References: join-constraint join-operator table-or-subquery

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: join-constraint

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

join-constraint

USING ( column-name ) , ON expr

Used by: join-clause

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: join-operator

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

join-operator

NATURAL LEFT OUTER JOIN , RIGHT FULL INNER CROSS

Used by: join-clause

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: literal-value

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

literal-value

CURRENT_TIMESTAMP numeric-literal string-literal blob-literal NULL TRUE FALSE CURRENT_TIME CURRENT_DATE

Used by: column-constraint expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: numeric-literal

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

numeric-literal

digit . E e digit . digit - digit + 0x hexdigit

See also: lang_expr.html


SQLite Syntax: ordering-term

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

ordering-term

expr COLLATE collation-name DESC ASC NULLS FIRST NULLS LAST

Used by: compound-select-stmt delete-stmt-limited factored-select-stmt over-clause select-stmt simple-select-stmt update-stmt-limited window-defn

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: over-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

over-clause

OVER window-name ( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

Used by: expr

References: expr frame-spec ordering-term

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: pragma-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

pragma-stmt

PRAGMA schema-name . pragma-name ( pragma-value ) = pragma-value

Used by: sql-stmt

References: pragma-value

See also: pragma.html


SQLite Syntax: pragma-value

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

pragma-value

signed-number name signed-literal

Used by: pragma-stmt

References: signed-number

See also: pragma.html


SQLite Syntax: qualified-table-name

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

qualified-table-name

schema-name . table-name AS alias INDEXED BY index-name NOT INDEXED

Used by: delete-stmt delete-stmt-limited update-stmt update-stmt-limited

See also: lang_createtrigger.html lang_delete.html lang_indexedby.html lang_update.html


SQLite Syntax: raise-function

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

raise-function

RAISE ( ROLLBACK , error-message ) IGNORE ABORT FAIL

Used by: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: recursive-cte

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

recursive-cte

cte-table-name AS ( initial-select UNION ALL recursive-select ) UNION

References: cte-table-name

See also: lang_with.html


SQLite Syntax: reindex-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

reindex-stmt

REINDEX schema-name . index-name table-name collation-name

Used by: sql-stmt

See also: lang_reindex.html


SQLite Syntax: release-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

release-stmt

RELEASE SAVEPOINT savepoint-name

Used by: sql-stmt

See also: lang_savepoint.html


SQLite Syntax: result-column

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

result-column

expr AS column-alias * table-name . *

Used by: select-core select-stmt

References: expr

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: returning-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

returning-clause

RETURNING expr AS column-alias * ,

Used by: delete-stmt delete-stmt-limited insert-stmt update-stmt update-stmt-limited

References: expr

See also: lang_createtrigger.html lang_delete.html lang_insert.html lang_returning.html lang_update.html


SQLite Syntax: rollback-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

rollback-stmt

ROLLBACK TRANSACTION TO SAVEPOINT savepoint-name

Used by: sql-stmt

See also: lang_savepoint.html lang_transaction.html


SQLite Syntax: savepoint-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

savepoint-stmt

SAVEPOINT savepoint-name

Used by: sql-stmt

See also: lang_savepoint.html


SQLite Syntax: select-core

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

select-core

SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , ,

Used by: compound-select-stmt factored-select-stmt simple-select-stmt

References: expr join-clause result-column table-or-subquery window-defn

See also: lang_select.html


SQLite Syntax: select-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

select-stmt

WITH RECURSIVE common-table-expression , SELECT DISTINCT result-column , ALL FROM table-or-subquery join-clause , WHERE expr GROUP BY expr HAVING expr , WINDOW window-name AS window-defn , VALUES ( expr ) , , compound-operator select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

Used by: common-table-expression create-table-stmt create-trigger-stmt create-view-stmt expr insert-stmt sql-stmt table-or-subquery with-clause

References: common-table-expression compound-operator expr join-clause ordering-term result-column table-or-subquery window-defn

See also: changes.html lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html releaselog/3_35_3.html releaselog/3_35_4.html releaselog/3_35_5.html


SQLite Syntax: signed-number

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

signed-number

+ numeric-literal -

Used by: column-constraint pragma-value type-name

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html pragma.html


SQLite Syntax: simple-function-invocation

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

simple-function-invocation

simple-func ( expr ) , *

References: expr

See also: lang_expr.html


SQLite Syntax: simple-select-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

simple-select-stmt

WITH RECURSIVE common-table-expression , select-core ORDER BY LIMIT expr ordering-term , OFFSET expr , expr

References: common-table-expression expr ordering-term select-core

See also: lang_select.html


SQLite Syntax: sql-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

sql-stmt

EXPLAIN QUERY PLAN alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt

Used by: sql-stmt-list

References: alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt

See also: lang.html lang_explain.html


SQLite Syntax: sql-stmt-list

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

sql-stmt-list

sql-stmt ;

References: sql-stmt

See also: lang.html


SQLite Syntax: table-constraint

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

table-constraint

CONSTRAINT name PRIMARY KEY ( indexed-column ) conflict-clause , UNIQUE CHECK ( expr ) FOREIGN KEY ( column-name ) foreign-key-clause ,

Used by: create-table-stmt

References: conflict-clause expr foreign-key-clause indexed-column

See also: lang_createtable.html


SQLite Syntax: table-options

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

table-options

WITHOUT ROWID STRICT ,

Used by: create-table-stmt

See also: lang_createtable.html


SQLite Syntax: table-or-subquery

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

table-or-subquery

schema-name . table-name AS table-alias INDEXED BY index-name NOT INDEXED table-function-name ( expr ) , AS table-alias ( select-stmt ) ( table-or-subquery ) , join-clause

Used by: join-clause select-core select-stmt update-stmt update-stmt-limited

References: expr join-clause select-stmt

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: type-name

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

type-name

name ( signed-number , signed-number ) ( signed-number )

Used by: column-def expr

References: signed-number

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: update-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

update-stmt

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause

Used by: create-trigger-stmt sql-stmt

References: column-name-list common-table-expression expr join-clause qualified-table-name returning-clause table-or-subquery

See also: lang_createtrigger.html lang_update.html


SQLite Syntax: update-stmt-limited

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

update-stmt-limited

WITH RECURSIVE common-table-expression , UPDATE OR ROLLBACK qualified-table-name OR REPLACE OR IGNORE OR FAIL OR ABORT SET column-name-list = expr column-name , FROM table-or-subquery , join-clause WHERE expr returning-clause ORDER BY ordering-term , LIMIT expr OFFSET expr , expr

Used by: sql-stmt

References: column-name-list common-table-expression expr join-clause ordering-term qualified-table-name returning-clause table-or-subquery

See also: lang_update.html


SQLite Syntax: upsert-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

upsert-clause

ON CONFLICT ( indexed-column ) WHERE expr DO , conflict target UPDATE SET column-name-list = expr WHERE expr NOTHING , column-name

Used by: insert-stmt

References: column-name-list expr indexed-column

See also: lang_createtrigger.html lang_insert.html lang_upsert.html


SQLite Syntax: vacuum-stmt

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

vacuum-stmt

VACUUM schema-name INTO filename

Used by: sql-stmt

See also: lang_vacuum.html


SQLite Syntax: window-defn

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

window-defn

( base-window-name PARTITION BY expr , ORDER BY ordering-term , frame-spec )

Used by: select-core select-stmt window-function-invocation

References: expr frame-spec ordering-term

See also: lang_aggfunc.html lang_altertable.html lang_attach.html lang_createindex.html lang_createtable.html lang_createtrigger.html lang_createview.html lang_delete.html lang_expr.html lang_insert.html lang_returning.html lang_select.html lang_update.html lang_upsert.html lang_with.html partialindex.html


SQLite Syntax: window-function-invocation

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

window-function-invocation

window-func ( expr ) filter-clause OVER window-name window-defn , *

References: expr filter-clause window-defn

See also: lang_expr.html


SQLite Syntax: with-clause

Small. Fast. Reliable.
Choose any three.
  • Home
  • Menu
  • About
  • Documentation
  • Download
  • License
  • Support
  • Purchase
  • Search
  • About
  • Documentation
  • Download
  • Support
  • Purchase

with-clause

WITH RECURSIVE cte-table-name AS NOT MATERIALIZED ( select-stmt ) MATERIALIZED ,

References: cte-table-name select-stmt

See also: lang_with.html