oracle 在PLSQL块中 执行DDL
- 不能直接写DDL删除表,应该:
declare
v_count NUMBER;
begin
-- 查询表索引
select count(*) into v_count from user_indexes WHERE table_name = 'TABLE_1' and index_name = 'IN_TABLE_5';
if v_count > 0 then
dbms_output.put_line(v_count);
execute immediate 'drop index IN_TABLE_5'';
commit;
end if;
end;
/