115

we know when type .mode column let me see tables like column And .headers on , we can see the header of tables. But I want to know if there is any way make the two default settings?

Do some modify for the source code of sqlite?? OR is there a config file for these settings?

Victor K.
  • 4,054
  • 3
  • 25
  • 38
aelam
  • 2,796
  • 2
  • 27
  • 32

2 Answers2

205

Put:

.headers on
.mode column

In a file called .sqliterc in the home directory of the user running sqlite.

(P.S. I found that in man sqlite3.)

Sdaz MacSkibbons
  • 27,668
  • 7
  • 32
  • 34
  • 7
    If you are using Windows, you should create the file %USERPROFILE%\.sqliterc. For instance, by executing the following on the command-line: `(echo .mode columns && echo .headers on) >%USERPROFILE%\.sqliterc` – Dennie Apr 13 '17 at 12:45
  • Create `.sqliterc` file if not avaialble in the home directory and add. Initially I thought `.sqliterc` is available in the home directory. But after reading man page again, I read this statement 'If the file ~/.sqliterc exists', if not avaialble, we can create it. – chanduthedev Oct 16 '19 at 02:02
  • @chanduthedev yep, the ".something" file in home directory is a standard *nix way of doing user configuration, not obvious unless you're a *nix user – yrebrac Jul 26 '20 at 04:23
  • I was hoping there would be a global `.sqliterc` that applies to all users. But that does not seem to be the case. – rwfbc Feb 15 '21 at 19:25
12

Make sure using the following command to open the file:

nano ~/.sqliterc

then add

.headers on
.mode column

to the file and save it

DevB2F
  • 4,674
  • 4
  • 36
  • 60