您的位置:首頁技術文章
文章詳情頁

一些很有用的SQLite命令總結

瀏覽:209日期:2023-04-05 14:55:57

顯示表結構:
復制代碼 代碼如下:
sqlite> .schema [table]

獲取所有表和視圖:
復制代碼 代碼如下:
sqlite > .tables

獲取指定表的索引列表:
復制代碼 代碼如下:
sqlite > .indices [table ]

導出數據庫到 SQL 文件:
復制代碼 代碼如下:
sqlite > .output [filename ]
sqlite > .dump
sqlite > .output stdout

從 SQL 文件導入數據庫:
復制代碼 代碼如下:
sqlite > .read [filename ]

格式化輸出數據到 CSV 格式:
復制代碼 代碼如下:
sqlite >.output [filename.csv ]
sqlite >.separator ,
sqlite > select * from test;
sqlite >.output stdout

從 CSV 文件導入數據到表中:
復制代碼 代碼如下:
sqlite >create table newtable ( id integer primary key, value text );
sqlite >.import [filename.csv ] newtable

備份數據庫:
復制代碼 代碼如下:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 mytable.db .dump > backup.sql

恢復數據庫:
復制代碼 代碼如下:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 mytable.db < backup.sql

標簽: SQLite
相關文章:
国产综合久久一区二区三区