I was thinking a bit on your question...let's make some terminology clear.

Database file -- a user file on your hard disk that may contain tables
Table -- a user table entry which may contain records
Records -- a specific user data record in a table containing fields of user data

#1 Create "a database file" as you asked -- when you first open a database file 
with the shell or the default C API it will automatically create it.  It does 
not need to be "pre created".  For the C API....there are options when opening 
the database file which can mandate that it already exist.
Example with the shell.
sqlite3 myfile.db
sqlite> .quit
Database file "myfile.db" now exists on your system but has no tables in it 
(ergo no records).

#2 Create a table -- note that myfile.db does not need to exist for this 
example:
sqlite3 myfile.db
sqlite> create table mytable(mydata);
sqlite> .quit
Database file "myfile.db" now exists and has one table with no data

#3 Create a record -- Now we'll re-use the databasefile that already has 
"mytable" in it.
sqlite3 myfile.db
sqlite> .dump mytable
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE mytable(mydata);
COMMIT;
sqlite> insert into mytable values('value1');

sqlite> select * from mytable;

value1

sqlite> .quit

Your database file "myfile.db" now has one table with on record in it.


Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems



From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of McSparin, Brett E [brett.e.mcspa...@boeing.com]
Sent: Thursday, May 10, 2012 3:26 PM
To: sqlite-users@sqlite.org
Subject: EXT :[sqlite] intial database creation


How does one go about creating a database initially in SQLite?
Do you create a schema file for it to read or similar?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to