[sqlite] UNIQUE constraint

2011-10-23 Thread Fabian
I have a column with a normal INDEX, and I would like to turn it into an UNIQUE index, but I'm a bit worried about the performance implications for inserts. Can someone give some insight into how UNIQUE is implemented in SQLite, does it create extra tables compared to a normale index, are there

Re: [sqlite] UNIQUE constraint

2011-10-23 Thread Igor Tandetnik
Fabian fabianpi...@gmail.com wrote: I have a column with a normal INDEX, and I would like to turn it into an UNIQUE index, but I'm a bit worried about the performance implications for inserts. Can someone give some insight into how UNIQUE is implemented in SQLite, does it create extra tables

Re: [sqlite] UNIQUE constraint

2011-10-23 Thread Fabian
No, a UNIQUE index and a regular index are implemented the exact same way. It's just that, at INSERT and UPDATE time, after finding a proper place to insert the new value, an additional check is made that the place isn't already occupied. So the only overhead for UNIQUE is that extra

Re: [sqlite] UNIQUE constraint

2011-10-23 Thread Simon Slavin
On 23 Oct 2011, at 3:49pm, Fabian wrote: So the only overhead for UNIQUE is that extra check? [snip] Right. When doing an INSERT or UPDATE, it checks to see whether the value it's trying to add to the index already exists in the index. If it does, the result is an error. There is no

Re: [sqlite] UNIQUE constraint

2011-10-23 Thread Fabian
2011/10/23 Simon Slavin slav...@bigfraud.org In this example, the indexed column is a text column. The text fields could have been very long, and checking long text fields for uniqueness can involve comparing every byte. Nevertheless, I do not understand the results you quoted. I wonder

Re: [sqlite] UNIQUE constraint on column

2007-02-04 Thread drh
A. Pagaltzis [EMAIL PROTECTED] wrote: It's a pity that INSERT OR IGNORE (apparently?) does not set last_insert_id properly regardless of outcome, Consider this case: CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE, z UNIQUE); INSERT INTO t1 VALUES(1,'a','b'); INSERT INTO t1

Re: [sqlite] UNIQUE constraint on column

2007-02-01 Thread Shane Harrelson
Shane Harrelson [EMAIL PROTECTED] wrote: I have two tables, an Objects table with a foreign key into a second Strings table which is composed of unique values. It is a many to one relationship, that is, several Objects may reference the same String. When an Object is added, its associated

[sqlite] UNIQUE constraint on column

2007-01-31 Thread Shane Harrelson
when i try to insert a row into a table that has a UNIQUE constraint on a column, and I get the SQLITE_CONSTRAINT result code because i'm inserting a duplicate value, is there anyway to determine the rowid of the conflict? looking at the internals of the VDBE, i found that the rowid of the

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread drh
Shane Harrelson [EMAIL PROTECTED] wrote: when i try to insert a row into a table that has a UNIQUE constraint on a column, and I get the SQLITE_CONSTRAINT result code because i'm inserting a duplicate value, is there anyway to determine the rowid of the conflict? looking at the internals of

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread Shane Harrelson
On 1/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Shane Harrelson [EMAIL PROTECTED] wrote: when i try to insert a row into a table that has a UNIQUE constraint on a column, and I get the SQLITE_CONSTRAINT result code because i'm inserting a duplicate value, is there anyway to determine

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread Dennis Cote
Shane Harrelson wrote: On 1/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The official way to find the conflicting entry is to do a query. SELECT rowid FROM table WHERE uniquecolumn=?; Thank you for the reply. I assumed this was most likely the case, and as I said in my original

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread Kees Nuyt
Hi Shane, On Wed, 31 Jan 2007 09:29:24 -0500, you wrote: On 1/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Shane Harrelson [EMAIL PROTECTED] wrote: when i try to insert a row into a table that has a UNIQUE constraint on a column, and I get the SQLITE_CONSTRAINT result code because i'm

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread Shane Harrelson
On 1/31/07, Dennis Cote [EMAIL PROTECTED] wrote: Shane Harrelson wrote: On 1/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The official way to find the conflicting entry is to do a query. SELECT rowid FROM table WHERE uniquecolumn=?; Thank you for the reply. I assumed this was

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread Nicolas Williams
On Wed, Jan 31, 2007 at 05:23:29PM -0500, Shane Harrelson wrote: I have two tables, an Objects table with a foreign key into a second Strings table which is composed of unique values. It is a many to one relationship, that is, several Objects may reference the same String. When an Object

Re: [sqlite] UNIQUE constraint on column

2007-01-31 Thread drh
Shane Harrelson [EMAIL PROTECTED] wrote: I have two tables, an Objects table with a foreign key into a second Strings table which is composed of unique values. It is a many to one relationship, that is, several Objects may reference the same String. When an Object is added, its associated

[sqlite] UNIQUE constraint on column

2007-01-30 Thread Shane Harrelson
when i try to insert a row into a table that has a UNIQUE constraint on a column, and I get the SQLITE_CONSTRAINT result code because i'm inserting a duplicate value, is there anyway to determine the rowid of the conflict? looking at the internals of the VDBE, i found that the rowid of the

Re: [sqlite] UNIQUE Constraint but case sensitive

2005-06-24 Thread Dan Kennedy
Hi, I need to create a unique constraint on a column of type varchar, but it is not case sensitive by default. Does any one know how to make a unique constraint case sensitive? CREATE TABLE abc(a UNIQUE COLLATE NOCASE); Bear in mind that the NOCASE collation sequence only knows about

[sqlite] UNIQUE Constraint but case sensitive

2005-06-23 Thread Ajay
Hi, I need to create a unique constraint on a column of type varchar, but it is not case sensitive by default. Does any one know how to make a unique constraint case sensitive? Thanks and best regards, Ajay Sonawane