![]() |
|
Use the RENAME TABLE statement to change the name of a table.
You can rename a table if any of the following statements are true:
You cannot change the table owner by renaming the table. You can use the owner. convention in the old name of the table, but an error occurs during compilation if you try to use the owner. convention in the new name of the table.
If you are using Enterprise Decision Server, you cannot rename a table that contains a dependent GK index.
In an ANSI-compliant database, you must use the owner. convention in the old name of the table if you are referring to a table that you do not own.
You cannot use the RENAME TABLE statement to move a table from the current database to another database or to move a table from another database to the current database. The table that you want to rename must reside in the current database. The renamed table that results from the statement remains in the current database.
If a view references the table that was renamed, and the view resides in the same database as the table, the database server updates the text of the view in the sysviews system catalog table to reflect the new table name. For further information on the sysviews system catalog table, see the Informix Guide to SQL: Reference.
If you rename a table that has a trigger, it produces the following results:
When the trigger executes, the database server returns an error if it encounters a table name for which no table exists.
The following example reorganizes the items table. The intent is to move the quantity column from the fifth position to the third. The example illustrates the following steps:
The following example uses the RENAME TABLE statement as the last step:
Related statements: ALTER TABLE, CREATE TABLE, DROP TABLE, and RENAME COLUMN.