The ALTER (rename)
statement allows you to change the name of indexes, user-defined functions, stored procedures, tables, triggers, or views.
You can use database-name to qualify any
object-type. However, if it is used to qualify an INDEX or TRIGGER object, you must also include
table-name. You can use
table-name to qualify only the objects INDEX and TRIGGER.
The ALTER statement can rename an object in a database whether or not ODBC is currently connected to that database. You must use database-name to qualify
object-type if the object resides in a database to which your session is
not currently connected. The renamed object occurs in the same database as
database-name.
If you omit database-name as a qualifier, the database to which your session is currently connected is used to identify and rename the objects.
Note that new-object-name never uses a database name as a qualifier. The context of the new name always matches the context of the original name.
Note: The database engine does not check dependencies for renamed objects. If you rename an object, ensure that all other objects with a dependency on the previous (changed from) name are revised appropriately. For example, suppose that a trigger refers a table named t1. If you rename table t1 to t5, the trigger contains invalid SQL that will not execute correctly.
In addition, if you rename a stored procedure, user-defined function, or trigger, the original definition for that object in the DDF is not changed. For example, suppose that you create stored procedure “proc1,” then later rename it to “proc2.” The definition stored in Xp$Misc in the procedures system table still shows “proc1.” This has no effect on the functioning of the object (in this case a stored procedure). The database engine uses the values in Xp$Name and Xp$Id to identify the stored procedure (and similar fields in the system tables for functions and triggers).