8
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sqlite メモ

Last updated at Posted at 2014-11-06

設定

$HOME/.sqliterc に設定を書いておくと、毎回 .header on とか
打たなくて良い。

.headers on
.mode line

mode は column, line などが指定可。

外部SQL文の読み込み

$ sqlite3 mydatabase.db < create.sql

大量のデータを突っ込む

auto commit みたいなのOFFにしないととても遅い。
begin してがーっとinsert, commit すると早い。

65000レコードで、下記のような感じ。

auto commit on: 72.91 sec
auto commit off: 15.99 sec

TSVファイルのインポート

sqlite> .separator "\t"
sqlite> .import data.tsv table_name

TSVファイルへのエクスポート

sqlite> .header off        /* ヘッダは表示しない */
sqlite> .mode tabs         /* TABに */
sqlite> .output hoge3.tsv  /* 出力先変更 */
sqlite> select * from table_name;

その他

.help すればだいたい分かる。

8
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?