Create an empty table based on all_objects, this dictionary view is used to populate big_table
create table big_table as select rownum id, a.* from all_objects a where 1=0 /
Set this table to NOLOGGING to improve performance. It is safe to use NOLOGGING mode for test tables.
Since the production system will not use such a test table, features such as oracle data guard will not be enabled
alter table big_table nologging;
Fills the table with the contents of all_objects, then inserts into itself iteratively, nearly doubling the size of the table with each iteration.
declare l_cnt number; l_rows number := &1; begin insert /*+ APPEND */ into big_table select rownum id, a.* from all_objects a; l_cnt := sql%rowcount; commit; while (l_cnt < l_rows) loop insert /*+ APPEND */ into big_table select rownum+l_cnt id, OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID, OBJECT_TYPE, CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS, TEMPORARY, GENERATED, SECONDARY, NAMESPACE, EDITION_NAME from big_table where rownum <= l_rows-l_cnt; l_cnt := l_cnt + sql%rowcount; commit; end loop; end; /
Create a primary key constraint on this table.
alter table big_table add constraint big_table_pk primary key(id) /
collect statistics
begin dbms_stats.gather_table_stats ( ownname => 'scott', tabname => 'BIG_TABLE', method_opt => 'for all indexed columns', cascade => TRUE ); end; /
Display the number of rows in the table
select count(*) from big_table;
result:
scott@ORCL>@D:\app\Administrator\product\11.2.0\big_table.sql; Table has been created. Table has been changed. Enter a value of 1: 100000 Original value 3: l_rows number := &1; new value 3: l_rows number := 100000; PL/SQL procedure completed successfully. Table has been changed. PL/SQL procedure completed successfully. COUNT(*) ---------- 100000