On Apr 8, 2012, at 12:25 AM, Josh Gibbs wrote:

> SQLite: INSERT OR IGNORE INTO test_table VALUES('prop','val');
> Postgres: INSERT INTO test_table SELECT 'prop','val' WHERE NOT EXISTS (SELECT 
> 1 FROM test_table WHERE property='prop');

My 2¢…

The first variant, insert or ignore, is arguably more idiomatic to SQLite, and 
theoretically requires less work.

As the DML will have to check the primary key constraint either ways, best to 
let SQLite do it only once. Instead of twice, as in your second variant: once 
for exists, and once for insert. 

Tangentially related, some RDBMS provide support for DML error logging, which 
comes handy at time:

http://www.oracle-base.com/articles/10g/DmlErrorLogging_10gR2.php


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to