LMHmedchem <[email protected]> wrote:
> It looks like my insert syntax should be,
> INSERT INTO Structure
> VALUES(null,'phosphoserine','phosphoserine.mol',185073,856147,73543,25338,'C3H8NO6P',185.073);
>
> where using null for id invokes AUTOINCREMENT. Is this the right syntax for
> sqlite?
Yes, this would work. Another possibility is omitting the value for ID entirely:
insert into Structure(name, filePath, ...) values
('phosphoserine','phosphoserine.mol', ...);
I have also seen versions of insert where the Table fields are
> defined and look like,
>
> INSERT INTO Structure(id, name, filePath, iH1, iH2, iH3, iH4, formula, fw)
> VALUES(null,'phosphoserine','phosphoserine.mol',185073,856147,73543,25338,'C3H8NO6P',185.073);
This works, too.
> Would I still use null here for the id, or do I not have this right? Is
> there some reason for preferring one version over the other if both are
> valid?
It's all the same to SQLite. For a programmer, a query that explicitly lists
the columns might be easier to read - you don't need to consult the table
definition to figure out which value goes into which field.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users