These commands below can set column names:
.headers on
.header on
Then, you can get the result with column names as shown below:
sqlite> SELECT * FROM user;
id|first_name|last_name|age
1|Steve|Jobs|56
2|Bill|Gates|66
3|Mark|Zuckerberg|38
And, these commands below can unset column names:
.headers off
.header off
Then, you can get the result without column names as shown below:
sqlite> SELECT * FROM user;
1|Steve|Jobs|56
2|Bill|Gates|66
3|Mark|Zuckerberg|38
And, these commands below can show the details of the command .headers
:
.help .headers
.help .header
.help headers
.help header
Then, you can show the details of the command .headers
as shown below:
sqlite> .help .headers
.headers on|off Turn display of headers on or off
In addition, this command below can set the output mode box
:
.mode box
Then, you can set the output mode box
as shown below:
sqlite> SELECT * FROM user;
┌────┬────────────┬────────────┬─────┐
│ id │ first_name │ last_name │ age │
├────┼────────────┼────────────┼─────┤
│ 1 │ Steve │ Jobs │ 56 │
│ 2 │ Bill │ Gates │ 66 │
│ 3 │ Mark │ Zuckerberg │ 38 │
└────┴────────────┴────────────┴─────┘
And, this command below sets the output mode table
:
.mode table
Then, you can set the output mode table
as shown below:
sqlite> SELECT * FROM user;
+----+------------+------------+-----+
| id | first_name | last_name | age |
+----+------------+------------+-----+
| 1 | Steve | Jobs | 56 |
| 2 | Bill | Gates | 66 |
| 3 | Mark | Zuckerberg | 38 |
+----+------------+------------+-----+
And, these commands can show the details of the command .mode
:
.help .mode
.help mode
.help modes
Then, you can show the details of the command .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
Lastly, you can show the commands .headers
and .mode
with .help
as shown below:
sqlite> .help
...
.headers on|off Turn display of headers on or off
...
.mode MODE ?OPTIONS? Set output mode
...
SQLite.swift
, see this question and answer for a simple list of column names or this one for migration issues.