Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Alter Unique Index

 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table created in following way:

create table TAB1 (
ID number not null,
VAL1_NBR varchar2(30) not null,
VAL2_NBR varchar2(5) not null,
VAL3_CD varchar2(2),
VAL4_NBR varchar2(30) not null,
VAL5_IND char(1),
constraint TAB1_PK primary key (ID)
);

create unique index TAB1_IDX1 on TAB1 (
VAL1_NBR ASC,
VAL2_NBR ASC,
VAL3 CD ASC
);

Now I need to change the unique index to add one more value
"VAL4_NBR". How do I use alter command to do it?

Thanks
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jane,
You can use the "alter index" command. However, I would recommend dropping the existing index and creating a new one. The database needs to rebuild the index either way. And using "create index" gives you the command if you need to build the index in the future.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!