## Summary **No review yet** ## Minimized query ```sql PRAGMA max_page_count; PRAGMA user_version; .load /home/test/sqlite3-src/build/rot13.so SELECT rot13('' || ('SMI 31/12 CHF 100000 PUTS')); CREATE TABLE T ( a TEXT, b TEXT, c REAL ); INSERT INTO T VALUES ('a','b',if(NULL, NULL, NULL)), ('a','c',-degrees(-trunc(2147483648))), ('b','b',4.75); CREATE TABLE T1 ( A VARCHAR(10) PRIMARY KEY, B VARCHAR(15) UNIQUE, C INTEGER ); CREATE TABLE main.T2 ( X VARCHAR(20) PRIMARY KEY, A VARCHAR(10) NOT NULL UNIQUE, FOREIGN KEY (A) REFERENCES T1(A) ); INSERT INTO T1 VALUES ('a', 'p', -2147483648); INSERT INTO T1 VALUES ('b', 'q', 2147483647); INSERT INTO T2 VALUES ('m', 'a'); INSERT INTO T2 VALUES ('n', 'b'); SELECT T2.X, T1.B, T1.C FROM T2, T1 WHERE T2.A = T1.A AND T1.C >= 0; SELECT a, SUM(CASE WHEN b!='b' THEN c ELSE 0 END) AS d, SUM(CASE WHEN b='c' THEN c ELSE 0 END) AS e FROM T GROUP BY a; ATTACH DATABASE ':memory:' AS aux38; PRAGMA mmap_size = 50000000; .once .help .help .archive .help .auth .help .backup .help .bail .help .cd .help .changes .help .check .help .clone .help .connection .help .databases .help .dbconfig .help .dbinfo .help .dump /* PRAGMA parser_trace = ON; */ .help .echo .help .eqp .help .excel .help .exit .help .expert .help .explain .help .filectrl .help .fullschema .help .headers .help .help .help .import .help .imposter .help .indexes .help .limit .help .lint .help .load .help .log .help .mode .help .nonce .help .nullvalue .help .once .help .open .help .output .help .parameter .help .print .help .progress .help .prompt .help .quit .help .read .help .recover .help .restore .help .save .help .scanstats .help .schema .help .separator .help .sha3sum .help .shell .help .show .help .stats .help .system .help .tables .help .timeout .help .timer .help .trace .help .version .help .vfsinfo .help .vfslist .help .vfsname .help .width BEGIN DEFERRED TRANSACTION; -- json_insert({v}, '$.key', {v}) ATTACH DATABASE (('' || '') || (':memory:') || '') AS aux15; .exit -'_' BEGIN EXCLUSIVE; ((PRAGMA)) count_changes = NO; PRAGMA defer_foreign_keys = TRUE; PRAGMA wal_autocheckpoint; CREATE TABLE T ( a INTEGER, b TEXT, c REAL, d REAL ); INSERT INTO T VALUES ('' || ('{"a":1,"b":[1,2,3]}'),'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999); SELECT b FROM T WHERE NOT NOT (NOT NOT (NOT NOT (ABS(c) > 5 AND ABS(d) > 5))) ; PRAGMA encoding = 'UTF-16'; PRAGMA full_column_names = NO; PRAGMA count_changes = ON; CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT); INSERT INTO t1 VALUES (1, 'Wernher', 10, 100); INSERT INTO t1 VALUES (2, 'von', 20, 200); INSERT INTO t1 VALUES (3, 'Braun', 30, 300); CREATE INDEX t1bc ON t1(b, c); PRAGMA writable_schema = ON; .imposter t1bc t2 SELECT * FROM t2; SELECT b, c FROM t1 ORDER BY b, c; .quit PRAGMA checkpoint_fullsync = 9223372036854775806; .progress CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES(1,'aaa','bbb'); INSERT INTO t1 SELECT * FROM t1; INSERT INTO t1 VALUES(2,'ccc','ddd'); SELECT DISTINCT a AS x, b||c AS y FROM t1 WHERE NOT NOT (y IN ('aaabbb','xxx')) ; SELECT DISTINCT a AS x, b||c AS y FROM t1 WHERE +y='aaabbb'; DROP TRIGGER IF EXISTS t1; ANALYZE; ALTER TABLE t1 RENAME COLUMN c TO c_r9068; PRAGMA writable_schema = OFF; SELECT AVG(b) FROM t1; ALTER TABLE t1 DROP COLUMN a; CREATE VIEW IF NOT EXISTS v_t1_9739 AS SELECT b FROM t1; ALTER TABLE t1 RENAME COLUMN c TO c_r2779; PRAGMA count_changes = NO; PRAGMA defer_foreign_keys = TRUE; PRAGMA wal_autocheckpoint; CREATE TABLE T ( a INTEGER, b TEXT, c REAL, d REAL ); INSERT INTO T VALUES ('' || ('{"a":1,"b":[1,2,3]}'),'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999); SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5; PRAGMA encoding = 'UTF-16'; PRAGMA full_column_names = NO; PRAGMA count_changes = ON; CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT); INSERT INTO t1 VALUES (1, 'Wernher', 10, 100); INSERT INTO t1 VALUES (2, 'von', 20, 200); INSERT INTO t1 VALUES (3, 'Braun', 30, 300); CREATE INDEX t1bc ON t1(b, c); PRAGMA writable_schema = ON; .imposter t1bc t2 SELECT * FROM t2; SELECT b, c FROM t1 ORDER BY b, c; .quit PRAGMA checkpoint_fullsync = 9223372036854775806; .progress CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES(1,'aaa','bbb'); INSERT INTO t1 SELECT * FROM t1; INSERT INTO t1 VALUES(2,'ccc','ddd'); SELECT DISTINCT a AS x, b||c AS y FROM t1 WHERE NOT NOT (y IN ('aaabbb','xxx')) ; SELECT DISTINCT a AS x, b||c AS y FROM t1 WHERE +y='aaabbb'; DROP TRIGGER IF EXISTS t1; ANALYZE; ALTER TABLE t1 RENAME COLUMN c TO c_r9068; PRAGMA writable_schema = OFF; SELECT AVG(b) FROM t1; ALTER TABLE t1 DROP COLUMN a; CREATE VIEW IF NOT EXISTS v_t1_9739 AS SELECT b FROM t1; ALTER TABLE t1 RENAME COLUMN c TO c_r2779; PRAGMA count_changes = NO; PRAGMA /**/ defer_foreign_keys = TRUE; PRAGMA wal_autocheckpoint; CREATE TABLE T ( a INTEGER, b TEXT, c REAL, d REAL ); INSERT INTO T VALUES ('' || ('{"a":1,"b":[1,2,3]}'),'a',40.5,-70.0), (2,'b',-10.25,20.5), (3,'c',9e999,-9e999); SELECT b FROM T WHERE ABS(c) > 5 AND ABS(d) > 5; PRAGMA encoding = 'UTF-16'; PRAGMA full_column_names = NO; PRAGMA count_changes = ON; CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT); INSERT INTO t1 VALUES (1, 'Wernher', 10, 100); INSERT INTO t1 VALUES (2, 'von', 20, 200); INSERT INTO t1 VALUES (3, 'Braun', 30, 300); CREATE INDEX t1bc ON t1(b, c); PRAGMA writable_schema = ON; .imposter t1bc t2 SELECT * FROM t2; SELECT b, c FROM t1 ORDER BY b, c; .quit PRAGMA checkpoint_fullsync = 9223372036854775806; .progress CREATE TABLE t1(a, b, c); INSERT INTO t1 VALUES(1,'aaa','bbb'); INSERT INTO t1 SELECT * FROM t1; INSERT INTO t1 VALUES(2,'ccc','ddd'); SELECT DISTINCT a AS x, b||c AS y FROM t1 WHERE NOT NOT (y IN ('aaabbb','xxx')) ; SELECT DISTINCT a AS x, b||c AS y FROM t1 WHERE +y='aaabbb'; DROP TRIGGER IF EXISTS t1; ANALYZE; ALTER TABLE t1 RENAME COLUMN c TO c_r9068; PRAGMA writable_schema = OFF; SELECT AVG(b) FROM t1; ALTER TABLE t1 DROP COLUMN a; CREATE VIEW IF NOT EXISTS v_t1_9739 AS SELECT b FROM t1; ALTER TABLE t1 RENAME COLUMN c TO c_r2779; COMMIT TRANSACTION; DELETE FROM T WHERE d IS NULL RETURNING *; INSERT INTO T DEFAULT VALUES; INSERT OR ROLLBACK INTO T VALUES (0, NULL, '', ''); SELECT LAG(a, 2) OVER (ORDER BY a ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM t1; SELECT * FROM T AS a FULL JOIN t1 AS b ON a.rowid = b.rowid; DETACH DATABASE aux15; COMMIT; PRAGMA vdbe_addoptrace = NO; WITH cte AS (SELECT d, RANK() OVER (ORDER BY d) AS rnk FROM T) SELECT * FROM cte; WITH RECURSIVE r AS (SELECT c FROM T UNION ALL SELECT c FROM T LIMIT 5) SELECT * FROM r; WITH cte AS (SELECT c FROM T UNION SELECT c FROM T) SELECT * FROM cte; ALTER TABLE T RENAME COLUMN b TO b_r7810; CREATE INDEX IF NOT EXISTS idx_T_9258 ON T(d COLLATE NOCASE); INSERT INTO t1 VALUES ('x', NULL, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c; INSERT INTO t1 VALUES (NULL, NULL, 1) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c; INSERT INTO T VALUES (NULL, NULL, NULL, NULL); DELETE FROM T WHERE a > (SELECT AVG(a) FROM T) RETURNING *; ALTER TABLE t1 ADD COLUMN extra_5967 BIGINT DEFAULT (random()); INSERT INTO T DEFAULT VALUES; DROP TRIGGER IF EXISTS T; INSERT INTO t1 VALUES (1, NULL, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c; CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT); INSERT INTO t1 VALUES (1, 'Wernher', 10, 100); INSERT INTO t1 VALUES (2, 'von', 20, 200); INSERT INTO t1 VALUES (3, 'Braun', 30, 300); CREATE INDEX t1bc ON t1(b, c); PRAGMA writable_schema = ON; .imposter t1bc /**/ t2 SELECT * FROM t2; SELECT b, c FROM t1 ORDER BY b, c; .quit ALTER TABLE T ADD COLUMN extra_256 DOUBLE PRECISION DEFAULT (random()); WITH RECURSIVE empty(x) AS (SELECT 1 WHERE 1=0 UNION ALL SELECT x+1 FROM empty WHERE x<10) SELECT * FROM empty; DELETE FROM t1 WHERE a > (SELECT AVG(a) FROM t1); DELETE FROM t1 WHERE rowid = 54; WITH cte AS (SELECT * FROM T WHERE b IN (SELECT b FROM T LIMIT 5)) SELECT * FROM cte; SELECT COUNT(*) FILTER (WHERE a IS NOT NULL), SUM(rowid) FILTER (WHERE a > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(a) FILTER (WHERE a > 0 AND a < 100), COUNT(*) FILTER (WHERE typeof(a) = "text") FROM t1; DETACH DATABASE aux38; DROP INDEX IF EXISTS T; VACUUM main; INSERT INTO t1 DEFAULT VALUES; CREATE TRIGGER IF NOT EXISTS trg_T_9906 BEFORE UPDATE OF c ON T FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'rb'); END; INSERT INTO T SELECT * FROM T; CREATE TRIGGER IF NOT EXISTS trg_t1_7906 BEFORE INSERT ON t1 BEGIN INSERT INTO t1(a) VALUES (NULL); END; INSERT INTO t1 DEFAULT VALUES; SELECT * FROM t1; INSERT INTO T VALUES ('x', NULL, NULL, 1) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c; INSERT INTO T DEFAULT VALUES; UPDATE T SET c = NULL WHERE c IS NOT NULL RETURNING *; SELECT * FROM T WHERE d <= ALL (SELECT d FROM T); SELECT COUNT(*) FROM T; DELETE FROM T WHERE 1; ALTER TABLE t1 RENAME TO t1_r4683; SELECT * FROM t1 t1 JOIN t1 t2 ON t1.b = (SELECT b FROM t1 LIMIT 1); ANALYZE T; SELECT COUNT(*) FILTER (WHERE b IS NOT NULL), SUM(rowid) FILTER (WHERE b > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(b) FILTER (WHERE b > 0 AND b < 100), COUNT(*) FILTER (WHERE typeof(b) = "text") FROM T; UPDATE t1 SET d = 'x' WHERE 1 RETURNING *; CREATE TRIGGER IF NOT EXISTS trg_T_949 BEFORE INSERT ON T FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'abort'); END; PRAGMA recursive_triggers = YES; ALTER TABLE t1 RENAME TO t1_r8323; DROP INDEX IF EXISTS t1; ALTER TABLE T DROP COLUMN c; INSERT INTO t1 DEFAULT VALUES; REINDEX t1; INSERT INTO T1 VALUES ('x', NULL, 1) ON CONFLICT(A) DO UPDATE SET A = excluded.A, B = excluded.B, C = excluded.C; SELECT * FROM T; INSERT INTO T2 DEFAULT VALUES; ``` ## Actual output ```sql 1073741823 0 FZV 31/12 PUS 100000 CHGF n|q|2147483647 .auth ON|OFF Show authorizer callbacks .backup ?DB? FILE Backup DB (default "main") to FILE .bail on|off Stop after hitting an error. Default OFF .binary on|off Turn binary output on or off. Default OFF .cd DIRECTORY Change the working directory to DIRECTORY .changes on|off Show number of rows changed by SQL .check GLOB Fail if output since .testcase does not match .clone NEWDB Clone data into NEWDB from the existing database .connection [close] [#] Open or close an auxiliary database connection .databases List names and files of attached databases .dbconfig ?op? ?val? List or change sqlite3_db_config() options .dbinfo ?DB? Show status information about the database .dump ?OBJECTS? Render database content as SQL .echo on|off Turn command echo on or off .eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN .excel Display the output of next command in spreadsheet .exit ?CODE? Exit this program with return-code CODE .expert EXPERIMENTAL. Suggest indexes for queries .explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto .filectrl CMD ... Run various sqlite3_file_control() operations .fullschema ?--indent? Show schema and the content of sqlite_stat tables .headers on|off Turn display of headers on or off .help ?-all? ?PATTERN? Show help text for PATTERN .import FILE TABLE Import data from FILE into TABLE .imposter INDEX TABLE Create imposter table TABLE on index INDEX .indexes ?TABLE? Show names of indexes .limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT .lint OPTIONS Report potential schema issues. .load FILE ?ENTRY? Load an extension library .log FILE|off Turn logging on or off. FILE can be stderr/stdout .mode MODE ?OPTIONS? Set output mode .nonce STRING Suspend safe mode for one command if nonce matches .nullvalue STRING Use STRING in place of NULL values .once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE .open ?OPTIONS? ?FILE? Close existing database and reopen FILE .output ?FILE? Send output to FILE or stdout if FILE is omitted .parameter CMD ... Manage SQL parameter bindings .print STRING... Print literal STRING .progress N Invoke progress handler after every N opcodes .prompt MAIN CONTINUE Replace the standard prompts .quit Exit this program .read FILE Read input from FILE or command output .recover Recover as much data as possible from corrupt db. .restore ?DB? FILE Restore content of DB (default "main") from FILE .save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...) .scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off .schema ?PATTERN? Show the CREATE statements matching PATTERN .selftest ?OPTIONS? Run tests defined in the SELFTEST table .separator COL ?ROW? Change the column and row separators .sha3sum ... Compute a SHA3 hash of database content .shell CMD ARGS... Run CMD ARGS... in a system shell .show Show the current values for various settings .stats ?ARG? Show stats or turn stats on or off .system CMD ARGS... Run CMD ARGS... in a system shell .tables ?TABLE? List names of tables matching LIKE pattern TABLE .testcase NAME Begin redirecting output to 'testcase-out.txt' .testctrl CMD ... Run various sqlite3_test_control() operations .timeout MS Try opening locked tables for MS milliseconds .timer on|off Turn SQL timer on or off .trace ?OPTIONS? Output each SQL statement as it is run .vfsinfo ?AUX? Information about the top-level VFS .vfslist List all available VFSes .vfsname ?AUX? Print the name of the VFS stack .width NUM1 NUM2 ... Set minimum column widths for columnar output Nothing matches '.archive' .auth ON|OFF Show authorizer callbacks .backup ?DB? FILE Backup DB (default "main") to FILE Options: --append Use the appendvfs --async Write to FILE without journal and fsync() .save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...) .bail on|off Stop after hitting an error. Default OFF .cd DIRECTORY Change the working directory to DIRECTORY .changes on|off Show number of rows changed by SQL .check GLOB Fail if output since .testcase does not match .clone NEWDB Clone data into NEWDB from the existing database .connection [close] [#] Open or close an auxiliary database connection .databases List names and files of attached databases .dbconfig ?op? ?val? List or change sqlite3_db_config() options .dbinfo ?DB? Show status information about the database .dump ?OBJECTS? Render database content as SQL Options: --data-only Output only INSERT statements --newlines Allow unescaped newline characters in output --nosys Omit system tables (ex: "sqlite_stat1") --preserve-rowids Include ROWID values in the output OBJECTS is a LIKE pattern for tables, indexes, triggers or views to dump Additional LIKE patterns can be given in subsequent arguments .eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN Other Modes: trigger Like "full" but also show trigger bytecode .excel Display the output of next command in spreadsheet --bom Put a UTF8 byte-order mark on intermediate file .once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE If FILE begins with '|' then open as a pipe --bom Put a UTF8 byte-order mark at the beginning -e Send output to the system text editor -x Send output as CSV to a spreadsheet (same as ".excel") .exit ?CODE? Exit this program with return-code CODE .expert EXPERIMENTAL. Suggest indexes for queries .explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto .filectrl CMD ... Run various sqlite3_file_control() operations --schema SCHEMA Use SCHEMA instead of "main" --help Show CMD details .fullschema ?--indent? Show schema and the content of sqlite_stat tables .headers on|off Turn display of headers on or off .help ?-all? ?PATTERN? Show help text for PATTERN .import FILE TABLE Import data from FILE into TABLE Options: --ascii Use \037 and \036 as column and row separators --csv Use , and \n as column and row separators --skip N Skip the first N rows of input --schema S Target table to be S.TABLE -v "Verbose" - increase auxiliary output Notes: * If TABLE does not exist, it is created. The first row of input determines the column names. * If neither --csv or --ascii are used, the input mode is derived from the ".mode" output mode * If FILE begins with "|" then it is a command that generates the input text. .imposter INDEX TABLE Create imposter table TABLE on index INDEX .indexes ?TABLE? Show names of indexes If TABLE is specified, only show indexes for tables matching TABLE using the LIKE operator. .limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT .lint OPTIONS Report potential schema issues. Options: fkey-indexes Find missing foreign key indexes .load FILE ?ENTRY? Load an extension library .log FILE|off Turn logging on or off. FILE can be stderr/stdout .import FILE TABLE Import data from FILE into TABLE Options: --ascii Use \037 and \036 as column and row separators --csv Use , and \n as column and row separators --skip N Skip the first N rows of input --schema S Target table to be S.TABLE -v "Verbose" - increase auxiliary output Notes: * If TABLE does not exist, it is created. The first row of input determines the column names. * If neither --csv or --ascii are used, the input mode is derived from the ".mode" output mode * If FILE begins with "|" then it is a command that generates the input text. .mode MODE ?OPTIONS? Set output mode MODE is one of: ascii Columns/rows delimited by 0x1F and 0x1E box Tables using unicode box-drawing characters csv Comma-separated values column Output in columns. (See .width) html HTML