ALTER (rename)
The ALTER (rename) statement allows you to change the name of indexes, user-defined functions, stored procedures, tables, triggers, or views.
Syntax
ALTER object-type RENAME qualified-object-name TO new-object-name
 
object-type ::= INDEX
| FUNCTION
| PROCEDURE
| TABLE
| TRIGGER
| VIEW
 
qualified-object-name ::= database-name.table-name.object-name
| database-name.object-name
| table-name.object-name
| object-name
 
database-name, table-name, object-name, new-object-name ::= user-defined name
Remarks
You cannot rename the following objects if they were created with a version of Pervasive PSQL prior to Pervasive PSQL v9:
In releases prior to Pervasive PSQL v9, the system table index on the name of these objects was created as not modifiable. The indexes for these objects are modifiable with release Pervasive PSQL v9 or greater.
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).
You can also use the psp_rename system stored procedure to rename objects.
Examples
The following statement alters the name of index “suplid” to “vendor_id” in the database to which your session is currently connected. The index applies to table region5.
ALTER INDEX RENAME region5.suplid TO vendor_id
The following statement alters the name of the user-defined function “calbrned” to “caloriesburned” in database foodforlife.
ALTER FUNCTION RENAME foodforlife.calbrned TO caloriesburned
The following statement alters the name of stored procedure “checkstatus” to “eligibility” in database international.
ALTER PROCEDURE RENAME international.checkstatus TO eligibility
The following statement alters the name of table “payouts” to “accts_payable” in the database to which your session is currently connected.
ALTER TABLE RENAME payouts TO accts_payable
The following statement alters the name of trigger “testtrig3” to “new_customer” in table domestic and database electronics.
ALTER TRIGGER RENAME electronics.domestic.testtrig3 TO new_customer
The following statement alters the name of view “suplrcds” to “vendor_codes” in the database to which your session is currently connected.
ALTER VIEW RENAME suplrcds TO vendor_codes
See Also
CREATE FUNCTION
CREATE PROCEDURE
CREATE TABLE
CREATE TRIGGER
CREATE VIEW
psp_rename