如何配置 sqlite 以默认显示标头

有没有办法配置 sqlite3以便在默认情况下显示标头?

我知道我可以使用 .headers on来打开头文件,但是每次启动客户端时我都必须不停地输入它,因为设置不会在会话之间保持不变。我希望标题永久保持开启状态。

41508 次浏览

From the fine manual:

INIT FILE
sqlite3 reads an initialization file to set the configuration of the interactive environment. [...] If the file ~/.sqliterc exists, it is processed first. can be found in the user's home directory, it is read and processed. It should generally only contain meta-commands.

So just put a file called .sqliterc in your home directory and put this in it:

.headers ON

You can pass arguments in the command line too:

sqlite3 db.db  -header -column  "select x from y;"