Developer Reference : Data Access Methods : SQL Engine Reference : SQL Syntax Reference : ALTER (rename)
 
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 Zen versions before PSQL v9:
Stored procedures
Triggers
Views
In these earlier releases, the system table index on the name of these objects was created as not modifiable. The indexes for these objects became modifiable in PSQL v9.
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. 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. Be sure that all objects with a dependency on the previous name are revised as needed. For example, if a trigger refers to a table named t1 and you rename table t1 to t5, the trigger now contains invalid SQL that will fail.
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 isEligible in database international.
ALTER PROCEDURE RENAME international.checkstatus TO isEligible
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