SQLite导出整个数据库/导出某个表到SQL文件

来源:互联网 发布:smt贴片机编程 编辑:程序博客网 时间:2024/05/16 04:20

突然想导出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.sqlite3sqlite> .output db.SQLsqlite> .dumpsqlite> .exit我们导出表tb1到db.SQL文件的方式:Use ".open FILENAME" to reopen on a persistent database.sqlite> .open db.sqlite3sqlite> .output db.SQLsqlite> .dump tb1sqlite> .exit
完。

0 0
原创粉丝点击