Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create index if not exist

vittelMar 25 2009 — edited Mar 25 2009
Hi,

I need a simple script to create an index with multiple column if not exit, the only parameter that I know is table_name and column_name.

I have an idea but it's complicate spaecialy when we check for an index with 10 column!!

Declare
i integer;
i:=0;
Begin
select count(*) into i
from USER_IND_COLUMNS
where column_name=<column name1>
and table_name=<table_name>
and index_name in (select index_name
from USER_IND_COLUMNS
where column_name= <column_name2>
and table_name=<table_name>);
if i=0 then
create index <balbala> .....
end if;
i:=0;
.
.
.
end;

Thanks

Edited by: vittel on Mar 25, 2009 12:18 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2009
Added on Mar 25 2009
2 comments
1,387 views