sqlite3.1 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. .\" Hey, EMACS: -*- nroff -*-
  2. .\" First parameter, NAME, should be all caps
  3. .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
  4. .\" other parameters are allowed: see man(7), man(1)
  5. .TH SQLITE3 1 "Fri Aug 11 23:50:12 CET 2023"
  6. .\" Please adjust this date whenever revising the manpage.
  7. .\"
  8. .\" Some roff macros, for reference:
  9. .\" .nh disable hyphenation
  10. .\" .hy enable hyphenation
  11. .\" .ad l left justify
  12. .\" .ad b justify to both left and right margins
  13. .\" .nf disable filling
  14. .\" .fi enable filling
  15. .\" .br insert line break
  16. .\" .sp <n> insert n+1 empty lines
  17. .\" for manpage-specific macros, see man(7)
  18. .SH NAME
  19. .B sqlite3
  20. \- A command line interface for SQLite version 3
  21. .SH SYNOPSIS
  22. .B sqlite3
  23. .RI [ options ]
  24. .RI [ databasefile ]
  25. .RI [ SQL ]
  26. .SH SUMMARY
  27. .PP
  28. .B sqlite3
  29. is a terminal-based front-end to the SQLite library that can evaluate
  30. queries interactively and display the results in multiple formats.
  31. .B sqlite3
  32. can also be used within shell scripts and other applications to provide
  33. batch processing features.
  34. .SH DESCRIPTION
  35. To start a
  36. .B sqlite3
  37. interactive session, invoke the
  38. .B sqlite3
  39. command and optionally provide the name of a database file. If the
  40. database file does not exist, it will be created. If the database file
  41. does exist, it will be opened.
  42. For example, to create a new database file named "mydata.db", create
  43. a table named "memos" and insert a couple of records into that table:
  44. .sp
  45. $
  46. .B sqlite3 mydata.db
  47. .br
  48. SQLite version 3.43.0 2023-08-11 17:45:23
  49. .br
  50. Enter ".help" for usage hints.
  51. .br
  52. sqlite>
  53. .B create table memos(text, priority INTEGER);
  54. .br
  55. sqlite>
  56. .B insert into memos values('deliver project description', 10);
  57. .br
  58. sqlite>
  59. .B insert into memos values('lunch with Christine', 100);
  60. .br
  61. sqlite>
  62. .B select * from memos;
  63. .br
  64. deliver project description|10
  65. .br
  66. lunch with Christine|100
  67. .br
  68. sqlite>
  69. .sp
  70. If no database name is supplied, the ATTACH sql command can be used
  71. to attach to existing or create new database files. ATTACH can also
  72. be used to attach to multiple databases within the same interactive
  73. session. This is useful for migrating data between databases,
  74. possibly changing the schema along the way.
  75. Optionally, a SQL statement or set of SQL statements can be supplied as
  76. a single argument. Multiple statements should be separated by
  77. semi-colons.
  78. For example:
  79. .sp
  80. $
  81. .B sqlite3 -line mydata.db 'select * from memos where priority > 20;'
  82. .br
  83. text = lunch with Christine
  84. .br
  85. priority = 100
  86. .br
  87. .sp
  88. .SS SQLITE META-COMMANDS
  89. .PP
  90. The interactive interpreter offers a set of meta-commands that can be
  91. used to control the output format, examine the currently attached
  92. database files, or perform administrative operations upon the
  93. attached databases (such as rebuilding indices). Meta-commands are
  94. always prefixed with a dot (.).
  95. A list of available meta-commands can be viewed at any time by issuing
  96. the '.help' command. For example:
  97. .sp
  98. sqlite>
  99. .B .help
  100. .nf
  101. .tr %.
  102. ...
  103. .sp
  104. .fi
  105. The available commands differ by version and build options, so they
  106. are not listed here. Please refer to your local copy for all available
  107. options.
  108. .SH INIT FILE
  109. .B sqlite3
  110. reads an initialization file to set the configuration of the
  111. interactive environment. Throughout initialization, any previously
  112. specified setting can be overridden. The sequence of initialization is
  113. as follows:
  114. o The default configuration is established as follows:
  115. .sp
  116. .nf
  117. .cc |
  118. mode = LIST
  119. separator = "|"
  120. main prompt = "sqlite> "
  121. continue prompt = " ...> "
  122. |cc .
  123. .sp
  124. .fi
  125. o If the file
  126. .B ${XDG_CONFIG_HOME}/sqlite3/sqliterc
  127. or
  128. .B ~/.sqliterc
  129. exists, the first of those to be found is processed during startup.
  130. It should generally only contain meta-commands.
  131. o If the -init option is present, the specified file is processed.
  132. o All other command line options are processed.
  133. .SH SEE ALSO
  134. https://sqlite.org/cli.html
  135. .br
  136. https://sqlite.org/fiddle (a WebAssembly build of the CLI app)
  137. .br
  138. The sqlite3-doc package.
  139. .SH AUTHOR
  140. This manual page was originally written by Andreas Rottmann
  141. <rotty@debian.org>, for the Debian GNU/Linux system (but may be used
  142. by others). It was subsequently revised by Bill Bumgarner <bbum@mac.com>,
  143. Laszlo Boszormenyi <gcs@debian.hu>, and the sqlite3 developers.