diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/www/sqlite.tcl')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/www/sqlite.tcl | 582 |
1 files changed, 582 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/www/sqlite.tcl b/libraries/sqlite/unix/sqlite-3.5.1/www/sqlite.tcl new file mode 100644 index 0000000..eed1cd7 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/www/sqlite.tcl | |||
@@ -0,0 +1,582 @@ | |||
1 | # | ||
2 | # Run this Tcl script to generate the sqlite.html file. | ||
3 | # | ||
4 | set rcsid {$Id: sqlite.tcl,v 1.25 2007/01/08 14:31:36 drh Exp $} | ||
5 | source common.tcl | ||
6 | header {sqlite3: A command-line access program for SQLite databases} | ||
7 | puts { | ||
8 | <h2>sqlite3: A command-line access program for SQLite databases</h2> | ||
9 | |||
10 | <p>The SQLite library includes a simple command-line utility named | ||
11 | <b>sqlite3</b> that allows the user to manually enter and execute SQL | ||
12 | commands against an SQLite database. This document provides a brief | ||
13 | introduction on how to use <b>sqlite3</b>. | ||
14 | |||
15 | <h3>Getting Started</h3> | ||
16 | |||
17 | <p>To start the <b>sqlite3</b> program, just type "sqlite3" followed by | ||
18 | the name the file that holds the SQLite database. If the file does | ||
19 | not exist, a new one is created automatically. | ||
20 | The <b>sqlite3</b> program will | ||
21 | then prompt you to enter SQL. Type in SQL statements (terminated by a | ||
22 | semicolon), press "Enter" and the SQL will be executed.</p> | ||
23 | |||
24 | <p>For example, to create a new SQLite database named "ex1" | ||
25 | with a single table named "tbl1", you might do this:</p> | ||
26 | } | ||
27 | |||
28 | proc Code {body} { | ||
29 | puts {<blockquote><tt>} | ||
30 | regsub -all {&} [string trim $body] {\&} body | ||
31 | regsub -all {>} $body {\>} body | ||
32 | regsub -all {<} $body {\<} body | ||
33 | regsub -all {\(\(\(} $body {<b>} body | ||
34 | regsub -all {\)\)\)} $body {</b>} body | ||
35 | regsub -all { } $body {\ } body | ||
36 | regsub -all \n $body <br>\n body | ||
37 | puts $body | ||
38 | puts {</tt></blockquote>} | ||
39 | } | ||
40 | |||
41 | Code { | ||
42 | $ (((sqlite3 ex1))) | ||
43 | SQLite version 3.3.10 | ||
44 | Enter ".help" for instructions | ||
45 | sqlite> (((create table tbl1(one varchar(10), two smallint);))) | ||
46 | sqlite> (((insert into tbl1 values('hello!',10);))) | ||
47 | sqlite> (((insert into tbl1 values('goodbye', 20);))) | ||
48 | sqlite> (((select * from tbl1;))) | ||
49 | hello!|10 | ||
50 | goodbye|20 | ||
51 | sqlite> | ||
52 | } | ||
53 | |||
54 | puts { | ||
55 | <p>You can terminate the sqlite3 program by typing your systems | ||
56 | End-Of-File character (usually a Control-D) or the interrupt | ||
57 | character (usually a Control-C).</p> | ||
58 | |||
59 | <p>Make sure you type a semicolon at the end of each SQL command! | ||
60 | The sqlite3 program looks for a semicolon to know when your SQL command is | ||
61 | complete. If you omit the semicolon, sqlite3 will give you a | ||
62 | continuation prompt and wait for you to enter more text to be | ||
63 | added to the current SQL command. This feature allows you to | ||
64 | enter SQL commands that span multiple lines. For example:</p> | ||
65 | } | ||
66 | |||
67 | Code { | ||
68 | sqlite> (((CREATE TABLE tbl2 ())) | ||
69 | ...> ((( f1 varchar(30) primary key,))) | ||
70 | ...> ((( f2 text,))) | ||
71 | ...> ((( f3 real))) | ||
72 | ...> ((();))) | ||
73 | sqlite> | ||
74 | } | ||
75 | |||
76 | puts { | ||
77 | |||
78 | <h3>Aside: Querying the SQLITE_MASTER table</h3> | ||
79 | |||
80 | <p>The database schema in an SQLite database is stored in | ||
81 | a special table named "sqlite_master". | ||
82 | You can execute "SELECT" statements against the | ||
83 | special sqlite_master table just like any other table | ||
84 | in an SQLite database. For example:</p> | ||
85 | } | ||
86 | |||
87 | Code { | ||
88 | $ (((sqlite3 ex1))) | ||
89 | SQlite vresion 3.3.10 | ||
90 | Enter ".help" for instructions | ||
91 | sqlite> (((select * from sqlite_master;))) | ||
92 | type = table | ||
93 | name = tbl1 | ||
94 | tbl_name = tbl1 | ||
95 | rootpage = 3 | ||
96 | sql = create table tbl1(one varchar(10), two smallint) | ||
97 | sqlite> | ||
98 | } | ||
99 | |||
100 | puts { | ||
101 | <p> | ||
102 | But you cannot execute DROP TABLE, UPDATE, INSERT or DELETE against | ||
103 | the sqlite_master table. The sqlite_master | ||
104 | table is updated automatically as you create or drop tables and | ||
105 | indices from the database. You can not make manual changes | ||
106 | to the sqlite_master table. | ||
107 | </p> | ||
108 | |||
109 | <p> | ||
110 | The schema for TEMPORARY tables is not stored in the "sqlite_master" table | ||
111 | since TEMPORARY tables are not visible to applications other than the | ||
112 | application that created the table. The schema for TEMPORARY tables | ||
113 | is stored in another special table named "sqlite_temp_master". The | ||
114 | "sqlite_temp_master" table is temporary itself. | ||
115 | </p> | ||
116 | |||
117 | <h3>Special commands to sqlite3</h3> | ||
118 | |||
119 | <p> | ||
120 | Most of the time, sqlite3 just reads lines of input and passes them | ||
121 | on to the SQLite library for execution. | ||
122 | But if an input line begins with a dot ("."), then | ||
123 | that line is intercepted and interpreted by the sqlite3 program itself. | ||
124 | These "dot commands" are typically used to change the output format | ||
125 | of queries, or to execute certain prepackaged query statements. | ||
126 | </p> | ||
127 | |||
128 | <p> | ||
129 | For a listing of the available dot commands, you can enter ".help" | ||
130 | at any time. For example: | ||
131 | </p>} | ||
132 | |||
133 | Code { | ||
134 | sqlite> (((.help))) | ||
135 | .bail ON|OFF Stop after hitting an error. Default OFF | ||
136 | .databases List names and files of attached databases | ||
137 | .dump ?TABLE? ... Dump the database in an SQL text format | ||
138 | .echo ON|OFF Turn command echo on or off | ||
139 | .exit Exit this program | ||
140 | .explain ON|OFF Turn output mode suitable for EXPLAIN on or off. | ||
141 | .header(s) ON|OFF Turn display of headers on or off | ||
142 | .help Show this message | ||
143 | .import FILE TABLE Import data from FILE into TABLE | ||
144 | .indices TABLE Show names of all indices on TABLE | ||
145 | .load FILE ?ENTRY? Load an extension library | ||
146 | .mode MODE ?TABLE? Set output mode where MODE is one of: | ||
147 | csv Comma-separated values | ||
148 | column Left-aligned columns. (See .width) | ||
149 | html HTML <table> code | ||
150 | insert SQL insert statements for TABLE | ||
151 | line One value per line | ||
152 | list Values delimited by .separator string | ||
153 | tabs Tab-separated values | ||
154 | tcl TCL list elements | ||
155 | .nullvalue STRING Print STRING in place of NULL values | ||
156 | .output FILENAME Send output to FILENAME | ||
157 | .output stdout Send output to the screen | ||
158 | .prompt MAIN CONTINUE Replace the standard prompts | ||
159 | .quit Exit this program | ||
160 | .read FILENAME Execute SQL in FILENAME | ||
161 | .schema ?TABLE? Show the CREATE statements | ||
162 | .separator STRING Change separator used by output mode and .import | ||
163 | .show Show the current values for various settings | ||
164 | .tables ?PATTERN? List names of tables matching a LIKE pattern | ||
165 | .timeout MS Try opening locked tables for MS milliseconds | ||
166 | .width NUM NUM ... Set column widths for "column" mode | ||
167 | sqlite> | ||
168 | } | ||
169 | |||
170 | puts { | ||
171 | <h3>Changing Output Formats</h3> | ||
172 | |||
173 | <p>The sqlite3 program is able to show the results of a query | ||
174 | in eight different formats: "csv", "column", "html", "insert", | ||
175 | "line", "tabs", and "tcl". | ||
176 | You can use the ".mode" dot command to switch between these output | ||
177 | formats.</p> | ||
178 | |||
179 | <p>The default output mode is "list". In | ||
180 | list mode, each record of a query result is written on one line of | ||
181 | output and each column within that record is separated by a specific | ||
182 | separator string. The default separator is a pipe symbol ("|"). | ||
183 | List mode is especially useful when you are going to send the output | ||
184 | of a query to another program (such as AWK) for additional processing.</p>} | ||
185 | |||
186 | Code { | ||
187 | sqlite> (((.mode list))) | ||
188 | sqlite> (((select * from tbl1;))) | ||
189 | hello|10 | ||
190 | goodbye|20 | ||
191 | sqlite> | ||
192 | } | ||
193 | |||
194 | puts { | ||
195 | <p>You can use the ".separator" dot command to change the separator | ||
196 | for list mode. For example, to change the separator to a comma and | ||
197 | a space, you could do this:</p>} | ||
198 | |||
199 | Code { | ||
200 | sqlite> (((.separator ", "))) | ||
201 | sqlite> (((select * from tbl1;))) | ||
202 | hello, 10 | ||
203 | goodbye, 20 | ||
204 | sqlite> | ||
205 | } | ||
206 | |||
207 | puts { | ||
208 | <p>In "line" mode, each column in a row of the database | ||
209 | is shown on a line by itself. Each line consists of the column | ||
210 | name, an equal sign and the column data. Successive records are | ||
211 | separated by a blank line. Here is an example of line mode | ||
212 | output:</p>} | ||
213 | |||
214 | Code { | ||
215 | sqlite> (((.mode line))) | ||
216 | sqlite> (((select * from tbl1;))) | ||
217 | one = hello | ||
218 | two = 10 | ||
219 | |||
220 | one = goodbye | ||
221 | two = 20 | ||
222 | sqlite> | ||
223 | } | ||
224 | |||
225 | puts { | ||
226 | <p>In column mode, each record is shown on a separate line with the | ||
227 | data aligned in columns. For example:</p>} | ||
228 | |||
229 | Code { | ||
230 | sqlite> (((.mode column))) | ||
231 | sqlite> (((select * from tbl1;))) | ||
232 | one two | ||
233 | ---------- ---------- | ||
234 | hello 10 | ||
235 | goodbye 20 | ||
236 | sqlite> | ||
237 | } | ||
238 | |||
239 | puts { | ||
240 | <p>By default, each column is at least 10 characters wide. | ||
241 | Data that is too wide to fit in a column is truncated. You can | ||
242 | adjust the column widths using the ".width" command. Like this:</p>} | ||
243 | |||
244 | Code { | ||
245 | sqlite> (((.width 12 6))) | ||
246 | sqlite> (((select * from tbl1;))) | ||
247 | one two | ||
248 | ------------ ------ | ||
249 | hello 10 | ||
250 | goodbye 20 | ||
251 | sqlite> | ||
252 | } | ||
253 | |||
254 | puts { | ||
255 | <p>The ".width" command in the example above sets the width of the first | ||
256 | column to 12 and the width of the second column to 6. All other column | ||
257 | widths were unaltered. You can gives as many arguments to ".width" as | ||
258 | necessary to specify the widths of as many columns as are in your | ||
259 | query results.</p> | ||
260 | |||
261 | <p>If you specify a column a width of 0, then the column | ||
262 | width is automatically adjusted to be the maximum of three | ||
263 | numbers: 10, the width of the header, and the width of the | ||
264 | first row of data. This makes the column width self-adjusting. | ||
265 | The default width setting for every column is this | ||
266 | auto-adjusting 0 value.</p> | ||
267 | |||
268 | <p>The column labels that appear on the first two lines of output | ||
269 | can be turned on and off using the ".header" dot command. In the | ||
270 | examples above, the column labels are on. To turn them off you | ||
271 | could do this:</p>} | ||
272 | |||
273 | Code { | ||
274 | sqlite> (((.header off))) | ||
275 | sqlite> (((select * from tbl1;))) | ||
276 | hello 10 | ||
277 | goodbye 20 | ||
278 | sqlite> | ||
279 | } | ||
280 | |||
281 | puts { | ||
282 | <p>Another useful output mode is "insert". In insert mode, the output | ||
283 | is formatted to look like SQL INSERT statements. You can use insert | ||
284 | mode to generate text that can later be used to input data into a | ||
285 | different database.</p> | ||
286 | |||
287 | <p>When specifying insert mode, you have to give an extra argument | ||
288 | which is the name of the table to be inserted into. For example:</p> | ||
289 | } | ||
290 | |||
291 | Code { | ||
292 | sqlite> (((.mode insert new_table))) | ||
293 | sqlite> (((select * from tbl1;))) | ||
294 | INSERT INTO 'new_table' VALUES('hello',10); | ||
295 | INSERT INTO 'new_table' VALUES('goodbye',20); | ||
296 | sqlite> | ||
297 | } | ||
298 | |||
299 | puts { | ||
300 | <p>The last output mode is "html". In this mode, sqlite3 writes | ||
301 | the results of the query as an XHTML table. The beginning | ||
302 | <TABLE> and the ending </TABLE> are not written, but | ||
303 | all of the intervening <TR>s, <TH>s, and <TD>s | ||
304 | are. The html output mode is envisioned as being useful for | ||
305 | CGI.</p> | ||
306 | } | ||
307 | |||
308 | puts { | ||
309 | <h3>Writing results to a file</h3> | ||
310 | |||
311 | <p>By default, sqlite3 sends query results to standard output. You | ||
312 | can change this using the ".output" command. Just put the name of | ||
313 | an output file as an argument to the .output command and all subsequent | ||
314 | query results will be written to that file. Use ".output stdout" to | ||
315 | begin writing to standard output again. For example:</p>} | ||
316 | |||
317 | Code { | ||
318 | sqlite> (((.mode list))) | ||
319 | sqlite> (((.separator |))) | ||
320 | sqlite> (((.output test_file_1.txt))) | ||
321 | sqlite> (((select * from tbl1;))) | ||
322 | sqlite> (((.exit))) | ||
323 | $ (((cat test_file_1.txt))) | ||
324 | hello|10 | ||
325 | goodbye|20 | ||
326 | $ | ||
327 | } | ||
328 | |||
329 | puts { | ||
330 | <h3>Querying the database schema</h3> | ||
331 | |||
332 | <p>The sqlite3 program provides several convenience commands that | ||
333 | are useful for looking at the schema of the database. There is | ||
334 | nothing that these commands do that cannot be done by some other | ||
335 | means. These commands are provided purely as a shortcut.</p> | ||
336 | |||
337 | <p>For example, to see a list of the tables in the database, you | ||
338 | can enter ".tables".</p> | ||
339 | } | ||
340 | |||
341 | Code { | ||
342 | sqlite> (((.tables))) | ||
343 | tbl1 | ||
344 | tbl2 | ||
345 | sqlite> | ||
346 | } | ||
347 | |||
348 | puts { | ||
349 | <p>The ".tables" command is similar to setting list mode then | ||
350 | executing the following query:</p> | ||
351 | |||
352 | <blockquote><pre> | ||
353 | SELECT name FROM sqlite_master | ||
354 | WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' | ||
355 | UNION ALL | ||
356 | SELECT name FROM sqlite_temp_master | ||
357 | WHERE type IN ('table','view') | ||
358 | ORDER BY 1 | ||
359 | </pre></blockquote> | ||
360 | |||
361 | <p>In fact, if you look at the source code to the sqlite3 program | ||
362 | (found in the source tree in the file src/shell.c) you'll find | ||
363 | exactly the above query.</p> | ||
364 | |||
365 | <p>The ".indices" command works in a similar way to list all of | ||
366 | the indices for a particular table. The ".indices" command takes | ||
367 | a single argument which is the name of the table for which the | ||
368 | indices are desired. Last, but not least, is the ".schema" command. | ||
369 | With no arguments, the ".schema" command shows the original CREATE TABLE | ||
370 | and CREATE INDEX statements that were used to build the current database. | ||
371 | If you give the name of a table to ".schema", it shows the original | ||
372 | CREATE statement used to make that table and all if its indices. | ||
373 | We have:</p>} | ||
374 | |||
375 | Code { | ||
376 | sqlite> (((.schema))) | ||
377 | create table tbl1(one varchar(10), two smallint) | ||
378 | CREATE TABLE tbl2 ( | ||
379 | f1 varchar(30) primary key, | ||
380 | f2 text, | ||
381 | f3 real | ||
382 | ) | ||
383 | sqlite> (((.schema tbl2))) | ||
384 | CREATE TABLE tbl2 ( | ||
385 | f1 varchar(30) primary key, | ||
386 | f2 text, | ||
387 | f3 real | ||
388 | ) | ||
389 | sqlite> | ||
390 | } | ||
391 | |||
392 | puts { | ||
393 | <p>The ".schema" command accomplishes the same thing as setting | ||
394 | list mode, then entering the following query:</p> | ||
395 | |||
396 | <blockquote><pre> | ||
397 | SELECT sql FROM | ||
398 | (SELECT * FROM sqlite_master UNION ALL | ||
399 | SELECT * FROM sqlite_temp_master) | ||
400 | WHERE type!='meta' | ||
401 | ORDER BY tbl_name, type DESC, name | ||
402 | </pre></blockquote> | ||
403 | |||
404 | <p>Or, if you give an argument to ".schema" because you only | ||
405 | want the schema for a single table, the query looks like this:</p> | ||
406 | |||
407 | <blockquote><pre> | ||
408 | SELECT sql FROM | ||
409 | (SELECT * FROM sqlite_master UNION ALL | ||
410 | SELECT * FROM sqlite_temp_master) | ||
411 | WHERE type!='meta' AND sql NOT NULL AND name NOT LIKE 'sqlite_%' | ||
412 | ORDER BY substr(type,2,1), name | ||
413 | </pre></blockquote> | ||
414 | |||
415 | <p> | ||
416 | You can supply an argument to the .schema command. If you do, the | ||
417 | query looks like this: | ||
418 | </p> | ||
419 | |||
420 | <blockquote><pre> | ||
421 | SELECT sql FROM | ||
422 | (SELECT * FROM sqlite_master UNION ALL | ||
423 | SELECT * FROM sqlite_temp_master) | ||
424 | WHERE tbl_name LIKE '%s' | ||
425 | AND type!='meta' AND sql NOT NULL AND name NOT LIKE 'sqlite_%' | ||
426 | ORDER BY substr(type,2,1), name | ||
427 | </pre></blockquote> | ||
428 | |||
429 | <p>The "%s" in the query is replace by your argument. This allows you | ||
430 | to view the schema for some subset of the database.</p> | ||
431 | } | ||
432 | |||
433 | Code { | ||
434 | sqlite> (((.schema %abc%))) | ||
435 | } | ||
436 | |||
437 | puts { | ||
438 | <p> | ||
439 | Along these same lines, | ||
440 | the ".table" command also accepts a pattern as its first argument. | ||
441 | If you give an argument to the .table command, a "%" is both | ||
442 | appended and prepended and a LIKE clause is added to the query. | ||
443 | This allows you to list only those tables that match a particular | ||
444 | pattern.</p> | ||
445 | |||
446 | <p>The ".databases" command shows a list of all databases open in | ||
447 | the current connection. There will always be at least 2. The first | ||
448 | one is "main", the original database opened. The second is "temp", | ||
449 | the database used for temporary tables. There may be additional | ||
450 | databases listed for databases attached using the ATTACH statement. | ||
451 | The first output column is the name the database is attached with, | ||
452 | and the second column is the filename of the external file.</p>} | ||
453 | |||
454 | Code { | ||
455 | sqlite> (((.databases))) | ||
456 | } | ||
457 | |||
458 | puts { | ||
459 | <h3>Converting An Entire Database To An ASCII Text File</h3> | ||
460 | |||
461 | <p>Use the ".dump" command to convert the entire contents of a | ||
462 | database into a single ASCII text file. This file can be converted | ||
463 | back into a database by piping it back into <b>sqlite3</b>.</p> | ||
464 | |||
465 | <p>A good way to make an archival copy of a database is this:</p> | ||
466 | } | ||
467 | |||
468 | Code { | ||
469 | $ (((echo '.dump' | sqlite3 ex1 | gzip -c >ex1.dump.gz))) | ||
470 | } | ||
471 | |||
472 | puts { | ||
473 | <p>This generates a file named <b>ex1.dump.gz</b> that contains everything | ||
474 | you need to reconstruct the database at a later time, or on another | ||
475 | machine. To reconstruct the database, just type:</p> | ||
476 | } | ||
477 | |||
478 | Code { | ||
479 | $ (((zcat ex1.dump.gz | sqlite3 ex2))) | ||
480 | } | ||
481 | |||
482 | puts { | ||
483 | <p>The text format is pure SQL so you | ||
484 | can also use the .dump command to export an SQLite database | ||
485 | into other popular SQL database engines. Like this:</p> | ||
486 | } | ||
487 | |||
488 | Code { | ||
489 | $ (((createdb ex2))) | ||
490 | $ (((sqlite3 ex1 .dump | psql ex2))) | ||
491 | } | ||
492 | |||
493 | puts { | ||
494 | <h3>Other Dot Commands</h3> | ||
495 | |||
496 | <p>The ".explain" dot command can be used to set the output mode | ||
497 | to "column" and to set the column widths to values that are reasonable | ||
498 | for looking at the output of an EXPLAIN command. The EXPLAIN command | ||
499 | is an SQLite-specific SQL extension that is useful for debugging. If any | ||
500 | regular SQL is prefaced by EXPLAIN, then the SQL command is parsed and | ||
501 | analyzed but is not executed. Instead, the sequence of virtual machine | ||
502 | instructions that would have been used to execute the SQL command are | ||
503 | returned like a query result. For example:</p>} | ||
504 | |||
505 | Code { | ||
506 | sqlite> (((.explain))) | ||
507 | sqlite> (((explain delete from tbl1 where two<20;))) | ||
508 | addr opcode p1 p2 p3 | ||
509 | ---- ------------ ----- ----- ------------------------------------- | ||
510 | 0 ListOpen 0 0 | ||
511 | 1 Open 0 1 tbl1 | ||
512 | 2 Next 0 9 | ||
513 | 3 Field 0 1 | ||
514 | 4 Integer 20 0 | ||
515 | 5 Ge 0 2 | ||
516 | 6 Key 0 0 | ||
517 | 7 ListWrite 0 0 | ||
518 | 8 Goto 0 2 | ||
519 | 9 Noop 0 0 | ||
520 | 10 ListRewind 0 0 | ||
521 | 11 ListRead 0 14 | ||
522 | 12 Delete 0 0 | ||
523 | 13 Goto 0 11 | ||
524 | 14 ListClose 0 0 | ||
525 | } | ||
526 | |||
527 | puts { | ||
528 | |||
529 | <p>The ".timeout" command sets the amount of time that the <b>sqlite3</b> | ||
530 | program will wait for locks to clear on files it is trying to access | ||
531 | before returning an error. The default value of the timeout is zero so | ||
532 | that an error is returned immediately if any needed database table or | ||
533 | index is locked.</p> | ||
534 | |||
535 | <p>And finally, we mention the ".exit" command which causes the | ||
536 | sqlite3 program to exit.</p> | ||
537 | |||
538 | <h3>Using sqlite3 in a shell script</h3> | ||
539 | |||
540 | <p> | ||
541 | One way to use sqlite3 in a shell script is to use "echo" or | ||
542 | "cat" to generate a sequence of commands in a file, then invoke sqlite3 | ||
543 | while redirecting input from the generated command file. This | ||
544 | works fine and is appropriate in many circumstances. But as | ||
545 | an added convenience, sqlite3 allows a single SQL command to be | ||
546 | entered on the command line as a second argument after the | ||
547 | database name. When the sqlite3 program is launched with two | ||
548 | arguments, the second argument is passed to the SQLite library | ||
549 | for processing, the query results are printed on standard output | ||
550 | in list mode, and the program exits. This mechanism is designed | ||
551 | to make sqlite3 easy to use in conjunction with programs like | ||
552 | "awk". For example:</p>} | ||
553 | |||
554 | Code { | ||
555 | $ (((sqlite3 ex1 'select * from tbl1' |))) | ||
556 | > ((( awk '{printf "<tr><td>%s<td>%s\n",$1,$2 }'))) | ||
557 | <tr><td>hello<td>10 | ||
558 | <tr><td>goodbye<td>20 | ||
559 | $ | ||
560 | } | ||
561 | |||
562 | puts { | ||
563 | <h3>Ending shell commands</h3> | ||
564 | |||
565 | <p> | ||
566 | SQLite commands are normally terminated by a semicolon. In the shell | ||
567 | you can also use the word "GO" (case-insensitive) or a slash character | ||
568 | "/" on a line by itself to end a command. These are used by SQL Server | ||
569 | and Oracle, respectively. These won't work in <b>sqlite3_exec()</b>, | ||
570 | because the shell translates these into a semicolon before passing them | ||
571 | to that function.</p> | ||
572 | } | ||
573 | |||
574 | puts { | ||
575 | <h3>Compiling the sqlite3 program from sources</h3> | ||
576 | |||
577 | <p> | ||
578 | The sqlite3 program is built automatically when you compile the | ||
579 | SQLite library. Just get a copy of the source tree, run | ||
580 | "configure" and then "make".</p> | ||
581 | } | ||
582 | footer $rcsid | ||