SQLite PRAGMA order is a unique order to be utilized to control different natural factors and state banners inside the SQLite climate. A PRAGMA worth can be perused and it can likewise be set dependent on the necessities.
Syntax
To inquiry the current PRAGMA esteem, simply give the name of the pragma.
PRAGMA pragma_name;
To set another incentive for PRAGMA, utilize the accompanying linguistic structure.
PRAGMA pragma_name = value;
The set mode can be either the name or the whole number comparable yet the returned worth will consistently be a whole number.
auto_vacuum Pragma
The auto_vacuum pragma gets or sets the auto-vacuum mode. Following is the straightforward language structure.
PRAGMA [database.]auto_vacuum;
PRAGMA [database.]auto_vacuum = mode;
Where mode can be any of the accompanying −
Sr.No. | Pragma Value & Description |
---|---|
1 |
0 or NONE Auto-vacuum is disabled. This is the default mode which means that a database file will never shrink in size unless it is manually vacuumed using the VACUUM command. |
2 |
1 or FULL Auto-vacuum is enabled and fully automatic which allows a database file to shrink as data is removed from the database. |
3 |
2 or INCREMENTAL Auto-vacuum is enabled but must be manually activated. In this mode the reference data is maintained, but free pages are simply put on the free list. These pages can be recovered using the incremental_vacuum pragma any time. |
cache_size Pragma
The cache_size pragma can get or briefly set the most extreme size of the in-memory page store. Following is the straightforward punctuation.
PRAGMA [database.]cache_size;
PRAGMA [database.]cache_size = pages;
The pages esteem addresses the quantity of pages in the reserve. The underlying page reserve has a default size of 2,000 pages and a base size of 10 pages.
case_sensitive_like Pragma
The case_sensitive_like pragma controls the case-affectability of the underlying LIKE articulation. As a matter of course, this pragma is bogus which implies that the implicit LIKE administrator disregards the letter case. Following is the straightforward grammar.
PRAGMA case_sensitive_like = [true|false];
Its absolutely impossible to question for the present status of this pragma.
count_changes Pragma
count_changes pragma gets or sets the return estimation of information control explanations, for example, INSERT, UPDATE and DELETE. Following is the straightforward linguistic structure.
PRAGMA count_changes;
PRAGMA count_changes = [true|false];
Naturally, this pragma is bogus and these proclamations don't bring anything back. Whenever set to valid, every one of the referenced assertion will restore a one-segment, one-line table comprising of a solitary number worth demonstrating affected lines by the activity.
database_list Pragma
The database_list pragma will be utilized to list down all the information bases appended. Following is the basic sentence structure.
PRAGMA database_list;
This pragma will restore a three-section table with one column for every open or appended information base giving data set succession number, its name and the document related.
encoding Pragma
The encoding pragma controls how strings are encoded and put away in a data set record. Following is the basic punctuation.
PRAGMA encoding;
PRAGMA encoding = format;
The organization worth can be one of UTF-8, UTF-16le, or UTF-16be.
freelist_count Pragma
The freelist_count pragma restores a solitary whole number demonstrating the number of information base pages are at present set apart as free and accessible. Following is the straightforward grammar.
PRAGMA [database.]freelist_count;
The organization worth can be one of UTF-8, UTF-16le, or UTF-16be.
index_info Pragma
The index_info pragma returns data about an information base record. Following is the straightforward punctuation.
PRAGMA [database.]index_info( index_name );
The outcome set will contain one line for every segment contained in the record giving section grouping, segment file with-in table and segment name.
index_list Pragma
index_list pragma records the entirety of the lists related with a table. Following is the basic language structure.
PRAGMA [database.]index_list( table_name );
The outcome set will contain one column for each record giving file grouping, file name and banner demonstrating if the file is exceptional.
journal_mode Pragma
The journal_mode pragma gets or sets the diary mode which controls how the diary document is put away and handled. Following is the straightforward language structure.
PRAGMA journal_mode;
PRAGMA journal_mode = mode;
PRAGMA database.journal_mode;
PRAGMA database.journal_mode = mode;
There are five upheld diary modes as recorded in the accompanying table.
Sr.No. | Pragma Value & Description |
---|---|
1 |
DELETE This is the default mode. Here at the conclusion of a transaction, the journal file is deleted. |
2 |
TRUNCATE The journal file is truncated to a length of zero bytes. |
3 |
PERSIST The journal file is left in place, but the header is overwritten to indicate the journal is no longer valid. |
4 |
MEMORY The journal record is held in memory, rather than on disk. |
5 |
OFF No journal record is kept. |
max_page_count Pragma
The max_page_count pragma gets or sets the greatest permitted page mean an information base. Following is the straightforward grammar.
PRAGMA [database.]max_page_count;
PRAGMA [database.]max_page_count = max_page;
The default esteem is 1,073,741,823 which is one giga-page, which implies if the default 1 KB page size, this permits data sets to grow up to one terabyte.
page_count Pragma
The page_count pragma returns in the current number of pages in the data set. Following is the basic language structure −
PRAGMA [database.]page_count;
The size of the information base record ought to be page_count * page_size.
page_size Pragma
The page_size pragma gets or sets the size of the information base pages. Following is the basic punctuation.
PRAGMA [database.]page_size;
PRAGMA [database.]page_size = bytes;
Of course, the permitted sizes are 512, 1024, 2048, 4096, 8192, 16384, and 32768 bytes. The best way to change the page size on a current information base is to set the page size and afterward promptly VACUUM the data set.
parser_trace Pragma
The parser_trace pragma controls printing the troubleshooting state as it parses SQL orders. Following is the basic sentence structure.
PRAGMA parser_trace = [true|false];
Naturally, it is set to bogus however when empowered by setting it to valid, the SQL parser will print its state as it parses SQL orders.
recursive_triggers Pragma
The recursive_triggers pragma gets or sets the recursive trigger usefulness. In the event that recursive triggers are not empowered, a trigger activity won't fire another trigger. Following is the straightforward sentence structure.
PRAGMA recursive_triggers;
PRAGMA recursive_triggers = [true|false];
schema_version Pragma
The schema_version pragma gets or sets the pattern variant worth that is put away in the data set header. Following is the straightforward linguistic structure.
PRAGMA [database.]schema_version;
PRAGMA [database.]schema_version = number;
This is a 32-cycle marked whole number worth that monitors pattern changes. At whatever point a composition changing order is executed (like, CREATE... or on the other hand DROP...), this worth is increased.
secure_delete Pragma
The secure_delete pragma is utilized to control how the substance is erased from the information base. Following is the basic language structure.
PRAGMA secure_delete;
PRAGMA secure_delete = [true|false];
PRAGMA database.secure_delete;
PRAGMA database.secure_delete = [true|false];
The default an incentive for the safe erase banner is regularly off, however this can be changed with the SQLITE_SECURE_DELETE construct choice.
sql_trace Pragma
The sql_trace pragma is utilized to dump SQL follow results to the screen. Following is the basic grammar.
PRAGMA sql_trace;
PRAGMA sql_trace = [true|false];
SQLite should be ordered with the SQLITE_DEBUG mandate for this pragma to be incorporated.
synchronous Pragma
The coordinated pragma gets or sets the current plate synchronization mode, which controls how forcefully SQLite will compose information that full distance to actual capacity. Following is the straightforward linguistic structure.
PRAGMA [database.]synchronous;
PRAGMA [database.]synchronous = mode;
SQLite underpins the accompanying synchronization modes as recorded in the table.
Sr.No. | Pragma Value & Description |
---|---|
1 |
0 or OFF No syncs at all |
2 |
1 or NORMAL Sync after each sequence of critical disk operations |
3 |
2 or FULL Sync after each critical disk operation |
temp_store Pragma
The temp_store pragma gets or sets the capacity mode utilized by brief information base documents. Following is the straightforward punctuation.
PRAGMA temp_store;
PRAGMA temp_store = mode;
SQLite upholds the accompanying stockpiling modes.
Sr.No. | Pragma Value & Description |
---|---|
1 |
0 or DEFAULT Use compile-time default. Normally FILE. |
2 |
1 or FILE Use file-based storage. |
3 |
2 or MEMORY Use memory-based storage. |
temp_store_directory Pragma
The temp_store_directory pragma gets or sets the area utilized for impermanent data set documents. Following is the basic language structure.
PRAGMA temp_store_directory;
PRAGMA temp_store_directory = 'directory_path';
user_version Pragma
The user_version pragma gets or sets the client characterized form esteem that is put away in the information base header. Following is the basic punctuation.
PRAGMA [database.]user_version;
PRAGMA [database.]user_version = number;
This is a 32-bit marked whole number worth, which can be set by the designer for variant following reason.
writable_schema Pragma
The writable_schema pragma gets or sets the capacity to adjust framework tables. Following is the basic punctuation.
PRAGMA writable_schema;
PRAGMA writable_schema = [true|false];
In the event that this pragma is set, tables that start with sqlite_ can be made and adjusted, including the sqlite_master table. Be cautious while utilizing pragma on the grounds that it can prompt total information base debasement.