具体的执行代码如下,供参考,生产检验过:
declare
x number;
y number;
begin
select count(*) into y from all_indexes where owner = '表属组' and table_name = '表名' and index_name = '索引名';
if y >= 1 then
execute immediate 'drop index 表属组.索引名';
end if;
--- 再弄字段
SELECT COUNT(*) into x FROM USER_TAB_COLUMNS WHERE TABLE_NAME = '表名' AND COLUMN_NAME = '列字段';
if x >= 1 then
execute immediate 'ALTER TABLE 表属组.表名 DROP COLUMN 列字段';
end if;
end;
/