
-- 原来undo段的名称:UNDOTBS1

prompt
prompt 'create tablespace undo_small '
declare row_count number;
begin
	select count(1) into row_count from dual where exists( select 1 from dba_tablespaces  where tablespace_name = upper('undo_small'));
	if row_count = 0 then
		execute immediate '
			create undo tablespace undo_small
			datafile ''/tmp/undo.dbf'' size 2m
			autoextend off
		';
	end if;
end;
/

alter system set undo_tablespace = 'undo_small';

prompt
prompt 'create table t'
declare row_count number;
begin
	select count(1) into row_count from dual where exists (select 1 from user_tables where table_name  = upper('t'));
	if row_count = 1 then
		execute immediate 'drop table t';
	end if;
	execute immediate '
		create table t
		as
		select *
		  from all_objects
		 order by dbms_random.random
	';
	commit;
	dbms_stats.gather_table_stats( user,'T',cascade=>true );
end;
/

alter system set undo_tablespace = 'UNDOTBS1';
