Florent THIERY <[EMAIL PROTECTED]> wrote:
On 11/13/06, Igor Tandetnik <[EMAIL PROTECTED]>
wrote:
Florent THIERY
<[EMAIL PROTECTED]>
wrote:
Some files have optional fields, so what i'd like to do is, whenever
such a file is scanned and parsed, i want my software to
- check first if the column already exists; that, i have no idea how
to achieve it
PRAGMA table_info: http://sqlite.org/pragma.html#schema
I don't quite get how to use these commands to do a trivial presence
test
PRAGMA table_info allows one to enumerate all the columns in a table. It
should be trivial to check whether a particular column appears in this
enumeration.
If i query something like:
" select * from jpgs where "/sof/field1/nb_comp" != NULL "
What result would i get if the column doesn't exist yet?
If the column "/sof/field1/nb_comp" does not exist yet, the query will
fail to compile (sqlite3_prepare will fail).
In any case, I don't quite see how this is related to the issue of
determining the existence of a column.
from http://www.sqlite.org/lang_altertable.html
" After ADD COLUMN has been run on a database, that database will not
be readable by SQLite version 3.1.3 and earlier until the database is
VACUUM<http://www.sqlite.org/lang_vacuum.html>ed.
"
Is it mandatory then?
Apparently yes, if you want the database to be readable by SQLite
version 3.1.3 and earlier. VACUUM works basically by creating a new
table with the same structure as the old one, copying all the data over,
and finally dropping the old table. I guess ALTER TABLE is implemented
with some data structure (a linked list of columns or something) that
older SQLite versions don't understand. By completely rebuilding a table
from scratch, VACUUM also removes this data structure.
And I was wrong: you can vacuum an individual table, and even an
individual index.
Igor Tandetnik
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------