这个可以根据自己的需要来设定,如果确实对数据有严格的要求,甚至可以要求不加入默认的分区。
以下的脚本会去"扫描"分区的信息,如果检测到没有默认的分区,就会生成对应的脚本。
可以根据自己的情况来决定是否需要加入分区。
sqlplus -s $1/$2@$SH_DB_SID < set head off
set pages 100
set linesize 200
/* bad performance
select name,Count(*)from user_part_key_columns where object_type=' rel="nofollow"TABLE' and name in
(
select table_name from user_tables where partitioned='YES'
minus
(select distinct table_name
from user_tab_partitions where partition_name like '%MAX%'
)
)
group by name;
*/
select 'alter table '||table_name||' add partition PMAXVALUE values less than ('||
decode(col_count, 1, 'MAXVALUE',
2,'MAXVALUE,MAXVALUE',
3,'MAXVALUE,MAXVALUE,MAXVALUE',
4,'MAXVALUE,MAXVALUE,MAXVALUE,MAXVALUE','partition out of range')||');'
from
(
(
select t1.table_name,count(t2.name) col_count from user_tables t1,user_part_key_columns t2
where t1.partitioned='YES'
and t1.table_name=t2.name
and t2.object_type='TABLE'
group by t1.table_name
)
minus
(
select t2.name table_name,count(t2.name)col_count
from user_tab_partitions t1,user_part_key_columns t2
where t1.partition_name like '%MAX%'
and t1.table_name=t2.name
and t2.object_type='TABLE'
group by t2.name
)
)
/
EOF
exit
简单运行一下,可以看到有一些分区表是灭有默认的分区的。可以根据自己的情况来定夺。
[ora11g@rac1 dbm_lite]$ ksh getmaxpar.sh system oracle
alter table LOGMNRC_GSBA add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNRC_GSII add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNRC_GTCS add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNRC_GTLO add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNRP_CTAS_PART_MAP add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_ATTRCOL$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_ATTRIBUTE$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_CCOL$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_CDEF$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_COL$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_COLTYPE$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_DICTIONARY$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_DICTSTATE$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_ENC$ add partition PMAXVALUE values less than (MAXVALUE);
alter table LOGMNR_ICOL$ add partition PMAXVALUE values less than (MAXVALUE);
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23718752/viewspace-1263626/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23718752/viewspace-1263626/