-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy paththree_table_create.sql
58 lines (53 loc) · 1.19 KB
/
three_table_create.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def crows=10
def orows=100
def olrows=1000
drop table customers;
create table customers as
select
rownum id
,rownum val
,rpad('A',4000,'A') data1
,rpad('A',2000,'A') data2
from
dual
connect by
level <= &crows
;
drop table orders;
create table orders as
select
rownum id,
--mod(rownum,&crows)+1 cid
trunc((rownum-1)/&crows)+1 cid
,rownum val
,rpad('A',4000,'A') data1
,rpad('A',2000,'A') data2
from
dual
connect by
level <= &orows
;
drop table orderlines;
create table orderlines as
select
rownum id,
--mod(rownum,&orows)+1 oid
trunc((rownum-1)/&orows)+1 oid
,rownum val
,rpad('A',4000,'A') data1
,rpad('A',2000,'A') data2
from
dual
connect by
level <= &olrows
;
create index cu_id on customers(id);
create index or_id on orders(id);
create index or_cid on orders(cid);
create index ol_id on orderlines(id);
create index ol_oid on orderlines(oid);
BEGIN DBMS_STATS.GATHER_TABLE_STATS(null,'CUSTOMERS'); END;
/
BEGIN DBMS_STATS.GATHER_TABLE_STATS(null,'ORDERS'); END;
/
BEGIN DBMS_STATS.GATHER_TABLE_STATS(null,'ORDERLINES'); END;