sqlite3.exe的基本使用

本文介绍了SQLite3.exe的使用,包括显示版本信息、查看帮助文档、打开数据库、执行基本SQL操作等。通过命令行交互,我们可以创建、修改和查询SQLite数据库,如插入数据到表格中,并通过各种命令查看数据库状态。


sqlite3.exe Ver 3.33版本 2020-8-14出版,还是蛮新的版本。

E:\sqlite3>sqlite3 --version #显示sqlite3的版本
3.33.0 2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0alt2

E:\sqlite3>sqlite3 --help #显示帮助文档
Usage: sqlite3 [OPTIONS] FILENAME [SQL]
FILENAME is the name of an SQLite database. A new database is created
if the file does not previously exist.
OPTIONS include:
   -append              append the database to the end of the file
   -ascii               set output mode to 'ascii'
   -bail                stop after hitting an error
   -batch               force batch I/O
   -box                 set output mode to 'box'
   -column              set output mode to 'column'
   -cmd COMMAND         run "COMMAND" before reading stdin
   -csv                 set output mode to 'csv'
   -echo                print commands before execution
   -init FILENAME       read/process named file
   -[no]header          turn headers on or off
   -help                show this message
   -html                set output mode to HTML
   -interactive         force interactive I/O
   -json                set output mode to 'json'
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -lookaside SIZE N    use N entries of SZ bytes for lookaside memory
   -markdown            set output mode to 'markdown'
   -memtrace            trace all memory allocations and deallocations
   -mmap N              default mmap size set to N
   -newline SEP         set output row separator. Default: '\n'
   -nofollow            refuse to open symbolic links to database files
   -nullvalue TEXT      set text string for NULL values. Default ''
   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory
   -quote               set output mode to 'quote'
   -readonly            open the database read-only
   -separator SEP       set output column separator. Default: '|'
   -stats               print memory stats before each finalize
   -table               set output mode to 'table'
   -version             show SQLite version
   -vfs NAME            use NAME as the default VFS


E:\sqlite3>sqlite3 mydb.db
SQLite version 3.33.0 2020-08-14 13:23:32
Enter ".help" for usage hints.

sqlite> .help #注意命令前面要加个"."点号。 ".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
.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
.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 ?TABLE?            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 ?TABLE?       Set output mode
.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
.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
.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 ?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 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

sqlite> .databases #显示链接(open)的数据库
main: E:\sqlite3\mydb.db

sqlite> .show # .show
        echo: off
         eqp: off
     explain: auto
     headers: off
        mode: list
   nullvalue: ""
      output: stdout
colseparator: "|"
rowseparator: "\n"
       stats: off
       width:
    filename: mydb.db

sqlite> INSERT INTO test values(?,?,?),(6, "zgq", 20); #插入数据sql语句末尾要加";"分号!
sqlite> select * from test;
||
3|name3|19
||
6|zgq|20
sqlite> .q # .q == .quit 退出系统。

E:\sqlite3>

E:\sqlite3>dir
 驱动器 E 中的卷是 DATA2
 卷的序列号是 68B0-6A2A

 E:\sqlite3 的目录

2021/02/01  00:41    <DIR>          .
2021/02/01  00:41    <DIR>          ..
2021/02/01  00:09    <DIR>          info
2021/02/01  00:09    <DIR>          Library
2021/02/01  00:41             8,192 mydb.db
2020/08/20  18:00         1,549,824 sqlite3.dll
2020/08/20  18:00         1,852,928 sqlite3.exe
2021/02/01  00:17             2,005 sqlite_help.txt
               4 个文件      3,412,949 字节
               4 个目录 73,885,323,264 可用字节

E:\sqlite3>dir /s
 驱动器 E 中的卷是 DATA2
 卷的序列号是 68B0-6A2A

 E:\sqlite3 的目录

2021/02/01  00:41    <DIR>          .
2021/02/01  00:41    <DIR>          ..
2021/02/01  00:09    <DIR>          info
2021/02/01  00:09    <DIR>          Library
2021/02/01  00:41             8,192 mydb.db
2020/08/20  18:00         1,549,824 sqlite3.dll
2020/08/20  18:00         1,852,928 sqlite3.exe
2021/02/01  00:17             2,005 sqlite_help.txt
               4 个文件      3,412,949 字节

 E:\sqlite3\info 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/20  18:01             4,539 about.json
2020/08/20  18:01               102 files
2020/08/20  18:01                 0 git
2020/08/20  18:01                48 hash_input.json
2020/08/20  18:01               386 index.json
2020/08/20  18:01               872 paths.json
2021/02/01  00:09    <DIR>          recipe
2021/01/31  19:16               861 repodata_record.json
2020/08/20  18:01                36 run_exports.json
2021/02/01  00:09    <DIR>          test
               8 个文件          6,844 字节

 E:\sqlite3\info\recipe 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/17  22:42             1,499 bld.bat
2020/08/17  22:42             5,307 build.sh
2020/08/20  18:01             2,099 conda_build_config.yaml
2020/08/20  18:01             2,296 meta.yaml
2020/08/20  22:57             5,065 meta.yaml.template
2021/02/01  00:09    <DIR>          patches
2020/08/20  22:57            26,229 recipe_log.txt
               6 个文件         42,495 字节

 E:\sqlite3\info\recipe\patches 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2021/02/01  00:09    <DIR>          applicable-to-amalgamated
               0 个文件              0 字节

 E:\sqlite3\info\recipe\patches\applicable-to-amalgamated 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/17  22:42               714 0001-expose_symbols.patch
               1 个文件            714 字节

 E:\sqlite3\info\test 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/20  18:01               337 run_test.bat
               1 个文件            337 字节

 E:\sqlite3\Library 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2021/02/01  00:09    <DIR>          bin
2021/02/01  00:09    <DIR>          include
2021/02/01  00:09    <DIR>          lib
               0 个文件              0 字节

 E:\sqlite3\Library\bin 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/20  18:00         1,549,824 sqlite3.dll
2020/08/20  18:00         1,852,928 sqlite3.exe
               2 个文件      3,402,752 字节

 E:\sqlite3\Library\include 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/20  18:00           580,732 sqlite3.h
               1 个文件        580,732 字节

 E:\sqlite3\Library\lib 的目录

2021/02/01  00:09    <DIR>          .
2021/02/01  00:09    <DIR>          ..
2020/08/20  18:00            64,474 sqlite3.lib
               1 个文件         64,474 字节

     所列文件总数:
              24 个文件      7,511,297 字节
              29 个目录 73,885,323,264 可用字节

E:\sqlite3>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值