oracle executes DDL in PLSQL block
- You cannot directly write DDL to delete the table, you should:
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;
/