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

