在SQLite上,我顯示了表“用戶”,如下所示,但選擇輸出的格式不正確,因此很難看到:
sqlite> .header on
sqlite> select * from user;
id|first_name|last_name|age
1|Steve|Jobs|56
2|Bill|Gates|66
3|Mark|Zuckerberg|38
我想要格式更好的選擇輸出,如下所示,或者選擇輸出的任何格式都可以,只要格式比上面更好:
id|first_name|last_name |age
1 |Steve |Jobs |56
2 |Bill |Gates |66
3 |Mark |Zuckerberg|38
有沒有辦法改變選擇輸出的格式?
uj5u.com熱心網友回復:
下面的這個命令設定輸出模式“box”:
.mode box
然后,它如下所示:
sqlite> .header on
sqlite> select * from user;
┌────┬────────────┬────────────┬─────┐
│ id │ first_name │ last_name │ age │
├────┼────────────┼────────────┼─────┤
│ 1 │ Steve │ Jobs │ 56 │
│ 2 │ Bill │ Gates │ 66 │
│ 3 │ Mark │ Zuckerberg │ 38 │
└────┴────────────┴────────────┴─────┘
并且,下面的這個命令設定了輸出模式“table”:
.mode table
然后,它如下所示:
sqlite> .header on
sqlite> select * from user;
---- ------------ ------------ -----
| id | first_name | last_name | age |
---- ------------ ------------ -----
| 1 | Steve | Jobs | 56 |
| 2 | Bill | Gates | 66 |
| 3 | Mark | Zuckerberg | 38 |
---- ------------ ------------ -----
共有14 種輸出模式,如下圖所示:
box Tables using unicode box-drawing characters
csv Comma-separated values
column Output in columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
json Results in a JSON array
line One value per line
list Values delimited by "|"
markdown Markdown table format
qbox Shorthand for "box --width 60 --quote"
quote Escape answers as for SQL
table ASCII-art table
tabs Tab-separated values
tcl TCL list elements
這些命令顯示了命令 ".mode" 的詳細資訊:
.help .mode
或者:
.help mode
然后,它如下所示:
sqlite> .help .mode
.import FILE TABLE Import data from FILE into TABLE
Options:
--ascii Use \037 and \036 as column and row separators
--csv Use , and \n as column and row separators
--skip N Skip the first N rows of input
--schema S Target table to be S.TABLE
-v "Verbose" - increase auxiliary output
Notes:
* If TABLE does not exist, it is created. The first row of input
determines the column names.
* If neither --csv or --ascii are used, the input mode is derived
from the ".mode" output mode
* If FILE begins with "|" then it is a command that generates the
input text.
.mode MODE ?OPTIONS? Set output mode
MODE is one of:
ascii Columns/rows delimited by 0x1F and 0x1E
box Tables using unicode box-drawing characters
csv Comma-separated values
column Output in columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
json Results in a JSON array
line One value per line
list Values delimited by "|"
markdown Markdown table format
qbox Shorthand for "box --width 60 --quote"
quote Escape answers as for SQL
table ASCII-art table
tabs Tab-separated values
tcl TCL list elements
OPTIONS: (for columnar modes or insert mode):
--wrap N Wrap output lines to no longer than N characters
--wordwrap B Wrap or not at word boundaries per B (on/off)
--ww Shorthand for "--wordwrap 1"
--quote Quote output text as SQL literals
--noquote Do not quote output text
TABLE The name of SQL table used for "insert" mode
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/480480.html
下一篇:如何顯示“空”(SQLite)