sqlite
Database; use; embedded relational database
explain
英[ɪkˈspleɪn] 美[ɪkˈsplen ]
vt.& vi. explain, explain
vt.explain the reasons for, defend
vi.explain, explain, defend
SQLite Explain function syntax
Function:Before the SQLite statement, you can use the "EXPLAIN" keyword or the "EXPLAIN QUERY PLAN" phrase to describe the details of the table. If the EXPLAIN keyword or phrase is omitted, any modification will cause the query behavior of the SQLite statement to return information about how the SQLite statement operates. Output from EXPLAIN and EXPLAIN QUERY PLAN is used only for interactive analysis and troubleshooting. The details of the output format may vary between SQLite versions. Applications should not use EXPLAIN or EXPLAIN QUERY PLAN because their exact behavior is variable and only partially logged.
Grammar: The syntax of EXPLAIN is as follows:
EXPLAIN [SQLite Query]
The syntax of EXPLAIN QUERY PLAN is as follows:
EXPLAIN QUERY PLAN [SQLite Query]
SQLite Explain function example
假设 COMPANY 表有以下记录: ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 7 James 24 Houston 10000.0 现在,让我们检查 SELECT 语句中的 Explain 使用: sqlite> EXPLAIN SELECT * FROM COMPANY WHERE Salary >= 20000; 这将产生以下结果: addr opcode p1 p2 p3 ---------- ---------- ---------- ---------- ---------- 0 Goto 0 19 1 Integer 0 0 2 OpenRead 0 8 3 SetNumColu 0 5 4 Rewind 0 17 5 Column 0 4 6 RealAffini 0 0 7 Integer 20000 0 8 Lt 357 16 collseq(BI 9 Rowid 0 0 10 Column 0 1 11 Column 0 2 12 Column 0 3 13 Column 0 4 14 RealAffini 0 0 15 Callback 5 0 16 Next 0 5 17 Close 0 0 18 Halt 0 0 19 Transactio 0 0 20 VerifyCook 0 38 21 Goto 0 1 22 Noop 0 0 现在,让我们检查 SELECT 语句中的 Explain Query Plan 使用: SQLite> EXPLAIN QUERY PLAN SELECT * FROM COMPANY WHERE Salary >= 20000; order from detail ---------- ---------- ------------- 0 0 TABLE COMPANY