您好,登录后才能下订单哦!
本篇内容主要讲解“DM7,DM8和ORACLE中对分区split的区别是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“DM7,DM8和ORACLE中对分区split的区别是什么”吧!
在oracle中,我们可以通过如下的命令去split分区,可以保留原分区名。达梦7和达梦8不能保留原分区名,我们用如下的命令来进行测试:
oracle 11g:
CREATE TABLE HC.PARTITION_HB
( PID NUMBER NOT NULL ,
PITEM VARCHAR2(200),
PDATA DATE NOT NULL
)
PARTITION BY RANGE (PID)
(PARTITION PART_01 VALUES LESS THAN (5) ,
PARTITION PART_02 VALUES LESS THAN (10) ,
PARTITION PART_03 VALUES LESS THAN (20) ,
PARTITION PART_MAX VALUES LESS THAN (MAXVALUE) ) ;
BEGIN
FOR I IN 1..150 LOOP
INSERT INTO HC.PARTITION_HB VALUES(I,'AA'||I,sysdate);
COMMIT;
END LOOP;
END;
alter table hc.partition_hb SPLIT PARTITION part_max AT(150) INTO
(PARTITION PART_04,PARTITION PART_MAX);
select * from hc.partition_hb partition(part_max);
ALTER TABLE hc.partition_hb RENAME PARTITION part_max TO part_max1;
执行成功,可以用rename来重命名分区
---------------------------------------------------------------------------------
DM7 中:
create user hc identified by dameng123;
grant dba to hc;
CREATE TABLE HC.PARTITION_HB
( PID NUMBER NOT NULL ENABLE,
PITEM VARCHAR2(200),
PDATA DATE NOT NULL ENABLE
)
PARTITION BY RANGE (PID)
(PARTITION PART_01 VALUES LESS THAN (5) ,
PARTITION PART_02 VALUES LESS THAN (10) ,
PARTITION PART_03 VALUES LESS THAN (20) ,
PARTITION PART_MAX VALUES LESS THAN (MAXVALUE) ) ;
BEGIN
FOR I IN 1..150 LOOP
INSERT INTO HC.PARTITION_HB VALUES(I,'AA'||I,sysdate);
COMMIT;
END LOOP;
END;
select count(1) from hc.partition_hb partition(part_max);
alTer table hc.partition_hb SPLIT PARTITION part_max AT(150) INTO
(PARTITION PART_04,PARTITION PART_MAX1);
ALTER TABLE hc.partition_hb RENAME PARTITION part_max1 TO part_max;
[执行语句1]:
ALTER TABLE hc.partition_hb RENAME PARTITION part_max1 TO part_max;
执行失败(语句1)
第 1 行, 第 74 列[PARTITION]附近出现错误[-2007]:
语法分析出错
可以看到达梦7不支持rename,也不支持对象重名,也就是split后的分区在原始表中不能有,故只能改成part_max1;
------------------------------------------------------------------------------------------------------------------------------
dm8:
[root@dm8os tool]# ./disql sysdba/dameng123
disql V8
SQL> show user;
未知的 SHOW 选项 user
SQL> select user;
未连接
SQL> conn sysdba/dameng123
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间: 4.958(毫秒)
SQL> create user hc identified by dameng123;
grant dba to hc;
create user hc identified by dameng123;
[-510]:系统处于MOUNT状态.
已用时间: 21.042(毫秒). 执行号:0.
SQL> grant dba to hc;
[-510]:系统处于MOUNT状态.
已用时间: 2.532(毫秒). 执行号:0.
SQL>
SQL> CREATE TABLE HC.PARTITION_HB
2 ( PID NUMBER NOT NULL ENABLE,
3 PITEM VARCHAR2(200),
4 PDATA DATE NOT NULL ENABLE
5 )
6 PARTITION BY RANGE (PID)
7 (PARTITION PART_01 VALUES LESS THAN (5) ,
8 PARTITION PART_02 VALUES LESS THAN (10) ,
9 PARTITION PART_03 VALUES LESS THAN (20) ,
10 PARTITION PART_MAX VALUES LESS THAN (MAXVALUE) ) ;
CREATE TABLE HC.PARTITION_HB
( PID NUMBER NOT NULL ENABLE,
PITEM VARCHAR2(200),
PDATA DATE NOT NULL ENABLE
)
PARTITION BY RANGE (PID)
(PARTITION PART_01 VALUES LESS THAN (5) ,
PARTITION PART_02 VALUES LESS THAN (10) ,
PARTITION PART_03 VALUES LESS THAN (20) ,
PARTITION PART_MAX VALUES LESS THAN (MAXVALUE) ) ;
[-510]:系统处于MOUNT状态.
已用时间: 3.614(毫秒). 执行号:0.
SQL> alter database open;
操作已执行
已用时间: 00:00:01.924. 执行号:0.
SQL> create user hc identified by dameng123;
create user hc identified by dameng123;
第1 行附近出现错误[-2124]:对象[HC]已存在.
已用时间: 1.310(毫秒). 执行号:0.
SQL> grant dba to hc;
操作已执行
已用时间: 11.131(毫秒). 执行号:4.
SQL>
SQL> CREATE TABLE HC.PARTITION_HB
2 ( PID NUMBER NOT NULL ENABLE,
3 PITEM VARCHAR2(200),
4 PDATA DATE NOT NULL ENABLE
5 )
6 PARTITION BY RANGE (PID)
7 (PARTITION PART_01 VALUES LESS THAN (5) ,
8 PARTITION PART_02 VALUES LESS THAN (10) ,
9 PARTITION PART_03 VALUES LESS THAN (20) ,
10 PARTITION PART_MAX VALUES LESS THAN (MAXVALUE) ) ;
操作已执行
已用时间: 28.160(毫秒). 执行号:5.
SQL>
2 BEGIN
3 FOR I IN 1..150 LOOP
4 INSERT INTO HC.PARTITION_HB VALUES(I,'AA'||I,sysdate);
5 COMMIT;
6 END LOOP;
7 END;
8 /
DMSQL 过程已成功完成
已用时间: 257.421(毫秒). 执行号:6.
SQL> select count(1) from hc.partition_hb partition(part_max);
行号 COUNT(1)
---------- --------------------
1 131
已用时间: 2.695(毫秒). 执行号:7.
SQL> alTer table hc.partition_hb SPLIT PARTITION part_max AT(150) INTO
2 (PARTITION PART_04,PARTITION PART_MAX);
alTer table hc.partition_hb SPLIT PARTITION part_max AT(150) INTO
(PARTITION PART_04,PARTITION PART_MAX);
第2 行附近出现错误[-2622]:分区名与数据库对象名称冲突.
已用时间: 0.757(毫秒). 执行号:0.
SQL> alTer table hc.partition_hb SPLIT PARTITION part_max AT(150) INTO
2 (PARTITION PART_04,PARTITION PART_MAX1);
操作已执行
已用时间: 90.611(毫秒). 执行号:8.
SQL> ALTER TABLE hc.partition_hb RENAME PARTITION part_max1 TO part_max;
操作已执行
已用时间: 117.870(毫秒). 执行号:9.
SQL>
到此,相信大家对“DM7,DM8和ORACLE中对分区split的区别是什么”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。