SQLite命令与SQL命令类似。 有三种类型的SQLite命令:

  • DDL:数据定义语言
  • DML:数据操作语言
  • DQL:数据查询语言



  • CREATE:此命令用于创建表,数据库中的表或其他对象的视图。

  • ALTER:此命令用于修改现有的数据库对象,如表。

  • DROPDROP命令用于删除整个表,数据库中的表或其他对象的视图。



  • INSERT:此命令用于创建记录。

  • UPDATE:用于修改记录。

  • DELETE:用于删除记录。


  • SELECT:此命令用于从一个或多个表中检索某些记录。


以下是SQLite点(.)命令的列表。 这些命令不会以分号(;)终止。




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的点(.)命令的列表。 命令及其描述如下表所示:

.backup ?db? file备份数据库(默认“main”)到文件中
.bail on/off遇到错误后停止,默认为off
.dump ?table?以sql文本格式转储数据库。如果指定表,则只转储表匹配像模式表。
.echo on/off打开或关闭echo命令
.explain on/off转向输出模式适合说明on/off。如没有参参数,则它为on
.header(s) on/off打开或关闭标题的显示
.import file table将数据从文件导入表
.indices ?table?显示所有索引的名称。如果指定表,则只显示匹配的表的索引,如模式表。
.load file ?entry?加载扩展库
.log file/off打开或关闭日志记录。文件可以是stderr/stdout
.mode mode设置输出模式
.nullvalue string打印字符串代替空值
.output filename发送输出到文件名
.output stdout发送输出到屏幕
.print string...打印文字字符串
.prompt main continue替换标准提示
.read filename在文件名中执行sql
.schema ?table?显示创建语句。如果指定表,则只显示与模式表匹配的表。
.separator string更改分隔符由输出模式和.import使用
.stats on/off打开或关闭统计信息
.tables ?pattern?列出匹配类似模式的表的名称
.timeout ms尝试打开锁定的表毫秒
.width num num设置“列”模式的列宽
.timer on/off打开或关闭cpu定时器测量







.header on

.mode column

.timer on

        原文地址: https://www.yiibai.com/sqlite/commands.html


    电子邮件地址不会被公开。 必填项已用*标注