grant EXECUTE_CATALOG_ROLE,CREATE ANY TABLE,ALTER ANY TABLE,DROP ANY TABLE,LOCK ANY TABLE,SELECT ANY TABLE to &用戶名;
或者直接使用DBA用戶。
begin
dbms_redefinition.can_redef_table(uname => &user,
tname => &table,
options_flag => dbms_redefinition.CONS_USE_PK);
end;
/
如果當前表沒有主鍵,需要將選項設置為CONS_USE_rowid(表示使用rowid作為分區依據。)
alter session force parallel dml parallel &并行度;
alter session force parallel query parallel &并行度;
CREATE TABLE scott.emp_tmp
(
EMPNO NUMBER(4) not null,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2)
)
partition BY range(EMPNO)
(
partition tab_part_2020 VALUES less than (7700),
partition tab_part_2021 VALUES less than (7900),
partition tab_part_2022 values less than(maxvalue)
);
BEGIN
DBMS_REDEFINITION.START_REDEF_TABLE(uname => &用戶名,
orig_table => &源表名,
int_table => &臨時表名,
col_mapping => null,
options_flag => dbms_redefinition.cons_use_pk
);
END;
/
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-14400: inserted partition key does not map to any partition
select * from dba_mview_logs where log_owner=SCOTT;
select MVIEW_NAME,CONTAINER_NAME,QUERY from dba_mviews where owner=SCOTT;
drop materialized view log on scott.emp1;
drop materiallized view scott.emp_tmp;
DECLARE
error_count PLS_INTEGER :=0;
BEGIN
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS(uname => &用戶名,
orig_table => &源表名,
int_table => &臨時表名,
copy_indexes => DBMS_REDEFINITION.CONS_ORIG_PARAMS,
copy_triggers => TRUE,
copy_constraints => TRUE,
copy_privileges => TRUE,
ignore_errors => true,
num_errors => error_count,
copy_statistics => FALSE );
DBMS_OUTPUT.PUT_LINE(errors := || TO_CHAR(error_count));
END;
ERROR at line 1:
ORA-01442: column to be modified to NOT NULL is already NOT NULL
select * from DBA_REDEFINITION_ERRORS;
SELECT CONSTRAINT_NAME, VALIDATED FROM USER_CONSTRAINTS WHERE TABLE_NAME = &表名;
ALTER TABLE &表名 ENABLE VALIDATE CONSTRAINT &約束名稱;
SELECT CONSTRAINT_NAME, VALIDATED FROM USER_CONSTRAINTS WHERE TABLE_NAME = &表名;
BEGIN
DBMS_REDEFINITION.SYNC_INTERIM_TABLE(uname => &用戶名,
orig_table => &源表名,
int_table => &臨時表名
);
END;
BEGIN
DBMS_REDEFINITION.FINISH_REDEF_TABLE(uname => &用戶名,
orig_table => &源表名,
int_table => &臨時表名
);
END;
EXEC DBMS_STATS.gather_table_stats(&用戶名, &表名, cascade => TRUE,no_invalidate => FALSE);
no_invalidate參數決定了新統計量生成之后,如何處理此時已經生成的執行計劃,no_invalidate取值true,新的執行計劃不會立即生效;no_invalidate取值false,新的執行計劃會立即生效,取值auto_invalidate則數據庫自行判斷何時生效(默認值)。
SELECT ALTER INDEX || INDEX_OWNER || . || INDEX_NAME ||
REBUILD PARTITION || PARTITION_NAME || NOLOGGING online;
FROM DBA_IND_PARTITIONS
WHERE INDEX_OWNER NOT IN (SYS, SYSTEM, PUBLIC)
AND STATUS = UNUSABLE
UNION ALL
SELECT alter index || OWNER || . || A.INDEX_NAME ||
REBUILD online nologging;
FROM DBA_INDEXES A
WHERE OWNER NOT IN (SYS, SYSTEM, PUBLIC)
AND STATUS = UNUSABLE;
select * from dba_objects where status<>VALID and owner=&用戶名;
truncate table &臨時表名;
drop table &臨時表名;
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/129302.html
摘要:背景由于性能數據每天導入量,數據庫表空間每天增長很快,且不需要太長的保存周期,為避免爆表,因此需要定制定期清理計劃。數據的清理可以有多種方案,根據場景的不同可以分為離線,在線。 背景 由于性能數據每天導入量,數據庫表空間每天增長很快,且不需要太長的保存周期,為避免爆表,因此需要定制定期清理計劃。數據的清理可以有多種方案,根據場景的不同可以分為離線,在線。后續又在可以細分。這里僅考慮在線...
摘要:前言在使用加載數據數據庫常見的優化操作后端掘金一索引將放第一位,不用說,這種優化方式我們一直都在悄悄使用,那便是主鍵索引。 Redis 內存壓縮實戰 - 后端 - 掘金在討論Redis內存壓縮的時候,我們需要了解一下幾個Redis的相關知識。 壓縮列表 ziplist Redis的ziplist是用一段連續的內存來存儲列表數據的一個數據結構,它的結構示例如下圖 zlbytes: 記錄整...
閱讀 1346·2023-01-11 13:20
閱讀 1684·2023-01-11 13:20
閱讀 1132·2023-01-11 13:20
閱讀 1858·2023-01-11 13:20
閱讀 4100·2023-01-11 13:20
閱讀 2704·2023-01-11 13:20
閱讀 1385·2023-01-11 13:20
閱讀 3597·2023-01-11 13:20