【正文】
表已更改。tablespacevaluespartitioncustaddralterT_LIST556CUSTADDRPARTITION_NAMECUSTADDR39。wherefromselect表已更改。tablespace55139。t_list551addtablet_list556(4)添加新分區(qū)SQLpartition_nameCUSTADDR39。wherefromselect表已更改。partitioncustaddralter1IDcustaddr*555SQL5562AREAcustaddr。*SQLmit。已創(chuàng)建 1 行。55539。339。custaddrinsert已創(chuàng)建 1 行。55139。239。custaddrinsert已創(chuàng)建 1 行。55639。139。custaddrinsert索引已創(chuàng)建。icd_service5p_othericd_service,4t_list556(3custaddr(id)2ix_custaddr_idcreate表已創(chuàng)建。icd_service10valuespartitiontablespace55639。valuespartition(areacode)7by)6varchar2(4null,4byte)idcustaddr2create 這種情況下,直接添加分區(qū)就可以了。 或者采用split,對(duì)邊界分區(qū)進(jìn)行拆分。count(*)72288sql三. 分區(qū)表的其他操作 添加新的分區(qū)添加新的分區(qū)有2中情況:(1)原分區(qū)里邊界是maxvalue或者default。partitionfromselectunpar_table。count(*)partition_namep1p2p3p4sql39。table_nameuser_tab_partitionspartition_nameparyessql39。table_nameuser_tablespartitioned7. 驗(yàn)證sqlcreate_date_ind。RENAMEINDEX6. 索引重命名SQLpar_table。DROP 只有在2個(gè)表進(jìn)行切換的時(shí)候會(huì)有短暫的鎖表。 此時(shí)臨時(shí)分區(qū)表par_table成了普通表,我們的基表unpar_table成了分區(qū)表。/PL/SQL 過(guò)程已成功完成。END。)。39。int_tableunpar_table39。=,439。unameBEGIN2pl/sql 過(guò)程已成功完成。=,39。icd39。exec索引已創(chuàng)建。onindexsql/PL/SQL 過(guò)程已成功完成。END。)。39。int_tableunpar_table39。=,439。unameBEGIN2這一步操作結(jié)束后,數(shù)據(jù)就已經(jīng)同步到這個(gè)臨時(shí)的分區(qū)表里來(lái)了。,create_dateIDpar_table39。unpar_table39。ICD39。EXECEND。par_table39。=unpar_table39。=ICD39。=這里要注意:如果分區(qū)表和原表列名相同,可以用如下方式進(jìn)行:SQLpl/sql 過(guò)程已成功完成。unpar_table39。,(39。4. 進(jìn)行重定義操作 檢查重定義的合理性sql(maxvalue))。lessp4)),539。20057139。thanvaluespartitionyyyymmdd39。,(to_date(39。lessp2)),339。20047139。thanvalues(partitionrangepartitiontimeprimary(idtable3. 創(chuàng)建臨時(shí)分區(qū)表sqltrue)。cascadeunpar_table39。,(39。2. 收集表的統(tǒng)計(jì)信息sqlmit。索引已創(chuàng)建。onindexsqldba_objects。createdselectintosql)。create_dateprimaryidunpar_tablecreate已連接。conn它已經(jīng)是普通表。即此時(shí)基表A成了分區(qū)表,我們創(chuàng)建的臨時(shí)分區(qū)表B 成了普通表。(3)開(kāi)始重定義,將基表A的數(shù)據(jù)導(dǎo)入臨時(shí)分區(qū)表B。[12261]在線重定義的大致操作流程如下:(1)創(chuàng)建基礎(chǔ)表A,如果存在,就不需要操作。使用在線重定義的一些限制條件:(1) There must be enough space to hold two copies of the table.(2) Primary key columns cannot be modified.(3) Tables must have primary keys.(4) Redefinition must be done within the same schema.(5) New columns added cannot be made NOT NULL until after the redefinition operation.(6) Tables cannot contain LONGs, BFILEs or User Defined Types.(7) Clustered tables cannot be redefined.(8) Tables in the SYS or SYSTEM schema cannot be redefined.(9) Tables with materialized view logs or materialized views defined on them cannot be redefined.(10) Horizontal sub setting of data cannot be performed during the redefinition.在Oracle 版本下,在線重定義可能會(huì)遇到如下bug:Bug[IDUsingExistingTo而且,可以在切換前進(jìn)行相應(yīng)的授權(quán)并建立各種約束,可以做到切換完成后不再需要任何額外的管理操作。只在切換的瞬間鎖表,具有很高的可用性。00:00:00SQL通過(guò)這個(gè)測(cè)試可以清楚,如果插入的數(shù)據(jù)不滿足分區(qū)規(guī)則,會(huì)報(bào)ORA14400錯(cuò)誤。999999IDwherefromselect會(huì)話已更改。yyyymmddsetalterTIMEid=999999。p_dba*SQL))。,39。values(999999,to_date(39。into))*第 1 行出現(xiàn)錯(cuò)誤:ORA14400: 插入的分區(qū)關(guān)鍵字未映射到任何分區(qū)SQL,39。values(999999,to_date(39。into))。,39。values(999999,to_date(39。into 現(xiàn)在我來(lái)插入一條不滿足規(guī)則的數(shù)據(jù),看結(jié)果:SQL在這里我們看一個(gè)問(wèn)題,一般情況下,我們?cè)趧?chuàng)建分區(qū)表的時(shí)候,都會(huì)有一個(gè)其他分區(qū),用來(lái)存放不匹配