
prompt
prompt 创建传统的堆表eoda.t_heap
declare
    num number;
    num_hashed number;
begin 
    select count(1) into num from all_tables where TABLE_NAME = 'T_HEAP' AND OWNER = 'EODA';
    select count(1) into num_hashed from all_tables where TABLE_NAME = 'T_HEAPED' AND OWNER = 'EODA';
    if num = 1 then 
        execute immediate 'drop table eoda.t_heap';
    end if;
    if num_hashed = 0 then 
        execute immediate '';
    end if;
    execute immediate '
        create table eoda.t_heap
        as 
        select * from eoda.t_hashed
        ';
end;
/


prompt 
prompt 添加主健eoda.t_heap
declare 
   num number;
begin 
    select count(1) into num from all_tables where table_name = 'T_HEAP' and owner = 'EODA';
    if num = 1 then 
        execute immediate 'alter table eoda.t_heap add constraint t_heap_pk primary key(object_id)'
    end if;
end;
/


prompt
prompt 收集统计信息
declare 
    num number;
begin 
    select count(1) into num from all_tables where table_name = 'T_HEAP' and owner = 'EODA';
    if num = 1 then 
        dbms_stats.gather_table_stats( user,'T_HEAP' );
    end if;
end;
/
