
prompt
prompt 创建eoda.gt_delete
declare 
    num number;
begin
    select count(1) into num from user_tables where table_name = upper( 'gt_delete' ) and temporary = 'Y';
    if num = 1 then 
        execute immediate 'drop table eoda.gt_delete';
    end if;
    execute immediate '
        create global temporary table eoda.gt_delete ( x number )
        on commit delete rows 
    ';
end;
/

prompt
prompt 插入数据到eoda.gt_delete
declare 
    num number;
begin
    execute immediate 'truncate table eoda.gt_delete';
    insert into eoda.gt_delete select user_id from all_users;
    -- 在事务提交之前查询，等到事务提交之后eoda.gt_delete表中数据就会被清除
    select count(*) into num from eoda.gt_delete;
    dbms_output.put_line ( '表中数据' || to_char( num ) );
    commit;
    dbms_stats.gather_table_stats ( user,'GT_DELETE' );
end;
/

select table_name,num_rows,last_analyzed,scope
  from user_tab_statistics 
 where table_name like 'GT_DELETE';
