首先创建一张含千条记录的tag表:
tag表定义:
create table tag( id number(12), name nvarchar2(20), primary key(id) )
插值:
insert into tag select rownum, dbms_random.String('*',dbms_random.value(6,20)) from dual connect by level<1001
其次创建一张含两百万记录的Customer表:
customer表定义:
create table customer( id number(12), name nvarchar2(20), primary key(id) )
插值:
insert into customer select rownum, dbms_random.String('*',dbms_random.value(6,20)) from dual connect by level<2000001
接下来就是创建连接表了:
create table customer_tag as select rownum as id,tag.id as tid,customer.id as cid from tag,customer
上面运行的时间有些长,部分机器上还可能爆ora-01652错误,请自行查找解决方案。
创建完毕后,查看新表有多大:
SQL> select count(*) from customer_tag; COUNT(*) ---------- 2000000000
END