1
0

sqlite3.1 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 "Mon Apr 15 23:49:17 2002"
  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.1.3
  49. .br
  50. Enter ".help" for instructions
  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. .cc |
  102. .databases List names and files of attached databases
  103. .dump ?TABLE? ... Dump the database in an SQL text format
  104. .echo ON|OFF Turn command echo on or off
  105. .exit Exit this program
  106. .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
  107. .header(s) ON|OFF Turn display of headers on or off
  108. .help Show this message
  109. .import FILE TABLE Import data from FILE into TABLE
  110. .indices TABLE Show names of all indices on TABLE
  111. .mode MODE ?TABLE? Set output mode where MODE is one of:
  112. csv Comma-separated values
  113. column Left-aligned columns. (See .width)
  114. html HTML <table> code
  115. insert SQL insert statements for TABLE
  116. line One value per line
  117. list Values delimited by .separator string
  118. tabs Tab-separated values
  119. tcl TCL list elements
  120. .nullvalue STRING Print STRING in place of NULL values
  121. .output FILENAME Send output to FILENAME
  122. .output stdout Send output to the screen
  123. .prompt MAIN CONTINUE Replace the standard prompts
  124. .quit Exit this program
  125. .read FILENAME Execute SQL in FILENAME
  126. .schema ?TABLE? Show the CREATE statements
  127. .separator STRING Change separator used by output mode and .import
  128. .show Show the current values for various settings
  129. .tables ?PATTERN? List names of tables matching a LIKE pattern
  130. .timeout MS Try opening locked tables for MS milliseconds
  131. .width NUM NUM ... Set column widths for "column" mode
  132. sqlite>
  133. |cc .
  134. .sp
  135. .fi
  136. .SH OPTIONS
  137. .B sqlite3
  138. has the following options:
  139. .TP
  140. .BI \-init\ file
  141. Read and execute commands from
  142. .I file
  143. , which can contain a mix of SQL statements and meta-commands.
  144. .TP
  145. .B \-echo
  146. Print commands before execution.
  147. .TP
  148. .B \-[no]header
  149. Turn headers on or off.
  150. .TP
  151. .B \-column
  152. Query results will be displayed in a table like form, using
  153. whitespace characters to separate the columns and align the
  154. output.
  155. .TP
  156. .B \-html
  157. Query results will be output as simple HTML tables.
  158. .TP
  159. .B \-line
  160. Query results will be displayed with one value per line, rows
  161. separated by a blank line. Designed to be easily parsed by
  162. scripts or other programs
  163. .TP
  164. .B \-list
  165. Query results will be displayed with the separator (|, by default)
  166. character between each field value. The default.
  167. .TP
  168. .BI \-separator\ separator
  169. Set output field separator. Default is '|'.
  170. .TP
  171. .BI \-nullvalue\ string
  172. Set string used to represent NULL values. Default is ''
  173. (empty string).
  174. .TP
  175. .B \-version
  176. Show SQLite version.
  177. .TP
  178. .B \-help
  179. Show help on options and exit.
  180. .SH INIT FILE
  181. .B sqlite3
  182. reads an initialization file to set the configuration of the
  183. interactive environment. Throughout initialization, any previously
  184. specified setting can be overridden. The sequence of initialization is
  185. as follows:
  186. o The default configuration is established as follows:
  187. .sp
  188. .nf
  189. .cc |
  190. mode = LIST
  191. separator = "|"
  192. main prompt = "sqlite> "
  193. continue prompt = " ...> "
  194. |cc .
  195. .sp
  196. .fi
  197. o If the file
  198. .B ~/.sqliterc
  199. exists, it is processed first.
  200. can be found in the user's home directory, it is
  201. read and processed. It should generally only contain meta-commands.
  202. o If the -init option is present, the specified file is processed.
  203. o All other command line options are processed.
  204. .SH SEE ALSO
  205. http://www.sqlite.org/
  206. .br
  207. The sqlite-doc package
  208. .SH AUTHOR
  209. This manual page was originally written by Andreas Rottmann
  210. <rotty@debian.org>, for the Debian GNU/Linux system (but may be used
  211. by others). It was subsequently revised by Bill Bumgarner <bbum@mac.com>.