突然想導出SQLite數據庫的某個表的數據,然後就記錄一下:
執行“sqlite3.exe”,我們可能用到下面幾個命令:
sqlite> .help
.dump ?TABLE? ... Dump the database in an SQL text format
If TABLE specified, only dump tables matching
LIKE pattern TABLE.
.exit Exit this program
.help Show this message
.open ?--new? ?FILE? Close existing database and reopen FILE
The --new starts with an empty file
.output ?FILENAME? Send output to FILENAME or stdout
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.tables ?TABLE? List names of tables
If TABLE specified, only list tables matching
LIKE pattern TABLE.
sqlite>
假設我們有一個SQLite數據庫文件,名爲db.sqlite3,這個數據庫中有2個表,分別爲tb1和tb2,
我們導出整個數據庫到db.SQL文件的方式:
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open db.sqlite3
sqlite> .output db.SQL
sqlite> .dump
sqlite> .exit
我們導出表tb1到db.SQL文件的方式:
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open db.sqlite3
sqlite> .output db.SQL
sqlite> .dump tb1
sqlite> .exit
完。