一些很有用的SQLite命令總結(jié)
更新時間:2015年07月06日 09:13:15 投稿:junjie
這篇文章主要介紹了一些很有用的SQLite命令總結(jié),本文總結(jié)了顯示表結(jié)構(gòu)、獲取所有表和視圖、獲取指定表的索引列表、導出數(shù)據(jù)庫到 SQL 文件、從 SQL 文件導入數(shù)據(jù)庫等一些非常有用的操作命令,需要的朋友可以參考下
顯示表結(jié)構(gòu):
復制代碼 代碼如下:
sqlite> .schema [table]
獲取所有表和視圖:
復制代碼 代碼如下:
sqlite > .tables
獲取指定表的索引列表:
復制代碼 代碼如下:
sqlite > .indices [table ]
導出數(shù)據(jù)庫到 SQL 文件:
復制代碼 代碼如下:
sqlite > .output [filename ]
sqlite > .dump
sqlite > .output stdout
從 SQL 文件導入數(shù)據(jù)庫:
復制代碼 代碼如下:
sqlite > .read [filename ]
格式化輸出數(shù)據(jù)到 CSV 格式:
復制代碼 代碼如下:
sqlite >.output [filename.csv ]
sqlite >.separator ,
sqlite > select * from test;
sqlite >.output stdout
從 CSV 文件導入數(shù)據(jù)到表中:
復制代碼 代碼如下:
sqlite >create table newtable ( id integer primary key, value text );
sqlite >.import [filename.csv ] newtable
備份數(shù)據(jù)庫:
復制代碼 代碼如下:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 mytable.db .dump > backup.sql
恢復數(shù)據(jù)庫:
復制代碼 代碼如下:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 mytable.db < backup.sql
相關文章
sqlite時間戳轉(zhuǎn)時間語句(時間轉(zhuǎn)時間戳)
這篇文章主要介紹了sqlite時間戳轉(zhuǎn)時間、時間轉(zhuǎn)時間戳的方法,需要的朋友可以參考下2014-06-06
SQLite教程(五):索引和數(shù)據(jù)分析/清理
這篇文章主要介紹了SQLite教程(五):索引和數(shù)據(jù)分析/清理,本文講解了創(chuàng)建索引、刪除索引、重建索引、數(shù)據(jù)分析、數(shù)據(jù)清理等內(nèi)容,需要的朋友可以參考下2015-05-05

