在删除和创建索引之前,我想检查索引是否存在。
用简单的 1-2 行语句可以实现这一点吗?
最佳答案
您当然可以查询dba_indexes
/all_indexes
/user_indexes
来查看索引是否存在。假设您想要查找特定的索引名称(您也可以匹配列集)
select count(*)
into l_cnt
from all_indexes
where owner = <<owner of index>>
and index_name = <<name of index>>
if( l_cnt > 0 )
then
<<index exists>>
else
<<index doesn't exist>>
end if;
当然,您也可以简单地删除索引并捕获它不存在的异常。
关于oracle - 如果存在则删除索引...如果存在则创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19784377/