David, that's a useful reminder than trigger and index NAMES are not
automatically changed when the referenced table is renamed.

Maybe another is that while index and trigger creation statements
automatically have the referenced table name changed (at least the
non-action trigger commands) by ALTER TABLE renames, the FOREIGN KEY table
references are changed ONLY if foreign keys are turned on at the time of
the ALTER TABLE.  (PRAGMA foreign_keys=ON;)

From:  http://sqlite.org/lang_altertable.html

===============================================

... This command cannot be used to move a table between attached databases,
only to rename a table within the same database.

If the table being renamed has triggers or indices, then these remain
attached to the table after it has been renamed. However, if there are any
view definitions, or statements executed by triggers that refer to the
table being renamed, these are not automatically modified to use the new
table name. If this is required, the triggers or view definitions must be
dropped and recreated to use the new table name by hand.

*Important Note:* The 'ALTER TABLE ... RENAME TO ...' command does not
update action statements within triggers or SELECT statements within views.
If the table being renamed is referenced from within triggers or views,
then those triggers and views must be dropped and recreated separately by
the application.

If foreign key constraints <http://sqlite.org/foreignkeys.html> are enabled
<http://sqlite.org/pragma.html#pragma_foreign_keys> when a table is
renamed, then any REFERENCES clauses
<http://sqlite.org/syntax/foreign-key-clause.html> in any table (either the
table being renamed or some other table) that refer to the table being
renamed are modified to refer to the renamed table by its new name.
===============================================
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to