今天系统遇到问题,Oracle数据访问越来越慢,查明细表,400w数据,当然距离大数量还查很多,但是对于我们系统查询已经很慢了,开始着手分区分表操作;
网上学习,oracle分区sql如下:
-- Create table
create table FIN_ACCOUNT_AR_EMP2
(
id VARCHAR2(32) not null,
ori_type VARCHAR2(10),
create_type VARCHAR2(10),
status VARCHAR2(500),
operater VARCHAR2(32),
create_time TIMESTAMP(6),
update_time TIMESTAMP(6),
branch_id VARCHAR2(32),
offset_id VARCHAR2(32),
be_offset_id VARCHAR2(32),
operate_time VARCHAR2(50),
is_collection VARCHAR2(32),
is_import VARCHAR2(32)
)
PARTITION BY RANGE (operate_time) INTERVAL (numtoyminterval(1, 'month'))
(partition FIN_ACCOUNT_AR_EMP0 values less than(to_date('2019-08-01', 'yyyy-mm-dd')));
(partition FIN_ACCOUNT_AR_EMP2 values less than(to_date('2019-09-01', 'yyyy-mm-dd')));
(partition FIN_ACCOUNT_AR_EMP3 values less than(to_date('2019-10-01', 'yyyy-mm-dd')));
(partition FIN_ACCOUNT_AR_EMP4 values less than(to_date('2019-11-01', 'yyyy-mm-dd')));
(partition FIN_ACCOUNT_AR_EMP5 values less than(to_date('2019-12-01', 'yyyy-mm-dd')));
(partition FIN_ACCOUNT_AR_EMP6 values less than(to_date('2020-01-01', 'yyyy-mm-dd')));
(partition FIN_ACCOUNT_AR_EMP7 values less than(to_date('2020-02-01', 'yyyy-mm-dd')));
我在测试环境,按照一个月进行分区;
但是提示错误,不支持分区:oracle未启用Partintioning功能;
执行如下sql:SELECT VALUE FROM V$OPTION WHERE UPPER(PARAMETER)= 'PARTITIONING ';
TRUE --[说明当前 Oracle 版本支持分区功能] 如果这个参数值时false,则说明当前Oracle版本不支持分区功能。
查询安装的oracle版本:select * from v$version;
测试环境安装的是标准表,不支持分区。。。只能卸载重新安装企业版,只有企业版支持oracle分区;
补充:
SELECT segment_name AS TABLENAME,round(BYTES/1024/1024,2) FROM user_segments;
上面sql,查询该用户下所有表占的空间大小,单位为M;