|
| 1 | +declare |
| 2 | + l_tab_exist number; |
1 | 3 | begin |
2 | | - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then |
3 | | - dbms_plsql_code_coverage.create_coverage_tables(force_it => true); |
4 | | - $else |
5 | | - null; |
6 | | - $end |
| 4 | + select count(*) into l_tab_exist from |
| 5 | + (select table_name from all_tables where table_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA') |
| 6 | + union all |
| 7 | + select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); |
| 8 | + if l_tab_exist = 0 then |
| 9 | + execute immediate q'[ |
| 10 | + create table dbmspcc_blocks ( |
| 11 | + run_id number(38, 0), |
| 12 | + object_id number(38, 0), |
| 13 | + block number(38, 0), |
| 14 | + line number(38, 0), |
| 15 | + col number(38, 0), |
| 16 | + covered number(1, 0), |
| 17 | + not_feasible number(1, 0) |
| 18 | + )]'; |
| 19 | + execute immediate q'[ |
| 20 | + create unique index dbmspcc_blocks_pk on |
| 21 | + dbmspcc_blocks ( |
| 22 | + run_id, |
| 23 | + object_id, |
| 24 | + block |
| 25 | + )]'; |
| 26 | + execute immediate q'[ |
| 27 | + alter table dbmspcc_blocks modify ( |
| 28 | + line |
| 29 | + constraint dbmspcc_blocks_line_nn not null enable |
| 30 | + )]'; |
| 31 | + execute immediate q'[ |
| 32 | + alter table dbmspcc_blocks modify ( |
| 33 | + col |
| 34 | + constraint dbmspcc_blocks_col_nn not null enable |
| 35 | + )]'; |
| 36 | + execute immediate q'[ |
| 37 | + alter table dbmspcc_blocks modify ( |
| 38 | + covered |
| 39 | + constraint dbmspcc_blocks_covered_nn not null enable |
| 40 | + )]'; |
| 41 | + execute immediate q'[ |
| 42 | + alter table dbmspcc_blocks modify ( |
| 43 | + not_feasible |
| 44 | + constraint dbmspcc_blocks_not_feasible_nn not null enable |
| 45 | + )]'; |
| 46 | + execute immediate q'[ |
| 47 | + alter table dbmspcc_blocks |
| 48 | + add constraint dbmspcc_blocks_block_ck check ( block >= 0 ) enable]'; |
| 49 | + execute immediate q'[ |
| 50 | + alter table dbmspcc_blocks |
| 51 | + add constraint dbmspcc_blocks_line_ck check ( line >= 0 ) enable]'; |
| 52 | + execute immediate q'[ |
| 53 | + alter table dbmspcc_blocks |
| 54 | + add constraint dbmspcc_blocks_col_ck check ( col >= 0 ) enable]'; |
| 55 | + execute immediate q'[ |
| 56 | + alter table dbmspcc_blocks |
| 57 | + add constraint dbmspcc_blocks_covered_ck check ( covered in ( |
| 58 | + 0, |
| 59 | + 1 |
| 60 | + ) ) enable]'; |
| 61 | + execute immediate q'[ |
| 62 | + alter table dbmspcc_blocks |
| 63 | + add constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in ( |
| 64 | + 0, |
| 65 | + 1 |
| 66 | + ) ) enable]'; |
| 67 | + execute immediate q'[ |
| 68 | + alter table dbmspcc_blocks |
| 69 | + add constraint dbmspcc_blocks_pk primary key ( run_id, |
| 70 | + object_id, |
| 71 | + block ) |
| 72 | + using index enable]'; |
| 73 | + end if; |
| 74 | +end; |
| 75 | +/ |
| 76 | +declare |
| 77 | + l_tab_exist number; |
| 78 | +begin |
| 79 | + select count(*) into l_tab_exist from |
| 80 | + (select table_name from all_tables where table_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA') |
| 81 | + union all |
| 82 | + select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); |
| 83 | + if l_tab_exist = 0 then |
| 84 | + execute immediate q'[ |
| 85 | + create table dbmspcc_runs ( |
| 86 | + run_id number(38, 0), |
| 87 | + run_comment varchar2(4000 byte), |
| 88 | + run_owner varchar2(128 byte), |
| 89 | + run_timestamp date |
| 90 | + )]'; |
| 91 | + execute immediate q'[ |
| 92 | + create unique index dbmspcc_runs_pk on |
| 93 | + dbmspcc_runs ( |
| 94 | + run_id |
| 95 | + )]'; |
| 96 | + execute immediate q'[ |
| 97 | + alter table dbmspcc_runs modify ( |
| 98 | + run_owner |
| 99 | + constraint dbmspcc_runs_run_owner_nn not null enable |
| 100 | + )]'; |
| 101 | + execute immediate q'[ |
| 102 | + alter table dbmspcc_runs modify ( |
| 103 | + run_timestamp |
| 104 | + constraint dbmspcc_runs_run_timestamp_nn not null enable |
| 105 | + )]'; |
| 106 | + execute immediate q'[ |
| 107 | + alter table dbmspcc_runs |
| 108 | + add constraint dbmspcc_runs_pk primary key ( run_id ) |
| 109 | + using index enable]'; |
| 110 | + end if; |
| 111 | +end; |
| 112 | +/ |
| 113 | +declare |
| 114 | + l_tab_exist number; |
| 115 | +begin |
| 116 | + select count(*) into l_tab_exist from |
| 117 | + (select table_name from all_tables where table_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA') |
| 118 | + union all |
| 119 | + select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); |
| 120 | + if l_tab_exist = 0 then |
| 121 | + execute immediate q'[ |
| 122 | + create table dbmspcc_units ( |
| 123 | + run_id number(38, 0), |
| 124 | + object_id number(38, 0), |
| 125 | + owner varchar2(128 byte), |
| 126 | + name varchar2(128 byte), |
| 127 | + type varchar2(12 byte), |
| 128 | + last_ddl_time date |
| 129 | + )]'; |
| 130 | + execute immediate q'[ |
| 131 | + create unique index dbmspcc_units_pk on |
| 132 | + dbmspcc_units ( |
| 133 | + run_id, |
| 134 | + object_id |
| 135 | + )]'; |
| 136 | + execute immediate q'[ |
| 137 | + alter table dbmspcc_units modify ( |
| 138 | + owner |
| 139 | + constraint dbmspcc_units_owner_nn not null enable |
| 140 | + )]'; |
| 141 | + execute immediate q'[ |
| 142 | + alter table dbmspcc_units modify ( |
| 143 | + name |
| 144 | + constraint dbmspcc_units_name_nn not null enable |
| 145 | + )]'; |
| 146 | + execute immediate q'[ |
| 147 | + alter table dbmspcc_units modify ( |
| 148 | + type |
| 149 | + constraint dbmspcc_units_type_nn not null enable |
| 150 | + )]'; |
| 151 | + execute immediate q'[ |
| 152 | + alter table dbmspcc_units modify ( |
| 153 | + last_ddl_time |
| 154 | + constraint dbmspcc_units_last_ddl_time_nn not null enable |
| 155 | + )]'; |
| 156 | + execute immediate q'[ |
| 157 | + alter table dbmspcc_units |
| 158 | + add constraint dbmspcc_units_pk primary key ( run_id, |
| 159 | + object_id ) |
| 160 | + using index enable]'; |
| 161 | + end if; |
7 | 162 | end; |
8 | 163 | / |
0 commit comments