Sql 如何从表中转储列?
我正在尝试在数据库中转储表的列。我感兴趣的表称为Sql 如何从表中转储列?,sql,sqlite,tablecolumn,Sql,Sqlite,Tablecolumn,我正在尝试在数据库中转储表的列。我感兴趣的表称为证书,我感兴趣的列称为证书: $ 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|hard
证书
,我感兴趣的列称为证书
:
$ 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数据库中转储列数据?谢谢bernie。我在别处找到了,但我不喜欢条目周围的
“
(csv模式)或证书=
(行模式)因为输出必须通过sed
运行,所以每个条目都有前缀。但我认为这是我能做的最好的事情。如果我理解正确,您可以使用字符串操作删除查询本身中的前缀文本。我刚刚测试了这一点,得到了一个格式良好的文本文件,其中包含列标题,然后是标题下的值。
.mode csv
.header on
.out file.dmp
select certificate from certificates;