【发布时间】:2014-07-02 06:55:34
【问题描述】:
我必须进行数据库分区测试,我现在在表中创建了间隔分区,如果我移动时钟进行测试,没有创建新分区?它仍然显示旧分区。知道如何解决这个问题吗? oracle数据库中如何判断表是范围分区还是区间分区?
使用以下代码进行分区删除后,我将间隔分区表作为范围分区。
SQL> create or replace procedure partition_delete(var in int) AS
2 v Date := SYSDATE;
3 i number;
4 occurance number;
5 l_drop_sql varchar2(2000);
6 BEGIN
7 execute immediate ' alter table "sch1"."AUDITS" set interval ()';
8 execute immediate ' alter table "sch1"."ALERTAUDITS" set interval ()';
9 -- select the tables that starts with either A or L having cfcc as table owner
10 for curs in ( select table_owner,table_name,partition_name,high_value from dba_tab_partitions where table_owner='owner' and REGEXP_LIKE (table_name,'^(A|L)')) LOOP
11 EXECUTE IMMEDIATE 'SELECT ' || curs.high_Value || ' FROM dual' INTO v; -- Conversion of high_value from long to date
12 select round(SYSDATE - v) into i from dual; -- finding the difference between current date and partition creation date
13 select count(*) into occurance from dba_tab_partitions where table_name=curs.table_name; -- Finding the no of existing partitions to the particular table
14 -- occurance>1 indicates table having only one partition is not getting deleted
15 if i > var and occurance > 1 then
16 dbms_output.put_line('The no of days are '||i);
17 dbms_output.put_line('The table name and partition name are '||curs.table_name||'and'||curs.partition_name);
18 l_drop_sql :='alter table "'||curs.table_owner||'"."'||curs.table_name||'" drop partition '||curs.partition_name||' update global indexes';
19 dbms_output.put_line(l_drop_sql);
20 execute immediate l_drop_sql;
21 end if;
22 end LOOP;
23 execute immediate 'alter table "sch1"."AUDITS" set interval (NUMTOYMINTERVAL(1,''month''))';
24 execute immediate 'alter table "CFCC"."ALERTAUDITS" set interval (NUMTOYMINTERVAL(1,''month''))';
25 end;
26 /
程序已创建。
请帮帮我..
【问题讨论】:
-
如何移动时钟进行测试?
-
请给我们看一些代码,CREATE TABLES,SELECTs 你已经完成了等等......
-
感谢您的代码。因此,程序运行,并打印出“ALTER TABLE ... DROP PARTITION...”,但分区仍然存在?
-
嗨。执行后我得到其他表的区间字段为否,应该是对吗?