On Mon, Aug 12, 2013 at 4:34 PM, Scott Hess <sh...@google.com> wrote:

> I had been attempting to write some code like this:
>
> CREATE TABLE t (x);
> CREATE INDEX t_x ON t(x);
> -- bunch of operations over a long period.
> -- now we want to run an expiration pass:
> BEGIN;
> ALTER TABLE t RENAME TO t_old;
> CREATE TABLE t (x);
> CREATE INDEX t_x ON t(x);  -- (*)
> -- Bunch of code like:
> INSERT INTO t (x) SELECT x FROM t_old WHERE (complicated);
> DROP TABLE t_old;
> COMMIT;
>
> Unfortunately, at (*) this throws:
>   Error: index t_x already exists
>
> Is there something really obvious I'm missing, here?
>

Does the index really have to be named "t_x".  Can you make up some
nonsense name containing a lot of randomness - a name that is very unlikely
to exist in the current schema?  Like say:
"t_x_b27289506cc846621a648dc9e95bba85".

SQLite doesn't care what the name of the index is, unless you use the
"INDEXED BY" clause on a query.  Are you doing that?


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

Reply via email to