Views:
SQL> create view v1 as select * from dual;
View created.
SQL> rename v1 to v2;
Table renamed.
Tables:
SQL> create table t1 as select * from dual;
Table created.
SQL> rename t1 to t2;
Table renamed.
Sequences:
SQL> create sequence s1;
Sequence created.
SQL> rename s1 to s2;
Table renamed.
Synonyms:
SQL> create synonym syn1 for dual;
Synonym created.
SQL> rename syn1 to syn2;
Table renamed.
Constraints :
SQL> create table t(x number not null);
Table created.
SQL> select constraint_name
2 from user_constraints
3 where table_name='T';
CONSTRAINT_NAME
------------------------------
SYS_C0018686
SQL> alter table t rename constraint SYS_C0018682 to X_NOT_NULL;
Table altered.
Indexes :
SQL> create index i1 on t(x);
Index created.
SQL> alter index i1 rename to i2;
Index altered.
Columns :
SQL> alter table t rename column x to y;
Table altered.
Partitions :
SQL> create table t (x number, y number)
2 partition by range(x)
3 subpartition by hash(y) (
4 partition p1 values less than(1)
5 (subpartition sp1)
6 ) ;
Table created.
SQL> alter table t rename partition p1 to p2;
Table altered.
Subpartitions:
SQL> alter table t rename subpartition sp1 to sp2;
Table altered.
Triggers:
SQL> create trigger tr1 after update on t
2 begin null; end;
3 /
Trigger created.
SQL>
SQL> alter trigger tr1 rename to tr2;
Trigger altered.
For the dba, you can also rename datafile, logfile and even tablespaces (10g)
Very handy!
and of course rename tablespace…
and rename user: update sys.user$ where…
😉
ehhh and of course rename database…
I’m not sure why the user is forced to remember all this lack of consistency in the rename syntax. Wouldn’t it be more simple to do it like this?
update user_objects
set object_name = ‘MY_’ || object name;
Great summary for rename syntax.
The response for renaming still needs a litle work. Right it allways replies with table renamed. 🙂
yes, this is bad 👿