pub enum Pragma {
Show 74 variants
ApplicationId(i32),
AutoVacuum(AutoVacuum),
CacheSize(i32),
ForeignKeys(bool),
JournalMode(JournalMode),
WalAutocheckpoint(i32),
Synchronous(Synchronous),
TempStore(TempStore),
LockingMode(LockingMode),
SecureDelete(SecureDelete),
UserVersion(i32),
Encoding(Encoding),
PageSize(i32),
MmapSize(i64),
RecursiveTriggers(bool),
AnalysisLimit(i32),
AutomaticIndex(bool),
BusyTimeout(i32),
CacheSpill(CacheSpill),
CaseSensitiveLike(bool),
CellSizeCheck(bool),
CheckpointFullFsync(bool),
CountChanges(bool),
DataStoreDirectory(&'static str),
DefaultCacheSize(i32),
DeferForeignKeys(bool),
EmptyResultCallbacks(bool),
FullColumnNames(bool),
FullFsync(bool),
HardHeapLimit(i64),
IgnoreCheckConstraints(bool),
JournalSizeLimit(i64),
LegacyAlterTable(bool),
LegacyFileFormat,
MaxPageCount(i32),
QueryOnly(bool),
ReadUncommitted(bool),
ReverseUnorderedSelects(bool),
SchemaVersion(i32),
ShortColumnNames(bool),
SoftHeapLimit(i64),
TempStoreDirectory(&'static str),
Threads(i32),
TrustedSchema(bool),
WritableSchema(WritableSchema),
ParserTrace(bool),
VdbeAddoptrace(bool),
VdbeDebug(bool),
VdbeListing(bool),
VdbeTrace(bool),
CollationList,
CompileOptions,
DatabaseList,
FunctionList,
TableList,
TableXInfo(&'static str),
ModuleList,
DataVersion,
FreelistCount,
PageCount,
PragmaList,
Stats,
IncrementalVacuum(Option<i32>),
ShrinkMemory,
WalCheckpoint(Option<WalCheckpointMode>),
IntegrityCheck(Option<&'static str>),
QuickCheck(Option<&'static str>),
Optimize(Option<u32>),
ForeignKeyCheck(Option<&'static str>),
TableInfo(&'static str),
IndexList(&'static str),
IndexInfo(&'static str),
IndexXInfo(&'static str),
ForeignKeyList(&'static str),
}Expand description
A SQLite PRAGMA statement.
Variants are grouped as settings, read-only queries, maintenance
commands, and per-table queries. A setting variant renders an assignment
(PRAGMA cache_size = -2000); to read a setting’s current value, use
Pragma::query. Names passed to variants (tables, indexes,
directories) are not quoted or escaped.
Variants§
ApplicationId(i32)
Sets the 32-bit signed big-endian application ID
§Examples
let pragma = Pragma::ApplicationId(12345);
assert_eq!(pragma.to_sql().sql(), "PRAGMA application_id = 12345");AutoVacuum(AutoVacuum)
Sets the auto-vacuum mode
§Examples
let pragma = Pragma::AutoVacuum(AutoVacuum::Full);
assert_eq!(pragma.to_sql().sql(), "PRAGMA auto_vacuum = FULL");CacheSize(i32)
Sets the suggested page cache size: pages if positive, KiB if negative
§Examples
let pragma = Pragma::CacheSize(-2000);
assert_eq!(pragma.to_sql().sql(), "PRAGMA cache_size = -2000");ForeignKeys(bool)
Turns foreign key enforcement on or off
§Examples
let pragma = Pragma::ForeignKeys(true);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_keys = ON");
let pragma = Pragma::ForeignKeys(false);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_keys = OFF");JournalMode(JournalMode)
Sets the journal mode for databases
§Examples
let pragma = Pragma::JournalMode(JournalMode::Wal);
assert_eq!(pragma.to_sql().sql(), "PRAGMA journal_mode = WAL");WalAutocheckpoint(i32)
Sets the WAL auto-checkpoint threshold (pages)
§Examples
let pragma = Pragma::WalAutocheckpoint(1000);
assert_eq!(pragma.to_sql().sql(), "PRAGMA wal_autocheckpoint = 1000");Synchronous(Synchronous)
Sets how often SQLite syncs writes to disk
§Examples
let pragma = Pragma::Synchronous(Synchronous::Normal);
assert_eq!(pragma.to_sql().sql(), "PRAGMA synchronous = NORMAL");TempStore(TempStore)
Sets the storage mode used by temporary tables and indices
§Examples
let pragma = Pragma::TempStore(TempStore::Memory);
assert_eq!(pragma.to_sql().sql(), "PRAGMA temp_store = MEMORY");LockingMode(LockingMode)
Sets the connection’s locking mode
§Examples
let pragma = Pragma::LockingMode(LockingMode::Exclusive);
assert_eq!(pragma.to_sql().sql(), "PRAGMA locking_mode = EXCLUSIVE");SecureDelete(SecureDelete)
Sets the secure-delete setting
§Examples
let pragma = Pragma::SecureDelete(SecureDelete::Fast);
assert_eq!(pragma.to_sql().sql(), "PRAGMA secure_delete = FAST");UserVersion(i32)
Sets the user-version integer
§Examples
let pragma = Pragma::UserVersion(42);
assert_eq!(pragma.to_sql().sql(), "PRAGMA user_version = 42");Encoding(Encoding)
Sets the text encoding used by the database
§Examples
let pragma = Pragma::Encoding(Encoding::Utf8);
assert_eq!(pragma.to_sql().sql(), "PRAGMA encoding = UTF-8");PageSize(i32)
Sets the database page size in bytes
§Examples
let pragma = Pragma::PageSize(4096);
assert_eq!(pragma.to_sql().sql(), "PRAGMA page_size = 4096");MmapSize(i64)
Sets the maximum memory map size
§Examples
let pragma = Pragma::MmapSize(268435456);
assert_eq!(pragma.to_sql().sql(), "PRAGMA mmap_size = 268435456");RecursiveTriggers(bool)
Enable or disable recursive trigger firing
§Examples
let pragma = Pragma::RecursiveTriggers(true);
assert_eq!(pragma.to_sql().sql(), "PRAGMA recursive_triggers = ON");AnalysisLimit(i32)
Sets the ANALYZE limit
AutomaticIndex(bool)
Sets automatic indexing
BusyTimeout(i32)
Sets the busy timeout (milliseconds)
CacheSpill(CacheSpill)
Sets cache spill settings
CaseSensitiveLike(bool)
Sets case_sensitive_like (deprecated)
CellSizeCheck(bool)
Enable or disable cell size checking
CheckpointFullFsync(bool)
Enable or disable checkpoint fullfsync
CountChanges(bool)
Sets count_changes (deprecated)
DataStoreDirectory(&'static str)
Sets data_store_directory (deprecated)
DefaultCacheSize(i32)
Sets default_cache_size (deprecated)
DeferForeignKeys(bool)
Sets defer_foreign_keys
EmptyResultCallbacks(bool)
Sets empty_result_callbacks (deprecated)
FullColumnNames(bool)
Sets full_column_names (deprecated)
FullFsync(bool)
Sets fullfsync
HardHeapLimit(i64)
Sets hard_heap_limit
IgnoreCheckConstraints(bool)
Sets ignore_check_constraints
JournalSizeLimit(i64)
Sets journal_size_limit
LegacyAlterTable(bool)
Sets legacy_alter_table
LegacyFileFormat
Query legacy_file_format (deprecated)
MaxPageCount(i32)
Sets max_page_count
QueryOnly(bool)
Sets query_only
ReadUncommitted(bool)
Sets read_uncommitted
ReverseUnorderedSelects(bool)
Sets reverse_unordered_selects
SchemaVersion(i32)
Sets schema_version. Misuse can corrupt the database
ShortColumnNames(bool)
Sets short_column_names (deprecated)
SoftHeapLimit(i64)
Sets soft_heap_limit
TempStoreDirectory(&'static str)
Sets temp_store_directory (deprecated)
Threads(i32)
Sets threads
TrustedSchema(bool)
Sets trusted_schema
WritableSchema(WritableSchema)
Sets writable_schema. Misuse can corrupt the database
ParserTrace(bool)
Sets parser_trace (requires SQLITE_DEBUG)
VdbeAddoptrace(bool)
Sets vdbe_addoptrace (requires SQLITE_DEBUG)
VdbeDebug(bool)
Sets vdbe_debug (requires SQLITE_DEBUG)
VdbeListing(bool)
Sets vdbe_listing (requires SQLITE_DEBUG)
VdbeTrace(bool)
Sets vdbe_trace (requires SQLITE_DEBUG)
CollationList
Return a list of collating sequences
§Examples
let pragma = Pragma::CollationList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA collation_list");CompileOptions
Return compile-time options used when building SQLite
§Examples
let pragma = Pragma::CompileOptions;
assert_eq!(pragma.to_sql().sql(), "PRAGMA compile_options");DatabaseList
Return information about attached databases
§Examples
let pragma = Pragma::DatabaseList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA database_list");FunctionList
Return a list of SQL functions
§Examples
let pragma = Pragma::FunctionList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA function_list");TableList
Return information about tables and views in the schema
§Examples
let pragma = Pragma::TableList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_list");TableXInfo(&'static str)
Return extended table information including hidden columns
§Examples
let pragma = Pragma::TableXInfo("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_xinfo(users)");ModuleList
Return a list of available virtual table modules
§Examples
let pragma = Pragma::ModuleList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA module_list");DataVersion
Return the data_version counter
FreelistCount
Return the number of free pages in the database file
PageCount
Return the page count for the database
PragmaList
Return a list of available pragmas
Stats
Return statistics (test-only)
IncrementalVacuum(Option<i32>)
Perform incremental vacuuming
ShrinkMemory
Release as much memory as possible
WalCheckpoint(Option<WalCheckpointMode>)
Run a WAL checkpoint
IntegrityCheck(Option<&'static str>)
Perform database integrity check
§Examples
// Check entire database
let pragma = Pragma::IntegrityCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA integrity_check");
// Check specific table
let pragma = Pragma::IntegrityCheck(Some("users"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA integrity_check(users)");QuickCheck(Option<&'static str>)
Perform faster database integrity check
§Examples
let pragma = Pragma::QuickCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA quick_check");
let pragma = Pragma::QuickCheck(Some("users"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA quick_check(users)");Optimize(Option<u32>)
Attempt to optimize the database
§Examples
let pragma = Pragma::Optimize(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA optimize");
let pragma = Pragma::Optimize(Some(0x10002));
assert_eq!(pragma.to_sql().sql(), "PRAGMA optimize(65538)");ForeignKeyCheck(Option<&'static str>)
Check foreign key constraints for a table
§Examples
let pragma = Pragma::ForeignKeyCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_check");
let pragma = Pragma::ForeignKeyCheck(Some("orders"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_check(orders)");TableInfo(&'static str)
Return information about table columns
§Examples
let pragma = Pragma::TableInfo("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_info(users)");IndexList(&'static str)
Return information about table indexes
§Examples
let pragma = Pragma::IndexList("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA index_list(users)");IndexInfo(&'static str)
Return information about index columns
§Examples
let pragma = Pragma::IndexInfo("idx_users_email");
assert_eq!(pragma.to_sql().sql(), "PRAGMA index_info(idx_users_email)");IndexXInfo(&'static str)
Return extended information about index columns
ForeignKeyList(&'static str)
Return foreign key information for a table
§Examples
let pragma = Pragma::ForeignKeyList("orders");
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_list(orders)");Implementations§
Source§impl Pragma
impl Pragma
Sourcepub fn query(pragma_name: &str) -> SQL<'static, SQLiteValue<'static>>
pub fn query(pragma_name: &str) -> SQL<'static, SQLiteValue<'static>>
Builds PRAGMA name, which reads the pragma’s current value.
pragma_name is written into the SQL as given; only pass trusted
names.
§Examples
assert_eq!(Pragma::query("journal_mode").sql(), "PRAGMA journal_mode");Sourcepub const fn foreign_keys(enabled: bool) -> Self
pub const fn foreign_keys(enabled: bool) -> Self
Same as Pragma::ForeignKeys.
Sourcepub const fn journal_mode(mode: JournalMode) -> Self
pub const fn journal_mode(mode: JournalMode) -> Self
Same as Pragma::JournalMode.
Sourcepub const fn wal_autocheckpoint(pages: i32) -> Self
pub const fn wal_autocheckpoint(pages: i32) -> Self
Same as Pragma::WalAutocheckpoint.
Sourcepub const fn table_info(table: &'static str) -> Self
pub const fn table_info(table: &'static str) -> Self
Same as Pragma::TableInfo.
Sourcepub const fn index_list(table: &'static str) -> Self
pub const fn index_list(table: &'static str) -> Self
Same as Pragma::IndexList.
Sourcepub const fn foreign_key_list(table: &'static str) -> Self
pub const fn foreign_key_list(table: &'static str) -> Self
Same as Pragma::ForeignKeyList.
Sourcepub const fn integrity_check(table: Option<&'static str>) -> Self
pub const fn integrity_check(table: Option<&'static str>) -> Self
Same as Pragma::IntegrityCheck.
Sourcepub const fn foreign_key_check(table: Option<&'static str>) -> Self
pub const fn foreign_key_check(table: Option<&'static str>) -> Self
Same as Pragma::ForeignKeyCheck.
Sourcepub const fn table_xinfo(table: &'static str) -> Self
pub const fn table_xinfo(table: &'static str) -> Self
Same as Pragma::TableXInfo.
Sourcepub const fn encoding(encoding: Encoding) -> Self
pub const fn encoding(encoding: Encoding) -> Self
Same as Pragma::Encoding.