sqlite
sqlite
type
open a db
sqlite3 ${database.sqlite}
in sqlite mode
-
.tableswill list tables .schema [tablename]will show the CREATE statement(s) for a table or tables-
.schema查看所有表的創建語句
-
.dump,.dump table_nameview the entire contentsselect * from some_table;
-
comment
- 兩個減號(–)則代表註解
sql
select
- 如果資料太多了,我們或許會想限制筆數:
select * from film limit 10;- 或是年份比較早的電影先列出來(預設為 ascended):
select * from film order by year limit 10;- 或是年份比較晚的電影先列出來:
select * from film order by year desc limit 10;
- 或是我們只想看電影名稱跟年份:
select title, year from film order by year desc limit 10;
- 資料庫一共有多少筆資料:
- 如果資料太多了,我們或許會想限制筆數:
設置顯示模式:
sqlite>.mode mode_name- Example:默認為list,設置為column,其他模式可通過.help查看mode相關內容
sqlite>.mode column
輸出幫助信息:
sqlite>.help
設置每一列的顯示寬度:
sqlite>.width width_value- Example:設置寬度為2
sqlite>.width 2
列出當前顯示格式的配置:
sqlite>.show
退出sqlite終端命令:
sqlite>.quitorsqlite>.exit
sqlite可以在shell底下直接執行命令:
How can one see the structure of a table in SQLite? [duplicate]