There's no way to alter a non-unique index to be unique.
Remember that a unique index is a form of constraint. You're saying that there can only be one row for each set of values in the column list.
In the general case, this requires you to use clean the data before you can apply the constraint.
From 12c you can create many indexes on the same column list. Provided:
- The have different properties (uniqueness, partitioning, bitmap vs. btree, ...)
- Only one is visible
So you can swap a non-unique and unique index over doing something like this:
create table t (
c1 int
);
create index i
on t ( c1 );
create unique index ui
on t ( c1 )
invisible;
alter index i
invisible;
alter index ui
visible;
Note this means there's a brief time when there's no visible indexes on c1! You may want to have a short outage while swapping the indexes over.
There are also a whole bunch of subtle differences between unique and non-unique indexes. Richard Foote discusses these in a series starting at:
https://richardfoote.wordpress.com/2007/12/18/differences-between-unique-and-non-unique-indexes-part-i/