Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: rename indexes
> -----Original Message-----
> From: John Dunn [mailto:john.dunn_at_sefas.co.uk]
>
> When I create tables with primary keys, Oracle gives the
> indexes a default name.
>
> Can I rename these indexes with meaningful names, or do I
> need to drop and
> recreate my tables, amending create table statements to
> explicitly name the indexes?
You can use "alter index rename" to change the name of the index. Or (a better solution) you can name the enforcing index when you create the primary key.
Examples:
-- In both cases an index will be created with the same name
-- as the primary key constraint
create table t
( n number constraint t_pk primary key using index tablespace indx, d date ) ;
create table movie
( movie_name varchar2 (30), director_name varchar2 (30), year number, studio_name varchar2 (30), constraint movie_pk primary key (movie_name, director_name, year) using index tablespace indx )