SQLite命令與SQL命令類似。 有三種類型的SQLite命令:
數(shù)據(jù)定義語言中主要有三個(gè)命令:
CREATE:此命令用于創(chuàng)建表,數(shù)據(jù)庫中的表或其他對象的視圖。
ALTER:此命令用于修改現(xiàn)有的數(shù)據(jù)庫對象,如表。
DROP:DROP命令用于刪除整個(gè)表,數(shù)據(jù)庫中的表或其他對象的視圖。
數(shù)據(jù)操作語言中主要有三個(gè)命令:
INSERT:此命令用于創(chuàng)建記錄。
UPDATE:用于修改記錄。
DELETE:用于刪除記錄。
以下是SQLite點(diǎn)(.)命令的列表。 這些命令不會以分號(;)終止。
.help
可在任何時(shí)候使用“.help”檢查點(diǎn)命令列表。
例如:
QLite version 3.18.0 2017-03-28 18:48:43
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .help
.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
.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
.databases List names and files of attached databases
.dbinfo ?DB? Show status information about the database
.dump ?TABLE? ... Dump the database in an SQL text format
If TABLE specified, only dump tables matching
LIKE pattern TABLE.
.echo on|off Turn command echo on or off
.eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN
.exit Exit this program
.explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic
.fullschema ?--indent? Show schema and the content of sqlite_stat tables
.headers on|off Turn display of headers on or off
.help Show this message
.import FILE TABLE Import data from FILE into TABLE
.imposter INDEX TABLE Create imposter table TABLE on index INDEX
.indexes ?TABLE? Show names of all indexes
If TABLE specified, only show indexes for tables
matching LIKE pattern TABLE.
.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
.mode MODE ?TABLE? Set output mode where MODE is one of:
ascii Columns/rows delimited by 0x1F and 0x1E
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
line One value per line
list Values delimited by "|"
quote Escape answers as for SQL
tabs Tab-separated values
tcl TCL list elements
.nullvalue STRING Use STRING in place of NULL values
.once FILENAME Output for the next SQL command only to FILENAME
.open ?--new? ?FILE? Close existing database and reopen FILE
The --new starts with an empty file
.output ?FILENAME? Send output to FILENAME or stdout
.print STRING... Print literal STRING
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.restore ?DB? FILE Restore content of DB (default "main") from FILE
.save FILE Write in-memory database into FILE
.scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off
.schema ?PATTERN? Show the CREATE statements matching PATTERN
Add --indent for pretty-printing
.selftest ?--init? Run tests defined in the SELFTEST table
.separator COL ?ROW? Change the column separator and optionally the row
separator for both the output mode and .import
.sha3sum ?OPTIONS...? 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 ?on|off? Show stats or turn stats on or off
.system CMD ARGS... Run CMD ARGS... in a system shell
.tables ?TABLE? List names of tables
If TABLE specified, only list tables matching
LIKE pattern TABLE.
.testcase NAME Begin redirecting output to 'testcase-out.txt'
.timeout MS Try opening locked tables for MS milliseconds
.timer on|off Turn SQL timer on or off
.trace FILE|off 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 column widths for "column" mode
Negative values right-justify
sqlite>
以上是各種SQLite的點(diǎn)(.)命令的列表。 命令及其描述如下表所示:
| 命令 | 描述說明 |
|---|---|
.backup ?db? file |
備份數(shù)據(jù)庫(默認(rèn)“main”)到文件中 |
.bail on/off |
遇到錯(cuò)誤后停止,默認(rèn)為off |
.databases |
附件數(shù)據(jù)庫的列表名稱和文件 |
.dump ?table? |
以sql文本格式轉(zhuǎn)儲數(shù)據(jù)庫。如果指定表,則只轉(zhuǎn)儲表匹配像模式表。 |
.echo on/off |
打開或關(guān)閉echo命令 |
.exit |
退出sqlite提示符 |
.explain on/off |
轉(zhuǎn)向輸出模式適合說明on/off。如沒有參參數(shù),則它為on。 |
.header(s) on/off |
打開或關(guān)閉標(biāo)題的顯示 |
.help |
顯示指定幫助消息 |
.import file table |
將數(shù)據(jù)從文件導(dǎo)入表 |
.indices ?table? |
顯示所有索引的名稱。如果指定表,則只顯示匹配的表的索引,如模式表。 |
.load file ?entry? |
加載擴(kuò)展庫 |
.log file/off |
打開或關(guān)閉日志記錄。文件可以是stderr/stdout |
.mode mode |
設(shè)置輸出模式 |
.nullvalue string |
打印字符串代替空值 |
.output filename |
發(fā)送輸出到文件名 |
.output stdout |
發(fā)送輸出到屏幕 |
.print string... |
打印文字字符串 |
.prompt main continue |
替換標(biāo)準(zhǔn)提示 |
.quit |
退出sqlite提示符 |
.read filename |
在文件名中執(zhí)行sql |
.schema ?table? |
顯示創(chuàng)建語句。如果指定表,則只顯示與模式表匹配的表。 |
.separator string |
更改分隔符由輸出模式和.import使用 |
.show |
顯示各種設(shè)置的當(dāng)前值 |
.stats on/off |
打開或關(guān)閉統(tǒng)計(jì)信息 |
.tables ?pattern? |
列出匹配類似模式的表的名稱 |
.timeout ms |
嘗試打開鎖定的表毫秒 |
.width num num |
設(shè)置“列”模式的列寬 |
.timer on/off |
打開或關(guān)閉cpu定時(shí)器測量 |
.show命令
可以使用.show命令查看SQLite命令提示符的默認(rèn)設(shè)置。

注意:不要在
sqlite>提示符和.命令之間放置空格,否則將不起作用。
其它特殊點(diǎn)命令
有一些點(diǎn)(.)命令用于格式化輸出。這些命令是:
.header on
.mode column
.timer on