oracle executes DDL in PLSQL block

oracle executes DDL in PLSQL block

  1. 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;
/

Guess you like

Origin blog.csdn.net/m0_55628494/article/details/128819430