{"id":244312,"date":"2022-06-18T10:01:21","date_gmt":"2022-06-18T02:01:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=244312"},"modified":"2022-06-04T02:02:30","modified_gmt":"2022-06-03T18:02:30","slug":"after-the-oracle-table-moves","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/after-the-oracle-table-moves.html","title":{"rendered":"Oracle\u8868\u79fb\u52a8\u540e\u5e94\u8be5\u505a\u54ea\u4e9b\u4e8b\u60c5\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u79fb\u52a8\u4e00\u5f20\u8868\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u91cd\u7ec4\u8fc7\u7a0b\uff0c\u6570\u636e\u5e93\u4f1a\u5c06\u539f\u6765\u7684\u6570\u636e\u590d\u5236\u5230\u65b0\u7684\u5730\u65b9\u3002\u4f46\u662f\u5982\u679c\u4f60\u53d1\u73b0\u8fd9\u4e2a\u8868\u5728\u79fb\u52a8\u540e\u6027\u80fd\u4e0b\u964d\u4e86\uff0c\u53ef\u80fd\u662f\u4f60\u7684\u7d22\u5f15\u6ca1\u6709\u91cd\u5efa\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u627e\u5230\u4f9d\u8d56\u7d22\u5f15\u5e76\u91cd\u5efa\u5b83\u4eec\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/a><\/p>\n

\u6982\u8ff0<\/strong><\/div>\n

\u79fb\u52a8\u4e00\u5f20\u8868\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u91cd\u7ec4\u8fc7\u7a0b\uff0c\u6570\u636e\u5e93\u4f1a\u5c06\u539f\u6765\u7684\u6570\u636e\u590d\u5236\u5230\u65b0\u7684\u5730\u65b9\u3002\u4f46\u662f\u5982\u679c\u4f60\u53d1\u73b0\u8fd9\u4e2a\u8868\u5728\u79fb\u52a8\u540e\u6027\u80fd\u4e0b\u964d\u4e86\uff0c\u53ef\u80fd\u662f\u4f60\u7684\u7d22\u5f15\u6ca1\u6709\u91cd\u5efa\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u627e\u5230\u4f9d\u8d56\u7d22\u5f15\u5e76\u91cd\u5efa\u5b83\u4eec\u3002
\n
\"\"<\/a><\/p>\n

\u5c06\u8868\u4ece\u793a\u4f8b\u79fb\u52a8\u5230\u7528\u6237<\/strong><\/div>\n
\r\nSQL> select tablespace_name from dba_tables where owner = 'HR' and table_name = 'EMPLOYEES';\r\n\r\nTABLESPACE_NAME\r\n------------------------------\r\nEXAMPLE\r\n\r\nSQL> alter table hr.employees move tablespace users;\r\n\r\nTable altered.\r\n\r\nSQL> select tablespace_name from dba_tables where owner = 'HR' and table_name = 'EMPLOYEES';\r\n\r\nTABLESPACE_NAME\r\n------------------------------\r\nUSERS\r\n<\/pre>\n
\u67e5\u770b\u54ea\u4e9b\u7d22\u5f15\u53d6\u51b3\u4e8e\u6b64\u8868<\/strong><\/div>\n
\r\nSQL> column index_name format a30;\r\nSQL> column tablespace_name format a30;\r\nSQL> column status format a10;\r\nSQL> select index_name, tablespace_name, status from dba_indexes where owner = 'HR' and table_name = 'EMPLOYEES';\r\n\r\nINDEX_NAME                     TABLESPACE_NAME                STATUS\r\n------------------------------ ------------------------------ ----------\r\nEMP_JOB_IX                     EXAMPLE                        UNUSABLE\r\nEMP_DEPARTMENT_IX              EXAMPLE                        UNUSABLE\r\nEMP_MANAGER_IX                 EXAMPLE                        UNUSABLE\r\nEMP_NAME_IX                    EXAMPLE                        UNUSABLE\r\nEMP_EMAIL_UK                   EXAMPLE                        UNUSABLE\r\nEMP_EMP_ID_PK                  EXAMPLE                        UNUSABLE\r\n\r\n6 rows selected.\r\n<\/pre>\n

\u5982\u60a8\u6240\u89c1\uff0c\u6240\u6709\u4f9d\u8d56\u7d22\u5f15\u90fd\u662fUNUSABLE\u3002\u8fd9\u610f\u5473\u7740\uff0c\u6570\u636e\u5e93\u4e0d\u4f1a\u81ea\u52a8\u91cd\u5efa\u5b83\u4eec\u3002\u4f60\u5fc5\u987b\u81ea\u5df1\u505a\u3002<\/p>\n

\u7f16\u5199\u6240\u6709\u91cd\u5efa\u8bed\u53e5\uff0c\u7136\u540e\u6267\u884c\u5b83\u4eec<\/strong><\/div>\n
\r\nSQL> select 'alter index ' || owner || '.' ||index_name || ' rebuild tablespace users;' as SQL_TO_BE_EXECUTED from dba_indexes where owner = 'HR' and table_name = 'EMPLOYEES';\r\n\r\nSQL_TO_BE_EXECUTED\r\n--------------------------------------------------------------------------------\r\nalter index EMP_JOB_IX rebuild tablespace users;\r\nalter index EMP_DEPARTMENT_IX rebuild tablespace users;\r\nalter index EMP_MANAGER_IX rebuild tablespace users;\r\nalter index EMP_NAME_IX rebuild tablespace users;\r\nalter index EMP_EMAIL_UK rebuild tablespace users;\r\nalter index EMP_EMP_ID_PK rebuild tablespace users;\r\n\r\n6 rows selected.\r\n<\/pre>\n
\u6216\u8005\u60a8\u53ef\u4ee5\u91cd\u5efa\u539f\u59cb\u8868\u7a7a\u95f4\u7684\u7d22\u5f15\u3002<\/strong><\/div>\n
\r\nSQL> select 'alter index ' || owner || '.' ||index_name || ' rebuild tablespace ' || tablespace_name || ';' as SQL_TO_BE_EXECUTED from dba_indexes where owner = 'HR' and table_name = 'EMPLOYEES';\r\n\r\nSQL_TO_BE_EXECUTED\r\n--------------------------------------------------------------------------------\r\nalter index HR.EMP_DEPARTMENT_IX rebuild tablespace EXAMPLE;\r\nalter index HR.EMP_NAME_IX rebuild tablespace EXAMPLE;\r\nalter index HR.EMP_MANAGER_IX rebuild tablespace EXAMPLE;\r\nalter index HR.EMP_EMP_ID_PK rebuild tablespace EXAMPLE;\r\nalter index HR.EMP_EMAIL_UK rebuild tablespace EXAMPLE;\r\nalter index HR.EMP_JOB_IX rebuild tablespace EXAMPLE;\r\n\r\n6 rows selected.\r\n<\/pre>\n

\u8bf7\u6ce8\u610f\uff0c\u6211\u4eec\u5728\u65b0\u8868\u7a7a\u95f4USERS\u4e2d\u91cd\u5efa\u7d22\u5f15\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u4e8e\u7d22\u5f15\uff0cREBUILD\u76f8\u5f53\u4e8e\u8868\u4e2d\u7684MOVE<\/p>\n

\u91cd\u5efa\u540e\u68c0\u67e5\u72b6\u6001<\/strong><\/div>\n
\r\nSQL> select index_name, tablespace_name, status from dba_indexes where owner = 'HR' and table_name = 'EMPLOYEES';\r\n\r\nINDEX_NAME                     TABLESPACE_NAME                STATUS\r\n------------------------------ ------------------------------ ----------\r\nEMP_JOB_IX                     USERS                          VALID\r\nEMP_DEPARTMENT_IX              USERS                          VALID\r\nEMP_MANAGER_IX                 USERS                          VALID\r\nEMP_NAME_IX                    USERS                          VALID\r\nEMP_EMAIL_UK                   USERS                          VALID\r\nEMP_EMP_ID_PK                  USERS                          VALID\r\n\r\n6 rows selected.\r\n<\/pre>\n

\u6240\u6709\u7d22\u5f15\u90fd\u53d8\u4e3aVALID\uff0c\u8868\u660e\u6240\u91cd\u5efa\u7684\u7d22\u5f15\u6709\u6548\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u79fb\u52a8\u4e00\u5f20\u8868\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u91cd\u7ec4\u8fc7\u7a0b\uff0c\u6570\u636e\u5e93\u4f1a\u5c06\u539f\u6765\u7684\u6570\u636e\u590d\u5236\u5230\u65b0\u7684\u5730\u65b9\u3002\u4f46\u662f\u5982\u679c\u4f60\u53d1\u73b0\u8fd9\u4e2a\u8868\u5728\u79fb\u52a8\u540e\u6027\u80fd\u4e0b\u964d\u4e86\uff0c\u53ef […]<\/p>\n","protected":false},"author":1898,"featured_media":244315,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[870],"class_list":["post-244312","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread","tag-oracle"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/244312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=244312"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/244312\/revisions"}],"predecessor-version":[{"id":244317,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/244312\/revisions\/244317"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/244315"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=244312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=244312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=244312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}