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 分割槽索引的失效和重建Oracle索引
- oracle 表遷移方法 (二) 約束不失效Oracle
- oracle 19c pdb遷移Oracle
- Oracle資料庫升級或資料遷移的方法探討Oracle資料庫
- Oracle從Windows 11.2.0.1升級並遷移到Linux 19cOracleWindowsLinux
- 遷移式升級的測試
- 【XTTS】Oracle XTTS V4--Oracle11.2.0.4+ 遷移升級TTSOracle
- 遷移式升級的測試(二)
- 遷移式升級的測試(三)
- 遷移式升級的一點思考
- 資料庫的升級及遷移資料庫
- Oracle中表空間、表、索引的遷移Oracle索引
- Oracle:Oracle RAC 11.2.0.4 升級為 19cOracle
- 關於Oracle 9i exp/imp 遷移過程中表分割槽是否匯入成功的測試Oracle
- Oracle 19c中基於函式的索引Oracle函式索引
- 【Oracle升級】Oracle指令碼升級11g to 19c non-CDBOracle指令碼
- Grafana的版本升級和資料遷移Grafana
- 關於資料遷移的方法、步驟和心得
- Oracle 18C升級到19COracle
- Oracle索引失效-likeOracle索引
- gitlab安裝/遷移/升級流程Gitlab
- Oracle 19c adg全庫遷移資料Oracle
- datapump跨平臺升級遷移的總結
- 一種遷移式升級的方案考慮
- oracle 9i升級到oracle9208Oracle
- [高翔]關於卷遷移的整理
- oracle 表遷移方法 (一)Oracle
- 遷移資料到Oracle的方法思考Oracle
- 關於億級賬戶資料遷移,你應該試試這種方法...
- Oracle 12c 使用(Full Transportable Export/Import)進行升級/遷移OracleExportImport
- 32位升級到64位之後遷移oracle db遇到的問題Oracle
- SQL Server升級和遷移的三個技巧GZSQLServer
- 關於移動端IOS active失效的處理iOS
- 遷移學習系列---基於例項方法的遷移學習遷移學習
- Oracle 9i RAC向單例項遷移手記Oracle單例