Am 02.03.2012 13:59, schrieb Jay A. Kreibich:
On Fri, Mar 02, 2012 at 10:44:20AM +0100, Christoph P.U. Kukulies scratched on 
the wall:
When defining a column TEXT PRIMARY KEY (is that possible on TEXT?),
would this imply uniqueness?
   Kind of.  It implies uniqueness in the SQL sense, which does not
   include NULLs (remember, NULL != NULL).  The SQL term "PRIMARY KEY"
   should imply both "UNIQUE" and "NOT NULL", but there is a long
   standing issue in SQLite that allows NULLs in non-integer PRIMARY
   KEY columns.  This allows "duplicate" NULL entries in a PK column.

   Normally this isn't an issue, as you shouldn't have NULLs in a
   single-column PK anyways.

Or would I have to write something like TEXT PRIMARY KEY UNIQUE ?
   No, but to be extra safe you should write "TEXT PRIMARY KEY NOT NULL."

    -j

Thanks. And thanks to others for contributing.

My logic is the following: When I'm inserting files and their respective contents into the database, I have to decide, whether a file is already there. I'm building a unique ID made up from the basename, md5sum and size of the file. This results
as a TEXT PRIMARY KEY (e.g. filename_md5sum_size).
Can I use (I'm using System.Data.SQLite) a try clause to find out whether the entry is
already there?

I think this can be faster than asking the database by an SQL statement, whether
the KEY is already there.

--
Christoph

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

Reply via email to