create table TABLE_&1 as select rownum id, a.* from all_objects a where 1=0
/
alter table TABLE_&1 nologging;

declare
    l_cnt number;
    l_rows number := &1;
begin
    insert /*+ append */ into TABLE_&1
    select rownum, a.*
      from all_objects a
     where rownum <= &1;

    l_cnt := sql%rowcount;

    commit;

    while (l_cnt < l_rows)
    loop
        insert /*+ APPEND */ into TABLE_&1
        select rownum+l_cnt,
               OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID,
               OBJECT_TYPE, CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS,
               TEMPORARY, GENERATED, SECONDARY, NAMESPACE, EDITION_NAME
               , SHARING, EDITIONABLE, ORACLE_MAINTAINED -- 12c only columns
          from TABLE_&1
         where rownum <= l_rows-l_cnt;
        l_cnt := l_cnt + sql%rowcount;
        commit;
    end loop;
  execute immediate 'alter table TABLE_'|| &1 ||' add constraint TABLE_'|| &1 ||'_PK primary key(id)';
end;
/

exec dbms_stats.gather_table_stats(user, 'TABLE_&1');
