oracle11g 分区表的5种类型,oracle11g中一个新的分区方式

interval分区,和范围分区类似,不过是自动按照范围分配。

oracle中原有的几个分区:hash分区、范围分区、列表分区和混合分区。

今天碰到一个问题:

Hi Ming,

As discussed with you over chatwe're testing an Oracle 11g feature called

Interval Partitioning. The table partitions are fine and seems to be working as

expected, the issue is in the local index when new data is added after the

index is created. I've provided some scripts to demonstrate:

-- create sample table on daily interval-hash partition

and spread to 4 tablespaces create table test_int_part

( cust_idnumber

, time_iddate

)

partition by range (time_id) interval (numtodsinterval(1,

'DAY')) store in (BIGFILE_DATA01, BIGFILE_DATA02, BIGFILE_DATA03,

BIGFILE_DATA04) subpartition by hash (cust_id) subpartitions 4 store in

(BIGFILE_DATA01, BIGFILE_DATA02, BIGFILE_DATA03, BIGFILE_DATA04) ( partition

oct31_2011 values less than (to_date('01-NOV-2011 00:00:00', 'DD-MON-YYYY

HH24:MI:SS')) tablespace BIGFILE_DATA01 ) parallel;

-- insert sample data

declare

dt date :=

to_date('31-OCT-2011 03:23:10', 'DD-MON-YYYY HH24:MI:SS'); begin

for i in 1 .. 7

loop

for j in 1 ..

10000 loop

insert into

test_int_part (time_id, cust_id) values (dt, trunc(dbms_random.value(1,9)) *

100);

end loop;

commit;

dt := dt + 1;

end loop;

end;

/

-- All good at this point, partitions seems to be going

to the right tbs create index test_int_part_idx on test_int_part (time_id,

cust_id) local store in (BIGFILE_INDEX01, BIGFILE_INDEX02, BIGFILE_INDEX03,

BIGFILE_INDEX04)

select * from user_tab_partitions where table_name like

'TEST_INT_PART';

select * from user_tab_subpartitions where table_name

like 'TEST_INT_PART';

select * from user_ind_partitions where index_name like

'TEST_INT_PART_IDX';

select * from user_ind_subpartitions where index_name

like 'TEST_INT_PART_IDX';

select min(time_id), max(time_id) from test_int_part;

-- ORA-14523: Cannot co-locate [sub]partition of local

indexwith table [sub]partition because

local index block size [16384] does not match table block size [8192] insert

into test_int_part (time_id, cust_id) values (to_date('07-NOV-2011 03:23:10',

'DD-MON-YYYY HH24:MI:SS'), 200);

I suspect the new index entry is being added to the data

tablespace, not in the index tablespace.

解决方法:

我没有自己试,就把解决方法给他发过去了。

ORA-14523: Cannot co-locate [sub]partition of string

string with table [sub]partition because string block size [string] does not

match table block size [string]

Cause: A DDL statement was issued that would require a

partition/subpartition of a local index/LOB column to be co-located with the

corresponding partition/subpartition of the base table. However, this is not

possible because the block sizes of the table and the LOB column/local index

are different.

Action: Either (1) Specify an object-level default

tablespace (or partition-level default tablespace for the appropriate

partition, if composite partitioning is used) for the partitioned local

index/LOB column and then retry the DDL command, OR (2) Ensure that tablespaces

of the correct block size are specified for all new partitions/subpartitions

being created. Also ensure that neither of TABLESPACE DEFAULT and STORE IN (DEFAULT)

is specified for a local index whose block size does not match that of the base

table.[@more@]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A: 创建分区表的语法如下: ``` CREATE TABLE table_name (column1 datatype1, column2 datatype2,...) PARTITION BY RANGE (column_name) ( PARTITION partition_name1 VALUES LESS THAN (value1), PARTITION partition_name2 VALUES LESS THAN (value2), PARTITION partition_name3 VALUES LESS THAN (MAXVALUE) ); ``` 其,table_name 是表名,column1、column2 是列名和数据类,column_name 是用于分区的列名。 PARTITION BY RANGE 是分区方式,指定分区键,这里使用了 RANGE 分区方式分区名称和分区边界值在 VALUES LESS THAN 之后指定,分区边界值是指定范围内的最大或最小值。 例如,以下示例将创建一个名为 sales 的表,该表使用 sales_date 列作为分区键,并在 2019 年前、2019 年、2020 年和 2021 年之后分成四个分区,每个分区使用不同的表空间: ``` CREATE TABLE sales (id INT PRIMARY KEY, sales_date DATE, sales_amount NUMBER(10,2)) PARTITION BY RANGE (sales_date) ( PARTITION sales_q1_2019 VALUES LESS THAN (TO_DATE('01-APR-2019', 'DD-MON-YYYY')), PARTITION sales_q2_2019 VALUES LESS THAN (TO_DATE('01-JUL-2019', 'DD-MON-YYYY')), PARTITION sales_q3_2019 VALUES LESS THAN (TO_DATE('01-OCT-2019', 'DD-MON-YYYY')), PARTITION sales_q4_2019 VALUES LESS THAN (TO_DATE('01-JAN-2020', 'DD-MON-YYYY')), PARTITION sales_q1_2020 VALUES LESS THAN (TO_DATE('01-APR-2020', 'DD-MON-YYYY')), PARTITION sales_q2_2020 VALUES LESS THAN (TO_DATE('01-JUL-2020', 'DD-MON-YYYY')), PARTITION sales_q3_2020 VALUES LESS THAN (TO_DATE('01-OCT-2020', 'DD-MON-YYYY')), PARTITION sales_q4_2020 VALUES LESS THAN (TO_DATE('01-JAN-2021', 'DD-MON-YYYY')), PARTITION sales_future VALUES LESS THAN (MAXVALUE) ) TABLESPACE sales_ts; ``` 在此示例,我们根据销售日期对表进行了分区,并提交了三个月和四个季度的数据,每个季度使用了不同的分区。 最后一个分区是用于未来销售数据的。 使用 TABLESPACE 关键字指定为每个分区使用不同的表空间。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值