SQLite’s PRAGMA The command is a special command that can be used to control various environment variables and status flags in the SQLite environment. One To query the current To work for Setting mode, which can be a name or an equivalent integer, but the value returned will always be an integer. auto_vacuum Pragma gets or sets Among them mode It can be any of the following: Pragma value Description 0 or NONE Disable Auto-vacuum. This is the default mode, which means that the database file size will not be reduced unless you use the VACUUM command manually. 1 or FULL Enable Auto-vacuum, which is fully automatic. In this mode, the database file is allowed to shrink as the data is removed from the database. 2 or INCREMENTAL Auto-vacuum is enabled, but must be activated manually. In this mode, the reference data is maintained and the free page is only placed in the free list. These pages can be overridden with incremental_vacuum pragma at any time. cache_size Pragma can get or temporarily set the maximum size of the page cache in memory. The syntax is as follows: pages Value represents the number of pages in the cache. The default size of the built-in page cache is 2000 pages, with a minimum size of 10 pages. case_sensitive_like Pragma controls the built-in There is currently no way to query the count_changes Pragma gets or sets the return values of data manipulation statements, such as INSERT, UPDATE, and DELETE. The syntax is as follows: By default, the Pragma is false, and these statements return nothing. If set to true, each mentioned statement returns a single-row, single-column table consisting of a single integer value that represents the row affected by the operation. database_list Pragma will be used to list all database connections. The syntax is as follows: The Pragma will return a single-row, three-column table, and each time you open or attach a database, it will give the serial number in the database, its name, and related files. encoding Pragma controls how strings are encoded and stored in database files. The syntax is as follows: The format value can be one of UTF-8, UTF-16le, or UTF-16be. freelist_count Pragma returns an integer indicating the number of database pages currently marked as free and available. The syntax is as follows: index_info Pragma returns information about the database index. The syntax is as follows: The result set displays a row for each column contained in the given column sequence, the column index in the table, and the column name. index_list Pragma lists all the indexes associated with the table. The syntax is as follows: The result set displays a row for each given column sequence index, index name, and identification indicating whether the index is unique. journal_mode Pragma gets or sets the log mode that controls how log files are stored and processed. The syntax is as follows: Five logging modes are supported here: Pragma value Description DELETE Default mode. In this mode, the log file is deleted at the end of the transaction. TRUNCATE The log file is in phase with zero byte length. PERSIST The log file is left in place, but the header is rewritten, indicating that the log is no longer valid. MEMORY Logging is kept in memory, not on disk. OFF No log records are retained. max_page_count Pragma gets or sets the maximum number of pages allowed for the database. The syntax is as follows: The default value is 1 gigabyte, which is a gigabyte page, that is, if the default page size is 1 KB, then one megabyte grows in the database. page_count Pragma returns the number of pages in the current database. The syntax is as follows: The size of the database file should be page_count* page_size. page_size Pragma gets or sets the size of the database page. The syntax is as follows: By default, the allowed sizes are 512, 1024, 2048, 4096, 8192, 16384, 32768 bytes. The only way to change the page size of an existing database is to set the page size and then VACUUM the database immediately. parser_trace Pragma parses the SQL command with it to control the debugging state of the print. The syntax is as follows: By default, it is set to false, but when set to true, it is enabled, and the SQL parser parses the SQL command with it to print out its state. recursive_triggers Pragma gets or sets recursive trigger functionality. If recursive triggers are not enabled, one trigger action will not trigger another trigger. The syntax is as follows: schema_version Pragma gets or sets the schema version value stored in the database header. The syntax is as follows: This is a 32-bit signed integer value that is used to track architectural changes. Whenever a schema change command is executed (such as CREATE… Or DROP…), this value is incremented. secure_delete Pragma is used to control how content is deleted from the database. The syntax is as follows: The default value of the secure delete flag is usually turned off, but this can be done through the sql_trace Pragma is used to dump the SQL trace results to the screen. The syntax is as follows: SQLite must compile the Pragma to be referenced through the SQLITE_DEBUG directive. synchronous Pragma gets or sets the synchronization mode of the current disk, which controls how active SQLite writes data to physical storage. The syntax is as follows: SQLite supports the following synchronization modes: Pragma value Description 0 or OFF Do not synchronize. 1 or NORMAL Synchronize after each sequence of critical disk operations. 2 or FULL Synchronize after each critical disk operation. temp_store Pragma gets or sets the storage mode used by the tempdb file. The syntax is as follows: SQLite supports the following storage modes: Pragma value Description 0 or DEFAULT Compile-time mode is used by default. Usually FILE. 1 or FILE Use file-based storage. 2 or MEMORY Use memory-based storage. temp_store_directory Pragma gets or sets the location used for tempdb files. The syntax is as follows: user_version Pragma gets or sets the user-defined version value stored in the database header. The syntax is as follows: This is a 32-bit signed integer value that can be set by the developer for version tracking purposes. writable_schema Pragma gets or sets whether the system table can be modified. The syntax is as follows: If the
PRAGMA
Values can be read or set as needed. 1.27.1. Grammar ¶
PRAGMA
Value, you only need to provide the
pragma
Name:PRAGMA pragma_name;
PRAGMA
Set a new value with the following syntax:PRAGMA pragma_name = value;
1.27.2. Auto_vacuum Pragma ¶
auto-vacuum
Mode. The syntax is as follows:PRAGMA [database.]auto_vacuum;
PRAGMA [database.]auto_vacuum = mode;
1.27.3. Cache_size Pragma ¶
PRAGMA [database.]cache_size;
PRAGMA [database.]cache_size = pages;
1.27.4. Case_sensitive_like Pragma ¶
LIKE
Case sensitivity of the expression. By default, the
Pragma
For
false
Which means that the built-in
LIKE
Operator ignores the case of letters. The syntax is as follows:PRAGMA case_sensitive_like = [true|false];
Pragma
The current state of the 1.27.5. Count_changes Pragma ¶
PRAGMA count_changes;
PRAGMA count_changes = [true|false];
1.27.6. Database_list Pragma ¶
PRAGMA database_list;
1.27.7. Encoding Pragma ¶
PRAGMA encoding;
PRAGMA encoding = format;
1.27.8. Freelist_count Pragma ¶
PRAGMA [database.]freelist_count;
1.27.9. Index_info Pragma ¶
PRAGMA [database.]index_info( index_name );
1.27.10. Index_list Pragma ¶
PRAGMA [database.]index_list( table_name );
1.27.11. Journal_mode Pragma ¶
PRAGMA journal_mode;
PRAGMA journal_mode = mode;
PRAGMA database.journal_mode;
PRAGMA database.journal_mode = mode;
1.27.12. Max_page_count Pragma ¶
PRAGMA [database.]max_page_count;
PRAGMA [database.]max_page_count = max_page;
1.27.13. Page_count Pragma ¶
PRAGMA [database.]page_count;
1.27.14. Page_size Pragma ¶
PRAGMA [database.]page_size;
PRAGMA [database.]page_size = bytes;
1.27.15. Parser_trace Pragma ¶
PRAGMA parser_trace = [true|false];
1.27.16. Recursive_triggers Pragma ¶
PRAGMA recursive_triggers;
PRAGMA recursive_triggers = [true|false];
1.27.17. Schema_version Pragma ¶
PRAGMA [database.]schema_version;
PRAGMA [database.]schema_version = number;
1.27.18. Secure_delete Pragma ¶
PRAGMA secure_delete;
PRAGMA secure_delete = [true|false];
PRAGMA database.secure_delete;
PRAGMA database.secure_delete = [true|false];
SQLITE_SECURE_DELETE
Build options to change. 1.27.19. Sql_trace Pragma ¶
PRAGMA sql_trace;
PRAGMA sql_trace = [true|false];
1.27.20. Synchronous Pragma ¶
PRAGMA [database.]synchronous;
PRAGMA [database.]synchronous = mode;
1.27.21. Temp_store Pragma ¶
PRAGMA temp_store;
PRAGMA temp_store = mode;
1.27.22. Temp_store_directory Pragma ¶
PRAGMA temp_store_directory;
PRAGMA temp_store_directory = 'directory_path';
1.27.23. User_version Pragma ¶
PRAGMA [database.]user_version;
PRAGMA [database.]user_version = number;
1.27.24. Writable_schema Pragma ¶
PRAGMA writable_schema;
PRAGMA writable_schema = [true|false];
Pragma
, then the table is
sqlite\_
To begin, you can create and modify, including
sqlite_master
Watch. Use the
Pragma
Be careful, as it can lead to corruption of the entire database.