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

prompt
prompt 插入数据到eoda.gt
begin
    execute immediate 'truncate table eoda.gt';
    insert into eoda.gt select user_id from all_users;
    commit;
    -- 将GLOBAL_TEMP_TABLE_STATS设置成SHARED
    dbms_stats.set_table_prefs( user,'GT','GLOBAL_TEMP_TABLE_STATS','SHARED' );
    dbms_stats.gather_table_stats ( user,'GT' );
end;
/

begin 
    dbms_output.put_line ( '查询视图USER_TAB_STATISTICS' );
end;
/
select table_name,num_rows ,last_analyzed,scope 
  from user_tab_statistics 
 where table_name like 'GT';

begin
    dbms_output.put_line ( '清除统计信息' );
end;
/
exec dbms_stats.delete_table_stats ( user,'GT' );

begin 
    dbms_output.put_line ( '查询视图USER_TAB_STATISTICS' );
end;
/
select table_name,num_rows ,last_analyzed,scope 
  from user_tab_statistics 
 where table_name like 'GT';
