This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
howtos:sqliteutilitynotes [2007/01/20 21:36] – created xuesheng | howtos:sqliteutilitynotes [2007/01/23 00:26] – texasfett | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== sqlite: a command-line | + | ====== sqlite |
+ | a command-line | ||
==== Introduction ==== | ==== Introduction ==== | ||
Line 9: | Line 11: | ||
The SQLite web site only seems to document the **sqlite3** utility which is not compatible with the SQLite databases created by POPFile. The information on this wiki page is based upon an old page (last modified on 2004/05/31 15:06:30) from the SQLite web site which documented the features supported by the **sqlite** command-line utility. | The SQLite web site only seems to document the **sqlite3** utility which is not compatible with the SQLite databases created by POPFile. The information on this wiki page is based upon an old page (last modified on 2004/05/31 15:06:30) from the SQLite web site which documented the features supported by the **sqlite** command-line utility. | ||
- | The SQLite web site still has some [[http:// | + | The SQLite web site still has some [[http:// |
==== Getting Started ==== | ==== Getting Started ==== | ||
Line 225: | Line 226: | ||
$ | $ | ||
</ | </ | ||
+ | |||
Line 256: | Line 258: | ||
< | < | ||
sqlite> .schema | sqlite> .schema | ||
- | create table tbl1(one varchar(1), two smallint); | + | create table tbl1(one varchar(10), two smallint) |
CREATE TABLE tbl2 ( | CREATE TABLE tbl2 ( | ||
- | f1 varchar(30) primary key, | + | |
- | f2 text, | + | f2 text, |
- | f3 real | + | f3 real |
- | ); | + | ) |
sqlite> .schema tbl2 | sqlite> .schema tbl2 | ||
CREATE TABLE tbl2 ( | CREATE TABLE tbl2 ( | ||
- | f1 varchar(30) primary key, | + | |
- | f2 text, | + | f2 text, |
- | f3 real | + | f3 real |
- | ); | + | ) |
sqlite> | sqlite> | ||
</ | </ | ||
Line 300: | Line 302: | ||
< | < | ||
+ | |||
+ | |||
+ | |||
Line 305: | Line 310: | ||
==== Converting An Entire Database To An ASCII Text File ==== | ==== Converting An Entire Database To An ASCII Text File ==== | ||
- | Use the " | + | Use the " |
A good way to make an archival copy of a database is this: | A good way to make an archival copy of a database is this: | ||
- | <code bash> | + | <code bash>$ echo ' |
This generates a file named **ex1.dump.gz** that contains everything you need to reconstruct the database at a later time, or on another machine. To reconstruct the database, just type: | This generates a file named **ex1.dump.gz** that contains everything you need to reconstruct the database at a later time, or on another machine. To reconstruct the database, just type: | ||
Line 315: | Line 320: | ||
<code bash>$ zcat ex1.dump.gz | sqlite ex2</ | <code bash>$ zcat ex1.dump.gz | sqlite ex2</ | ||
- | The text format used is the same as used by PostgreSQL, so you can also use the .dump command to export an SQLite database into a PostgreSQL database. Like this: | + | The text format used is the same as used by < |
<code bash> | <code bash> | ||
Line 322: | Line 327: | ||
</ | </ | ||
- | You can almost (but not quite) go the other way and export a PostgreSQL database into SQLite using the **pg_dump** utility. Unfortunately, | + | You can almost (but not quite) go the other way and export a < |
<code bash> | <code bash> |
Should you find anything in the documentation that is incomplete, unclear, outdated or just plain wrong, please let us know and leave a note in the Documentation Forum.