On Tue, Nov 30, 2010 at 10:40:52AM -0600, john darnell scratched on the wall:
> I know this is a fundamental question, but in the book I'm using to
> learn SQLite, there is no reference that I can find for what one needs
> to do to create a database. I thought that simply using a CREATE
> statement with a database name included might do the trick, but alas
> it does not.
From code, you use sqlite3_open_v2( ). See the docs for specifics:
http://sqlite.org/c3ref/open.html
From the shell, you just access a non-existent file.
> I went to the SQLite website and under the "SQLite in 5 minutes" page it says
> to simply do this (after downloading the appropriate files, which I did) at
> the dos prompt:
>
> SQLite3 test.db
>
> When I tried it, I received this back:
>
> SQLite version 3.7.3
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite>
>
> I quit out of the SQLite shell and looked for test.db and did not find it.
>
> So my question remains. How do I create a database?
The SQLite library uses lazy file creation. There are a number of
configuration parameters that become fixed once the database header is
written to disk. As such, the actual file creation is delayed until
it *must* be written. This gives you a chance to issue PRAGMA commands
and setup the proper configuration after the database is open, but
before the header is written.
To force SQLite to actually write the database file to disk just
issue a CREATE TABLE statement:
CREATE TABLE t ( i );
-j
--
Jay A. Kreibich < J A Y @ K R E I B I.C H >
"Intelligence is like underwear: it is important that you have it,
but showing it to the wrong people has the tendency to make them
feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users