Oracle 9i升級19C 遷移關於失效索引的梳理方法
declare
ls_sql varchar2(1000);
ls_tbs_name varchar2(30) :='FWDATA_IDX';
begin
for ci in (select owner, index_name, index_type, table_owner, table_name, uniqueness
from dba_indexes@to9idb
where owner in ('XXXX')
--and index_name not like 'SYS_%'
--and table_name in (select tab_name from exp_group)
minus
select owner, index_name, index_type, table_owner, table_name, uniqueness
from dba_indexes@to19cdcdb
where owner in ('XXXX')
--and index_name not like 'SYS_%'
order by owner, table_name, index_name) loop
if ci.uniqueness = 'UNIQUE' then
ls_sql := 'create unique index ' || ci.owner || '.' || ci.index_name || ' on ' || ci.table_owner || '.' || ci.table_name || '(';
else
ls_sql := 'create index ' || ci.owner || '.' || ci.index_name || ' on ' || ci.table_owner || '.' || ci.table_name || '(';
end if;
for cr in (select * from dba_ind_columns@to9idb where index_owner = ci.owner and index_name = ci.index_name
and table_owner = ci.table_owner and table_name = ci.table_name order by column_position) loop
ls_sql := ls_sql || cr.column_name || ',';
end loop;
ls_sql := rtrim(ls_sql, ',');
ls_sql := ls_sql || ') tablespace ' || ls_tbs_name || ' parallel 16;';
dbms_output.put_line(ls_sql);
dbms_output.put_line('alter index ' || ci.owner || '.' || ci.index_name || ' noparallel;');
dbms_output.put_line('');
end loop;
end;
/
-- 新增主鍵約束
declare
ls_sql varchar2(1000);
ls_tbs_name varchar2(30) :='FWDATA_IDX';
begin
for cc in (select owner, table_name
from dba_constraints@to9idb t
where owner in ('XXXX')
and t.constraint_type = 'P'
and table_name in (select tab_name from exp_group)
minus
select owner, table_name
from dba_constraints@to19cdcdb t
where owner in ('XXXX')
and t.constraint_type = 'P'
order by owner, table_name) loop
for ci in (select * from dba_constraints@to9idb where owner = cc.owner and table_name = cc.table_name and constraint_type = 'P') loop
ls_sql := 'alter table ' || ci.owner || '.' || ci.table_name || ' add constraint ' || ci.constraint_name || ' primary key (';
for cr in (select * from dba_ind_columns@to9idb where index_owner = ci.owner and index_name = ci.index_name
and table_owner = ci.owner and table_name = ci.table_name order by column_position) loop
ls_sql := ls_sql || cr.column_name || ',';
end loop;
ls_sql := rtrim(ls_sql, ',');
ls_sql := ls_sql || ') using index enable;';
dbms_output.put_line(ls_sql);
end loop;
end loop;
end;
/
-- 新增unique鍵約束
declare
ls_sql varchar2(1000);
ls_tbs_name varchar2(30) :='FWDATA_IDX';
begin
for cc in (select owner, table_name
from dba_constraints@to9idb t
where owner in ('XXX')
and t.constraint_type = 'U'
--and table_name in (select tab_name from exp_group)
minus
select owner, table_name
from dba_constraints@to19cdcdb t
where owner in ('XXX')
and t.constraint_type = 'U'
order by owner, table_name) loop
for ci in (select * from dba_constraints@to9idb where owner = cc.owner and table_name = cc.table_name and constraint_type = 'U') loop
ls_sql := 'alter table ' || ci.owner || '.' || ci.table_name || ' add constraint ' || ci.constraint_name || ' unique (';
for cr in (select * from dba_ind_columns@to9idb where index_owner = ci.owner and index_name = ci.index_name
and table_owner = ci.owner and table_name = ci.table_name order by column_position) loop
ls_sql := ls_sql || cr.column_name || ',';
end loop;
ls_sql := rtrim(ls_sql, ',');
ls_sql := ls_sql || ') using index enable;';
dbms_output.put_line(ls_sql);
end loop;
end loop;
end;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31547506/viewspace-2987244/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 9i升級19C 邏輯遷移詳細方法(一)Oracle
- Oracle 9i升級19C 邏輯遷移詳細方法(二)Oracle
- Oracle 9i 11g歷史庫升級遷移資料至19c CDBOracle
- oracle 19c pdb遷移Oracle
- Oracle資料庫升級或資料遷移的方法探討Oracle資料庫
- Oracle從Windows 11.2.0.1升級並遷移到Linux 19cOracleWindowsLinux
- 【XTTS】Oracle XTTS V4--Oracle11.2.0.4+ 遷移升級TTSOracle
- gitlab的遷移和升級Gitlab
- Oracle中表空間、表、索引的遷移Oracle索引
- Oracle:Oracle RAC 11.2.0.4 升級為 19cOracle
- Oracle 19c中基於函式的索引Oracle函式索引
- Oracle 19c adg全庫遷移資料Oracle
- 【Oracle升級】Oracle指令碼升級11g to 19c non-CDBOracle指令碼
- Oracle 18C升級到19COracle
- gitlab安裝/遷移/升級流程Gitlab
- Grafana的版本升級和資料遷移Grafana
- Oracle索引梳理系列(六)- Oracle索引種類之函式索引Oracle索引函式
- datagrip2019.1.4-升級資料遷移
- 使用DBUA升級 Oracle 11.2.0.4到Oracle 19C的問題記錄Oracle
- 【UP_ORACLE】Oracle 19c之從19.3升級到19.9Oracle
- 關於億級賬戶資料遷移,你應該試試這種方法...
- 【資料庫升級】Oracle指令碼升級12c CDB to 19c CDB資料庫Oracle指令碼
- 墨天輪高分技術文件分享——Oracle升級遷移篇(共96個)Oracle
- 遷移學習系列---基於例項方法的遷移學習遷移學習
- index_oracle索引梳理系列及分割槽表梳理IndexOracle索引
- 關於移動端IOS active失效的處理iOS
- SQL Server升級和遷移的三個技巧GZSQLServer
- 關於 Laravel 遷移遇到的問題Laravel
- 關於禪道的資料遷移
- Oracle 19c - 手動升級 Oracle 12.x, 18c CDB 到 Oracle 19c (19.x)Oracle
- Oracle Database 19c中的自動索引OracleDatabase索引
- 【DBA Part03】國產Linux上Oracle RAC安裝-升級-ADG-遷移LinuxOracle
- 【INDEX】Oracle 索引常見知識梳理IndexOracle索引
- weblogic版本升級遷移需要注意事項Web
- 關於轉儲Oracle索引資訊的相關命令Oracle索引
- Oracle12c遷移-某風險報告類系統升級暨遷移至12c-2Oracle
- Oracle12c遷移-某風險報告類系統升級暨遷移至12c-3Oracle
- Oracle12c遷移-某風險報告類系統升級暨遷移至12c-1Oracle