如何从表中转储列?

时间:2014-01-18 09:13:57

标签: sql sqlite tablecolumn

我正在尝试按How do I dump the data of some SQLite3 tables?转储数据库中的表列。我感兴趣的表名为certificates,我感兴趣的列名为certificate

$ sqlite3 lbb.db 
SQLite version 3.8.3 2013-12-17 16:32:56
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from sqlite_master where type='table';
table|hardware|hardware|2|CREATE TABLE "hardware" (id INTEGER PRIMARY KEY, vendor TEXT, model TEXT, revision TEXT, description TEXT)
table|certificates|certificates|3|CREATE TABLE certificates(id INTEGER PRIMARY KEY, fingerprint TEXT, certificate TEXT, key TEXT, description TEXT)
table|firmware|firmware|4|CREATE TABLE firmware(id INTEGER PRIMARY KEY, device_id INTEGER, certificate_id INTEGER, vendor TEXT, description TEXT)

当我转储表时,我得到了完整的转储。当我尝试转储表的列时,我几乎什么也得不到:

$ sqlite3 lbb.db ".dump 'certificates.certificate'"
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
COMMIT;
$

如何将列数据转储到Sqlite数据库中?

1 个答案:

答案 0 :(得分:1)

.mode csv 
.header on 
.out file.dmp 
select certificate from certificates;