Oracle8i SQL Reference
Release 2 (8.1.6)

A76989-01

Library

Product

Contents

Index

Prev Up Next

SQL Statements (continued), 2 of 6


RENAME

Syntax


Purpose

To rename a table, view, sequence, or private synonym for a table, view, or sequence.

Do not use this statement to rename public synonyms. Instead, drop the public synonym and then create another public synonym with the new name.

See Also:

"DROP SYNONYM" and "CREATE SYNONYM"

Prerequisites

The object must be in your own schema.

Keywords and Parameters

old 

is the name of an existing table, view, sequence, or private synonym.  

new 

is the new name to be given to the existing object. The new name must not already be used by another schema object in the same namespace and must follow the rules for naming schema objects defined in the section "Schema Object Naming Rules"

Example

To change the name of table DEPT to EMP_DEPT, issue the following statement:

RENAME dept TO emp_dept;

You cannot use this statement directly to rename columns. However, you can rename a column using this statement together with the CREATE TABLE statement with AS subquery. The following statements re-create the table STATIC, renaming a column from OLDNAME to NEWNAME:

CREATE TABLE temporary (newname, col2, col3) 
    AS SELECT oldname, col2, col3 FROM static; 

DROP TABLE static; 

RENAME temporary TO static; 

Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index