2021-01-21

SQLite管理工具SQLite-tools

這裡目前不會提到如何在程式中加入SQLite來處理程式要管理的資料,主要是介紹透過SQLite的管理工具,來管理在SQLite檔案中的資料。

SQLite的Slogan : Small. Fast. Reliable. Choose any three.
SQLite官網:https://www.sqlite.org/
SQLite Download Page : https://www.sqlite.org/download.html 
在SQLite的下載頁面,以搜尋的方式找到所需作業系統的對應版本:
以下載 sqlite-tools-win32-x86-3290000.zip 為例


透過7-zip提供的CRC SHA 檔案驗證功能,計算所下載檔案的SHA1值:
(只要能計算SHA1都可以,不一定要用7-zip;但驗證是必要的,尤其是在非官方網站或知名度、信賴度較低)


SHA-1比對吻合,就可以安心的使用了...

SQLite-tools不需要安裝,解壓縮即可使用 ... SQLite提供文字界面的操作方式,開啟sqlite3.exe後,可以使用 .help 查看相關管指令


Help 指令清單
.archive ...Manage SQL archives
.auth ON|OFFShow authorizer callbacks
.backup ?DB? FILEBackup DB (default "main") to FILE
.bail on|offStop after hitting an error. Default OFF
.binary on|offTurn binary output on or off. Default OFF
.cd DIRECTORYChange the working directory to DIRECTORY
.changes on|offShow number of rows changed by SQL
.check GLOBFail if output since .testcase does not match
.clone NEWDBClone data into NEWDB from the existing database
.databasesList 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 all database content as SQL
.echo on|offTurn command echo on or off
.eqp on|off|full|...Enable or disable automatic EXPLAIN QUERY PLAN
.excelDisplay the output of next command in a spreadsheet
.exit ?CODE?Exit this program with return-code CODE
.expertEXPERIMENTAL. Suggest indexes for specified queries
.filectrl CMD ...Run various sqlite3_file_control() operations
.fullschema ?--indent?Show schema and the content of sqlite_stat tables
.headers on|offTurn display of headers on or off
.help ?-all? ?PATTERN?Show help text for PATTERN
.import FILE TABLEImport data from FILE into TABLE
.imposter INDEX TABLECreate 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 OPTIONSReport potential schema issues.
.load FILE ?ENTRY?Load an extension library
.log FILE|offTurn logging on or off. FILE can be stderr/stdout
.mode MODE ?TABLE?Set output mode
.nullvalue STRINGUse STRING in place of NULL values
.once (-e|-x|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 NInvoke progress handler after every N opcodes
.prompt MAIN CONTINUEReplace the standard prompts
.quitExit this program
.read FILERead input from FILE
.recoverRecover as much data as possible from corrupt db.
.restore ?DB? FILERestore content of DB (default "main") from FILE
.save FILEWrite in-memory database into FILE
.scanstats on|offTurn 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
.showShow 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 NAMEBegin redirecting output to 'testcase-out.txt'
.testctrl CMD ...Run various sqlite3_test_control() operations
.timeout MSTry opening locked tables for MS milliseconds
.timer on|offTurn SQL timer on or off
.trace ?OPTIONS?Output each SQL statement as it is run
.vfsinfo ?AUX?Information about the top-level VFS
.vfslistList all available VFSes
.vfsname ?AUX?Print the name of the VFS stack
.width NUM1 NUM2 ...Set column widths for "column" mode