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