Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming SQLite Tables/Columns/Rows after indices have been created

If I rename SQLite Tables/Columns/Rows after indices have been created, will the old indices still be functional?

Thanks!

like image 347
joshim5 Avatar asked Jul 31 '11 17:07

joshim5


1 Answers

If you're using ALTER TABLE with RENAME TO to rename a table, then as described on this page (from the sqlite docs) the indices will still work:

The ALTER TABLE command in SQLite allows the user to rename a table [...] If the table being renamed has triggers or indices, then these remain attached to the table after it has been renamed.

But note there's no renaming of columns allowed. This is one of the SQL features not implemented by sqlite:

Only the RENAME TABLE and ADD COLUMN variants of the ALTER TABLE command are supported. Other kinds of ALTER TABLE operations such as DROP COLUMN, ALTER COLUMN, ADD CONSTRAINT, and so forth are omitted.

Rows don't have names (except in the sense of having a PK) so there's not really a way of renaming them.

like image 112
Richard Inglis Avatar answered Sep 22 '22 04:09

Richard Inglis