归类 : 默认分类

sqlite3.exe

执行“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

以上