sqlite.1 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 SQLITE 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. sqlite \- A command line interface for SQLite
  20. .SH SYNOPSIS
  21. .B sqlite
  22. .RI [ options ] " filename " [ SQL ]
  23. .SS SUMMARY
  24. .PP
  25. sqlite is a terminal-based front-end to the SQLite library. It enables
  26. you to type in queries interactively, issue them to SQLite and see the
  27. results. Alternatively, you can specify SQL code on the command-line. In
  28. addition it provides a number of meta-commands.
  29. .SH DESCRIPTION
  30. This manual page documents briefly the
  31. .B sqlite
  32. command.
  33. This manual page was written for the Debian GNU/Linux distribution
  34. because the original program does not have a manual page.
  35. .SS GETTING STARTED
  36. .PP
  37. To start the sqlite program, just type "sqlite" followed by the name
  38. the file that holds the SQLite database. If the file does not exist, a
  39. new one is created automatically. The sqlite program will then prompt
  40. you to enter SQL. Type in SQL statements (terminated by a semicolon),
  41. press "Enter" and the SQL will be executed.
  42. For example, to create a new SQLite database named "ex1" with a single
  43. table named "tbl1", you might do this:
  44. .sp
  45. .nf
  46. $ sqlite ex1
  47. SQLite version 2.0.0
  48. Enter ".help" for instructions
  49. sqlite> create table tbl1(one varchar(10), two smallint);
  50. sqlite> insert into tbl1 values('hello!',10);
  51. sqlite> insert into tbl1 values('goodbye', 20);
  52. sqlite> select * from tbl1;
  53. hello!|10
  54. goodbye|20
  55. sqlite>
  56. .sp
  57. .fi
  58. .SS SQLITE META-COMMANDS
  59. .PP
  60. Most of the time, sqlite just reads lines of input and passes them on
  61. to the SQLite library for execution. But if an input line begins with
  62. a dot ("."), then that line is intercepted and interpreted by the
  63. sqlite program itself. These "dot commands" are typically used to
  64. change the output format of queries, or to execute certain prepackaged
  65. query statements.
  66. For a listing of the available dot commands, you can enter ".help" at
  67. any time. For example:
  68. .sp
  69. .nf
  70. .cc |
  71. sqlite> .help
  72. .dump ?TABLE? ... Dump the database in an text format
  73. .echo ON|OFF Turn command echo on or off
  74. .exit Exit this program
  75. .explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
  76. "off" will revert to the output mode that was
  77. previously in effect
  78. .header(s) ON|OFF Turn display of headers on or off
  79. .help Show this message
  80. .indices TABLE Show names of all indices on TABLE
  81. .mode MODE Set mode to one of "line(s)", "column(s)",
  82. "insert", "list", or "html"
  83. .mode insert TABLE Generate SQL insert statements for TABLE
  84. .nullvalue STRING Print STRING instead of nothing for NULL data
  85. .output FILENAME Send output to FILENAME
  86. .output stdout Send output to the screen
  87. .prompt MAIN CONTINUE Replace the standard prompts
  88. "sqlite > " and " ...> "
  89. with the strings MAIN and CONTINUE
  90. CONTINUE is optional.
  91. .quit Exit this program
  92. .read FILENAME Execute SQL in FILENAME
  93. .reindex ?TABLE? Rebuild indices
  94. .schema ?TABLE? Show the CREATE statements
  95. .separator STRING Change separator string for "list" mode
  96. .show Show the current values for the following:
  97. .echo
  98. .explain
  99. .mode
  100. .nullvalue
  101. .output
  102. .separator
  103. .width
  104. .tables ?PATTERN? List names of tables matching a pattern
  105. .timeout MS Try opening locked tables for MS milliseconds
  106. .width NUM NUM ... Set column widths for "column" mode
  107. sqlite>
  108. |cc .
  109. .sp
  110. .fi
  111. .SH OPTIONS
  112. The program has the following options:
  113. .TP
  114. .BI \-init\ file
  115. Read in and process 'file', which contains "dot commands".
  116. You can use this file to initialize display settings.
  117. .TP
  118. .B \-html
  119. Set output mode to HTML.
  120. .TP
  121. .B \-list
  122. Set output mode to 'list'.
  123. .TP
  124. .B \-line
  125. Set output mode to 'line'.
  126. .TP
  127. .B \-column
  128. Set output mode to 'column'.
  129. .TP
  130. .BI \-separator\ separator
  131. Specify which output field separator for 'list' mode to use.
  132. Default is '|'.
  133. .TP
  134. .BI \-nullvalue\ string
  135. When a null is encountered, print 'string'. Default is no string.
  136. .TP
  137. .B \-[no]header
  138. Turn headers on or off. Default is off.
  139. .TP
  140. .B \-echo
  141. Print commands before execution.
  142. .SH OUTPUT MODE
  143. The SQLite program has different output modes, which define the way
  144. the output (from queries) is formatted.
  145. In 'list' mode, which is the default, one record per line is output,
  146. each field separated by the separator specified with the
  147. \fB-separator\fP option or \fB.separator\fP command.
  148. In 'line' mode, each column is output on its own line, records are
  149. separated by blank lines.
  150. In HTML mode, an XHTML table is generated.
  151. In 'column' mode, one record per line is output, aligned neatly in colums.
  152. .SH INIT FILE
  153. sqlite can be initialized using resource files. These can be combined with
  154. command line arguments to set up sqlite exactly the way you want it.
  155. Initialization proceeds as follows:
  156. o The defaults of
  157. .sp
  158. .nf
  159. .cc |
  160. mode = LIST
  161. separator = "|"
  162. main prompt = "sqlite> "
  163. continue prompt = " ...> "
  164. |cc .
  165. .sp
  166. .fi
  167. are established.
  168. o If a file .sqliterc can be found in the user's home directory, it is
  169. read and processed. It should only contain "dot commands". If the
  170. file is not found or cannot be read, processing continues without
  171. notification.
  172. o If a file is specified on the command line with the -init option, it
  173. is processed in the same manner as .sqliterc
  174. o All other command line options are processed
  175. o The database is opened and you are now ready to begin.
  176. .SH SEE ALSO
  177. http://www.hwaci.com/sw/sqlite/
  178. .br
  179. The sqlite-doc package
  180. .SH AUTHOR
  181. This manual page was originally written by Andreas Rottmann
  182. <rotty@debian.org>, for the Debian GNU/Linux system (but may be used
  183. by others).