oracle 分区表,分区索引

1、分区表

一)范围分区

SCOTT@orcl#select tablespace_name from dba_tablespaces;TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
UNDOTBS2
VPN_HUADAN
TEST1
TEMP01
TEMP001
BIGTABLESPACE已选择11行。已用时间:  00: 00: 01.90
SCOTT@orcl#col name for a80
SCOTT@orcl#select name from v$datafile;NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/ORCL/datafile/o1_mf_system_8no75lqw_.dbf
/opt/oracle/oradata/ORCL/datafile/o1_mf_sysaux_8no736vh_.dbf
/opt/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_8no736w0_.dbf
/opt/oracle/oradata/ORCL/datafile/o1_mf_users_8no75m69_.dbf
/opt/oracle/oradata/ORCL/datafile/huadan
/opt/oracle/oradata/sysaux_add.dbf
/opt/oracle/oradata/system_add.dbf
/opt/oracle/oradata/test1.dbf
/opt/oracle/oradata/ORCL/datafile/bigtablespace.dbf
/opt/oracle/oradata/ORCL/datafile/undotbs02.dbf已选择10行。已用时间:  00: 00: 00.59
SCOTT@orcl#create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m2  autoextend on next 2M maxsize 100M 3  extent management local autoallocate4  segment space management auto;
create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m
*
第 1 行出现错误:
ORA-19502: 文件 "/opt/oracle/oradata/ORCL/datafile/test2.dbf", 块编号 2944 (块大小=8192) 上出现写入错误
ORA-27072: 文件 I/O 错误
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4
Additional information: 2944
Additional information: 831488已用时间:  00: 00: 03.08
SCOTT@orcl#!df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              18G   18G   24M 100% /
udev                  8.0G  172K  8.0G   1% /dev
shmfs                 2.0G  519M  1.5G  26% /dev/shm
/dev/mapper/vgscp-lvscu2.0G   33M  2.0G   2% /tellin
df: `/tellinshare/sms': Permission denied
.host:/               180G  177G  3.3G  99% /mnt/hgfsSCOTT@orcl#l1  create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m2  autoextend on next 2M maxsize 100M3  extent management local autoallocate4* segment space management auto
SCOTT@orcl#save p.sql replace
已写入 file ././p.sql
SCOTT@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
ramoracle@oracle:~> ramn target /
-bash: ramn: command not found
oracle@oracle:~> rman target /恢复管理器: Release 11.1.0.6.0 - Production on 星期六 5月 18 18:23:14 2013Copyright (c) 1982, 2007, Oracle.  All rights reserved.连接到目标数据库: ORCL (DBID=1307032085)RMAN> list backup of files;RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: 分析输入命令时出错
RMAN-01009: 语法错误: 找到 "files": 应为: "archivelog, controlfile, database, datafile, foreign, spfile, tablespace" 中的一个
RMAN-01007: 在第 1 行第 16 列, 文件: standard inputRMAN> list backup by file;使用目标数据库控制文件替代恢复目录RMAN> exit恢复管理器完成。
oracle@oracle:~> sqlplus "/as sysdba"SQL*Plus: Release 11.1.0.6.0 - Production on 星期六 5月 18 18:25:11 2013Copyright (c) 1982, 2007, Oracle.  All rights reserved.连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@orcl#get p.sql1  create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m2  autoextend on next 2M maxsize 100M3  extent management local autoallocate4* segment space management auto
SYS@orcl#! vi p.sql
create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m
autoextend on next 2M maxsize 100M
extent management local autoallocate
segment space management auto
/
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~SYS@orcl#get p.sql1  create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m2  autoextend on next 2M maxsize 100M3  extent management local autoallocate4* segment space management auto
SYS@orcl#r1  create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m2  autoextend on next 2M maxsize 100M3  extent management local autoallocate4* segment space management auto表空间已创建。SYS@orcl#11* create tablespace test2 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m
SYS@orcl#c /test2/test31* create tablespace test3 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m
SYS@orcl#r1  create tablespace test3 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m2  autoextend on next 2M maxsize 100M3  extent management local autoallocate4* segment space management auto
create tablespace test3 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m
*
第 1 行出现错误:
ORA-01537: 无法添加文件 '/opt/oracle/oradata/ORCL/datafile/test2.dbf' -
该文件已是数据库的一部分SYS@orcl#11* create tablespace test3 datafile '/opt/oracle/oradata/ORCL/datafile/test2.dbf' size 50m
SYS@orcl#c /test2/test31* create tablespace test3 datafile '/opt/oracle/oradata/ORCL/datafile/test3.dbf' size 50m
SYS@orcl#r1  create tablespace test3 datafile '/opt/oracle/oradata/ORCL/datafile/test3.dbf' size 50m2  autoextend on next 2M maxsize 100M3  extent management local autoallocate4* segment space management auto表空间已创建。SYS@orcl#conn scott/root
已连接。
SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(8),4  subject varchar2(20),5  score number 6  )7  partition by range(score)8  (9  partition part1 values less than(60) tablespace test1,10  partition part2 values less than(80) tablespace test2,11  partition part3 values less than(maxvalue) tablespace test312  );表已创建。SCOTT@orcl#insert into archivement values(1,'rhys1','C#',40);
insert into archivement values(1,'rhys1','C#',40)*
第 1 行出现错误:
ORA-00942: 表或视图不存在SCOTT@orcl#insert into achivement values(1,'rhys1','c#',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',60);已创建 1 行。SCOTT@orcl#insert into achivement values(3,'rhys3','c++',70);已创建 1 行。SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',120);已创建 1 行。SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement ;  ID NAME             SUBJECT                                       SCORE
---------- ---------------- ---------------------------------------- ----------1 rhys1            c#                                               402 rhys2            java                                             603 rhys3            c++                                              704 rhys4            oracle                                          120SCOTT@orcl#select * from achivement partition(part1);ID NAME             SUBJECT                                       SCORE
---------- ---------------- ---------------------------------------- ----------1 rhys1            c#                                               40SCOTT@orcl#select * from achivement partition(part2);ID NAME             SUBJECT                                       SCORE
---------- ---------------- ---------------------------------------- ----------2 rhys2            java                                             603 rhys3            c++                                              70SCOTT@orcl#select * from achivement partition(part3);ID NAME             SUBJECT                                       SCORE
---------- ---------------- ---------------------------------------- ----------4 rhys4            oracle                                          120

二)散列分区

SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#
SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(10),5  score number6  )7  partition by hash(id)8  (9  partition part1 tablespace test1,10  partition part2 tablespace test2,11  partition part3 tablespace test312  );表已创建。SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#insert into achivement values(1,'rhys1','c#',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',60);已创建 1 行。SCOTT@orcl#insert into achivement values(3,'rhys3','c++',70);已创建 1 行。SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',120);已创建 1 行。SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement partition(part1);未选定行SCOTT@orcl#select * from achivement;ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           403 rhys3                c++                          704 rhys4                oracle                      1202 rhys2                java                         60SCOTT@orcl#select * from achivement partition(part2);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           403 rhys3                c++                          704 rhys4                oracle                      120SCOTT@orcl#select * from achivement partition(part3);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------2 rhys2                java                         60SCOTT@orcl#insert into achivement values(5,'xiaohai','linux',120);已创建 1 行。SCOTT@orcl#insert into achivement values(6,'xiaohai2','unix',100);已创建 1 行。SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement partition(part1);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------6 xiaohai2             unix                        100SCOTT@orcl#select * from achivement partition(part2);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           403 rhys3                c++                          704 rhys4                oracle                      120SCOTT@orcl#select * from achivement partition(part3);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------2 rhys2                java                         605 xiaohai              linux                       120

三)列表分区

SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(10),5  score number6  )7  partition by list(subject)8  (9  partition part1 values('c#','c++') tablespace test1,10  partition part2 values('oracle','linux','unix') tablespace test2,11  partition part3 values('java') tablespace test312  );表已创建。SCOTT@orcl#insert into achivement values(1,'rhys1','c#',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',60);已创建 1 行。SCOTT@orcl#insert into achivement values(3,'rhys3','c++',70);已创建 1 行。SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',120);
insert into achivement values(5,'xiaohai','linux',120);
insert into achivement values(6,'xiaohai2','unix',100);
已创建 1 行。SCOTT@orcl#
已创建 1 行。SCOTT@orcl#commit2  ;
insert into achivement values(6,'xiaohai2','unix',100);commit*
第 1 行出现错误:
ORA-00911: 无效字符SCOTT@orcl#insert into achivement values(6,'xiaohai2','unix',100);已创建 1 行。SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement;ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           403 rhys3                c++                          704 rhys4                oracle                      1205 xiaohai              linux                       1206 xiaohai2             unix                        1002 rhys2                java                         60已选择6行。SCOTT@orcl#select * from achivement partition(part1);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           403 rhys3                c++                          70SCOTT@orcl#select * from achivement partition(part2);
select * from achivement partition(part3);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------4 rhys4                oracle                      1205 xiaohai              linux                       1206 xiaohai2             unix                        100SCOTT@orcl#ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------2 rhys2                java                         60SCOTT@orcl#insert into achivement values(6,'xiaohai2','aix',100);
insert into achivement values(6,'xiaohai2','aix',100)*
第 1 行出现错误:
ORA-14400: 插入的分区关键字未映射到任何分区SCOTT@orcl#
SCOTT@orcl#注意了!!!!
SP2-0734: 未知的命令开头 "注意了!!..." - 忽略了剩余的行。
SCOTT@orcl#

四)组合范围散列分区

oracle@oracle:~> sqlplus "/as sysdba"SQL*Plus: Release 11.1.0.6.0 - Production on 星期六 5月 18 20:19:18 2013Copyright (c) 1982, 2007, Oracle.  All rights reserved.连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@orcl#conn scott/root
已连接。
SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(10),5  score number)6  partition by range(score)7  subpartition by hash(id)8  subpartition 2 store in(test1,test2)9  (10  partition part1 values less than(60),11  partition part2 values less than(80),12  partition part3 values less than(120)13  );
subpartition 2 store in(test1,test2)*
第 8 行出现错误:
ORA-00905: 缺失关键字SCOTT@orcl#l1  create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(10),5  score number)6  partition by range(score)7  subpartition by hash(id)8  subpartition 2 store in(test1,test2)9  (10  partition part1 values less than(60),11  partition part2 values less than(80),12  partition part3 values less than(120)13* )
SCOTT@orcl#88* subpartition 2 store in(test1,test2)
SCOTT@orcl#c /subpartition/subpartitions8* subpartitions 2 store in(test1,test2)
SCOTT@orcl#r1  create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(10),5  score number)6  partition by range(score)7  subpartition by hash(id)8  subpartitions 2 store in(test1,test2)9  (10  partition part1 values less than(60),11  partition part2 values less than(80),12  partition part3 values less than(120)13* )表已创建。SCOTT@orcl#insert into achivement values(1,'rhys1','c#',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',60);
insert into achivement values(3,'rhys3','c++',70);insert into achivement values(4,'rhys4','oracle',120);
已创建 1 行。SCOTT@orcl#insert into achivement values(5,'xiaohai','linux',120);已创建 1 行。SCOTT@orcl#已创建 1 行。SCOTT@orcl#select * from achivement;ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           402 rhys2                java                         603 rhys3                c++                          706 xiaohai2             unix                        100SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',120);
insert into achivement values(4,'rhys4','oracle',120)*
第 1 行出现错误:
ORA-14400: 插入的分区关键字未映射到任何分区SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',110);已创建 1 行。SCOTT@orcl#insert into achivement values(5,'xiaohai','linux',110);已创建 1 行。SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement partition(part1);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           40SCOTT@orcl#select * from achivement partition(part2);
select * from achivement partition(part3);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------2 rhys2                java                         603 rhys3                c++                          70SCOTT@orcl#ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------6 xiaohai2             unix                        1005 xiaohai              linux                       1104 rhys4                oracle                      110SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#

五)组合范围列表分区

SCOTT@orcl#
SCOTT@orcl#drop table achivement;
表已删除。SCOTT@orcl#get p.sql1  create table achivement(2  id number,3  name varchar2(10),4  subject varchar2(10),5  score number ,6  constraint primary_key primary key(id)7  )8  partition by range(score)9  subpartition by hash(id)10  subpartitions 2 store in (test1,test3)11  (12  partition part1 values less than(60) tablespace test1,13  partition part2 values less than(80) tablespace test2,14  partition part3 values less than(130) tablespace test315* )
SCOTT@orcl#r1  create table achivement(2  id number,3  name varchar2(10),4  subject varchar2(10),5  score number ,6  constraint primary_key primary key(id)7  )8  partition by range(score)9  subpartition by hash(id)10  subpartitions 2 store in (test1,test3)11  (12  partition part1 values less than(60) tablespace test1,13  partition part2 values less than(80) tablespace test2,14  partition part3 values less than(130) tablespace test315* )表已创建。SCOTT@orcl#insert into achivement values(1,'rhys1','c#',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',60);已创建 1 行。SCOTT@orcl#insert into achivement values(3,'rhys3','c++',70);已创建 1 行。SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',110);已创建 1 行。SCOTT@orcl#insert into achivement values(5,'xiaohai','linux',110);已创建 1 行。SCOTT@orcl#insert into achivement values(6,'xiaohai2','unix',100);已创建 1 行。SCOTT@orcl#
SCOTT@orcl#select * from achivement partition(part1);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------1 rhys1                c#                           40SCOTT@orcl#select * from achivement partition(part2);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------2 rhys2                java                         603 rhys3                c++                          70SCOTT@orcl#select * from achivement partition(part3);ID NAME                 SUBJECT                   SCORE
---------- -------------------- -------------------- ----------5 xiaohai              linux                       1106 xiaohai2             unix                        1004 rhys4                oracle                      110SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(20),5  score number not null6  )7  partition by range(score)8  subpartition by list(subject)9  (10  partition part1 values less than(60)11  (12  subpartition part1_1 values('java','c','asp.net') tablespace test1,13  subpartition part1_2 values('linux','unix') tablespace test1 14  )15  partition part2 values less than(80)16  (17  subpartition part2_1 values('oracle') tablespace test218  )19  );
partition part2 values less than(80)
*
第 15 行出现错误:
ORA-00907: 缺失右括号SCOTT@orcl#1414* )
SCOTT@orcl#append ,14* ),
SCOTT@orcl#r1  create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(20),5  score number not null6  )7  partition by range(score)8  subpartition by list(subject)9  (10  partition part1 values less than(60)11  (12  subpartition part1_1 values('java','c','asp.net') tablespace test1,13  subpartition part1_2 values('linux','unix') tablespace test114  ),15  partition part2 values less than(80)16  (17  subpartition part2_1 values('oracle') tablespace test218  )19* )表已创建。
SCOTT@orcl#get p.sql1  create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(20),5  score number not null6  )7  partition by range(score)8  subpartition by list(subject)9  (10  partition part1 values less than(60) tablespace test211  (12  subpartition part1_1 values('java','c','asp.net') tablespace test1,13  subpartition part1_2 values('linux','unix') tablespace test314  ),15  partition part2 values less than(80) tablespace test116  (17  subpartition part2_1 values('oracle') tablespace test218  )19* )
SCOTT@orcl#r1  create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(20),5  score number not null6  )7  partition by range(score)8  subpartition by list(subject)9  (10  partition part1 values less than(60) tablespace test211  (12  subpartition part1_1 values('java','c','asp.net') tablespace test1,13  subpartition part1_2 values('linux','unix') tablespace test314  ),15  partition part2 values less than(80) tablespace test116  (17  subpartition part2_1 values('oracle') tablespace test218  )19* )表已创建。SCOTT@orcl#
SCOTT@orcl#insert into achivement values(1,'rhys1','c',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',60);
insert into achivement values(2,'rhys2','java',60)*
第 1 行出现错误:
ORA-14400: 插入的分区关键字未映射到任何分区SCOTT@orcl#insert into achivement values(3,'rhys3','asp.net',70);
insert into achivement values(4,'rhys4','oracle',110);
insert into achivement values(5,'xiaohai','linux',110);
insert into achivement values(3,'rhys3','asp.net',70)*
第 1 行出现错误:
ORA-14400: 插入的分区关键字未映射到任何分区SCOTT@orcl#insert into achivement values(2,'rhys2','java',50);已创建 1 行。SCOTT@orcl#insert into achivement values(3,'rhys3','asp.net',50);已创建 1 行。SCOTT@orcl#insert into achivement values(5,'xiaohai','linux',40);已创建 1 行。SCOTT@orcl#insert into achivement values(6,'xiaohai2','unix',40);已创建 1 行。SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement;ID NAME                 SUBJECT
---------- -------------------- ----------------------------------------SCORE
----------1 rhys1                c402 rhys2                java503 rhys3                asp.net50ID NAME                 SUBJECT
---------- -------------------- ----------------------------------------SCORE
----------5 xiaohai              linux406 xiaohai2             unix40SCOTT@orcl#r1* select * from achivementID NAME                 SUBJECT
---------- -------------------- ----------------------------------------SCORE
----------1 rhys1                c402 rhys2                java503 rhys3                asp.net50ID NAME                 SUBJECT
---------- -------------------- ----------------------------------------SCORE
----------5 xiaohai              linux406 xiaohai2             unix40SCOTT@orcl#set linesize 200
SCOTT@orcl#r1* select * from achivementID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                402 rhys2                java                                             503 rhys3                asp.net                                          505 xiaohai              linux                                            406 xiaohai2             unix                                             40SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',70);已创建 1 行。SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement;ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                402 rhys2                java                                             503 rhys3                asp.net                                          505 xiaohai              linux                                            406 xiaohai2             unix                                             404 rhys4                oracle                                           70已选择6行。SCOTT@orcl#select * from achivement partition(part1);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                402 rhys2                java                                             503 rhys3                asp.net                                          505 xiaohai              linux                                            406 xiaohai2             unix                                             40SCOTT@orcl#select * from achivement partition(part1_1);
select * from achivement partition(part1_1)*
第 1 行出现错误:
ORA-02149: 指定的分区不存在SCOTT@orcl#select * from achivement subpartition(part1_1);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                402 rhys2                java                                             503 rhys3                asp.net                                          50SCOTT@orcl#select * from achivement subpartition(part1_2);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------5 xiaohai              linux                                            406 xiaohai2             unix                                             40SCOTT@orcl#select * from achivement partition(part2);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------4 rhys4                oracle                                           70SCOTT@orcl#select * from achivement subpartition(part2_1);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------4 rhys4                oracle                                           70

2、分区索引
一)部分分区索引

SCOTT@orcl#
SCOTT@orcl#drop index achivement_index;索引已删除。SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#create table achivement(2  id number,3  name varchar2(20),4  subject varchar2(20),5  score number6  )7  partition by range(score)8  (  9  partition part1 values less than(70) tablespace test1,10  partition part2 values less than(80) tablespace test2,11  partition part3 values less than(maxvalue) tablespace test3 12  );表已创建。SCOTT@orcl#create index part_index2  on achivement(id) 3  locate4  (5  partition index1 tablespace test1,6  partition index2 tablespace test2,7  partition index3 tablespace test3 8  );
locate
*
第 3 行出现错误:
ORA-02158: 无效的 CREATE INDEX 选项SCOTT@orcl#3 3* locate
SCOTT@orcl#create index part_index2  on achivement(id)3  local4  (5  partition index1 tablespace test1,6  partition index2 tablespace test2,7  partition index3 tablespace test38  );索引已创建。SCOTT@orcl#

二)全局分区索引

SCOTT@orcl#drop index part_index;索引已删除。SCOTT@orcl#create index global_index2  on achivement(id)3  global partition by range(id)   4  (5  partition index1 values less than (10000) tablespace test1,6  partition index2 values less than (20001) tablespace test2,7  partition index3 values less than(maxvalue) tablespace test38  );索引已创建。SCOTT@orcl#drop index global_index;索引已删除。

三)全局非分区索引

SCOTT@orcl#create index no_part_global_index on achivement(id);索引已创建。SCOTT@orcl#drop index no_part_global_index;索引已删除。SCOTT@orcl#select a.table_name,a.partitioning_type,b.object_type,b.column_name 2  from user_part_tables a ,user_part_key_columns b where a.table_name=b.name;TABLE_NAME                                                   PARTITIONING_TYPE  OBJECT_TYP
------------------------------------------------------------ ------------------ ----------
COLUMN_NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ACHIVEMENT                                                   RANGE              TABLE
SCOREBIN$3P4ccOeGW/vgQKjABIkDGQ==$0                               LIST               TABLE
SUBJECTBIN$3P4ccOeJW/vgQKjABIkDGQ==$0                               RANGE              TABLE
SCORETABLE_NAME                                                   PARTITIONING_TYPE  OBJECT_TYP
------------------------------------------------------------ ------------------ ----------
COLUMN_NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BIN$3P4ccOeMW/vgQKjABIkDGQ==$0                               RANGE              TABLE
SCOREBIN$3P4ccOeQW/vgQKjABIkDGQ==$0                               RANGE              TABLE
SCOREBIN$3P4ccOeUW/vgQKjABIkDGQ==$0                               RANGE              TABLE
SCORETABLE_NAME                                                   PARTITIONING_TYPE  OBJECT_TYP
------------------------------------------------------------ ------------------ ----------
COLUMN_NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BIN$3Py1XNsEZTXgQKjABIl/WQ==$0                               RANGE              TABLE
SCOREBIN$3Py1XNsHZTXgQKjABIl/WQ==$0                               HASH               TABLE
ID已选择8行。SCOTT@orcl#col table_name for a20
SCOTT@orcl#col column_name for a30
SCOTT@orcl#r1  select a.table_name,a.partitioning_type,b.object_type,b.column_name2* from user_part_tables a ,user_part_key_columns b where a.table_name=b.nameTABLE_NAME           PARTITIONING_TYPE  OBJECT_TYP COLUMN_NAME
-------------------- ------------------ ---------- ------------------------------
ACHIVEMENT           RANGE              TABLE      SCORE
BIN$3P4ccOeGW/vgQKjA LIST               TABLE      SUBJECT
BIkDGQ==$0BIN$3P4ccOeJW/vgQKjA RANGE              TABLE      SCORE
BIkDGQ==$0BIN$3P4ccOeMW/vgQKjA RANGE              TABLE      SCORE
BIkDGQ==$0BIN$3P4ccOeQW/vgQKjA RANGE              TABLE      SCORETABLE_NAME           PARTITIONING_TYPE  OBJECT_TYP COLUMN_NAME
-------------------- ------------------ ---------- ------------------------------
BIkDGQ==$0BIN$3P4ccOeUW/vgQKjA RANGE              TABLE      SCORE
BIkDGQ==$0BIN$3Py1XNsEZTXgQKjA RANGE              TABLE      SCORE
BIl/WQ==$0BIN$3Py1XNsHZTXgQKjA HASH               TABLE      ID
BIl/WQ==$0已选择8行。SCOTT@orcl#
SCOTT@orcl#

3、管理分区表

SCOTT@orcl#alter table achivement add partition part4 values less than(150) tablespace test1;
alter table achivement add partition part4 values less than(150) tablespace test1*
第 1 行出现错误:
ORA-14074: 分区界限必须调整为高于最后一个分区界限SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#create table achivement(2  id number,3  name varchar2(10),4  subject varchar2(20),5  score number,6  constraint primary_key primary key(id)7  )8  partition by range (score)9  (10  partition part1 values less than(60) tabelspace test1,11  partition part2 values less than(80) tablespace test212  );
partition part1 values less than(60) tabelspace test1,*
第 10 行出现错误:
ORA-14020: 不能指定表分区的此物理属性SCOTT@orcl#1010* partition part1 values less than(60) tabelspace test1,
SCOTT@orcl#c /tabelspace/tablespace10* partition part1 values less than(60) tablespace test1,
SCOTT@orcl#r1  create table achivement(2  id number,3  name varchar2(10),4  subject varchar2(20),5  score number,6  constraint primary_key primary key(id)7  )8  partition by range (score)9  (10  partition part1 values less than(60) tablespace test1,11  partition part2 values less than(80) tablespace test212* )表已创建。SCOTT@orcl#alter table achivement add partition part4 values less than(120) tablespace test3;表已更改。SCOTT@orcl#alter table achivement add partition part5 values less than(180) tablespace test2;表已更改。SCOTT@orcl#alter table achivement    2  split partition part4 at(100)3  into4  (        5  partition part6 tablespace test2,6  partition part7 tablespace test37  );表已更改。SCOTT@orcl#alter table achivement2  split partition part5 at(150)3  into4  (5  partition part8 tablespace test1,6  partition part9 tablespace test37  );表已更改。SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(20),5  score number)6  partition by hash(id)7  (8  partition part1 tablespace test1,9  partition part2 tablespace test2,10  partition part3 tablespace test3 11  );表已创建。SCOTT@orcl#alter table achivement add partition part4 tablespace test1;表已更改。SCOTT@orcl#alter table achivement add partition part6 tablespace test2;表已更改。SCOTT@orcl#alter table achivement merge partitions part1,part2 into partition part3;
alter table achivement merge partitions part1,part2 into partition part3*
第 1 行出现错误:
ORA-14255: 未按范围, 列表, 组合范围或组合列表方法对表进行分区SCOTT@orcl#insert into achivement values(1,'rhys1','c',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',50);已创建 1 行。SCOTT@orcl#insert into achivement values(3,'rhys3','asp.net',50);已创建 1 行。SCOTT@orcl#insert into achivement values(4,'rhys4','oracle',70);已创建 1 行。SCOTT@orcl#insert into achivement values(5,'xiaohai','linux',40);已创建 1 行。SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#
SCOTT@orcl#commit;提交完成。SCOTT@orcl#select * from achivement partition(part1);未选定行SCOTT@orcl#select * from achivement partition(part2);未选定行SCOTT@orcl#select * from achivement partition(part3);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------2 rhys2                java                                             505 xiaohai              linux                                            40SCOTT@orcl#select * from achivement partition(part4);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                403 rhys3                asp.net                                          504 rhys4                oracle                                           70SCOTT@orcl#drop table achivement partition part4;
drop table achivement partition part4*
第 1 行出现错误:
ORA-00933: SQL 命令未正确结束SCOTT@orcl#alter table achivement drop partition part4;
alter table achivement drop partition part4*
第 1 行出现错误:
ORA-14255: 未按范围, 列表, 组合范围或组合列表方法对表进行分区SCOTT@orcl#drop table achivement;表已删除。SCOTT@orcl#create table achivement(2  id number primary key,3  name varchar2(10),4  subject varchar2(20),5  score number 6  )7  partition by list(subject)8  (9  partition part1 values('c','asp.net') tablespace test1,10  partition part2 values('java','oracle','linux') tablespace test2 11  );表已创建。SCOTT@orcl#alter table achivement add partition part3 values('unix') tablespace test2;表已更改。SCOTT@orcl#insert into achivement values(1,'rhys1','c',40);已创建 1 行。SCOTT@orcl#insert into achivement values(2,'rhys2','java',50);
insert into achivement values(3,'rhys3','asp.net',50);
insert into achivement values(4,'rhys4','oracle',70);
insert into achivement values(5,'xiaohai','linux',40);
insert into achivement values(6,'xiaohai2','unix',40);
commit;
已创建 1 行。SCOTT@orcl#
已创建 1 行。SCOTT@orcl#
已创建 1 行。SCOTT@orcl#
已创建 1 行。SCOTT@orcl#
已创建 1 行。SCOTT@orcl#提交完成。SCOTT@orcl#select * from achivement partition(part1);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                403 rhys3                asp.net                                          50SCOTT@orcl#select * from achivement partition(part2);
select * from achivement partition(part3);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------2 rhys2                java                                             504 rhys4                oracle                                           705 xiaohai              linux                                            40SCOTT@orcl#ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------6 xiaohai2             unix                                             40SCOTT@orcl#alter table achivement merge partitions part3,part4 into partition part3;
alter table achivement merge partitions part3,part4 into partition part3*
第 1 行出现错误:
ORA-02149: 指定的分区不存在SCOTT@orcl#alter table achivement merge partitions part2,part3 into partition part2;表已更改。SCOTT@orcl#select * from achivement partition(part2);ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------2 rhys2                java                                             504 rhys4                oracle                                           705 xiaohai              linux                                            406 xiaohai2             unix                                             40SCOTT@orcl#alter table achivement drop partition part2;表已更改。SCOTT@orcl#select * from achivement;ID NAME                 SUBJECT                                       SCORE
---------- -------------------- ---------------------------------------- ----------1 rhys1                c                                                403 rhys3                asp.net                                          50SCOTT@orcl#      

oracle 分区表,分区索引相关推荐

  1. 【oracle分区:分区表/分区索引查看,在线重建分区索引】

    分区表/分区索引查看,在线重建分区索引 1.查看分区索引/普通索引 2.查看分区使用空间 3.重建分区索引/主键 4.增加/删除分区 5.创建分区表.分区字段值不能修改. 6.非分区表重建成分区表 1 ...

  2. oracle分区表加索引,oracle分区表增加索引

    oracle分区表增加索引 2016-03-29 oracle分区表查询比较慢,以前是按CID分区,欲增加索引. 1.普通表创建index CREATE INDEX IDX_LOGIN_MESSAGE ...

  3. oracle 建分区索引_Oracle分区表及分区索引-创建list分区

    Oracle 分区表及分区索引 - 创建 list 分区 创建 list 分区的语法如上,需要我们指定的 : l column: 分区依赖列 ( 注意:只能是一个 ); l partition: 分区 ...

  4. oracle 建分区索引_Oracle分区索引

    索引与表类似,也可以分区: 分区索引分为两类: Locally partitioned index(局部分区索引) Globally partitioned index(全局分区索引) 下面就来详细解 ...

  5. oracle分区表分区导出,Oracle分区表数据的导入与导出

    Oracle分区表的使用在一定程度上提高了对表数据的存储及处理性能,在查询性能和数据存储安全上体现了其特有的优势,因此很好的利用分区表,在一定程度上有利于数据库性能的优化.而Oracle分区表数据的导 ...

  6. oracle 建分区索引_ORACLE 创建组合分区索引

    我创建分区表的语句如下:CREATETABLET_JC_CFPARTITIONBYRANGE(KFTIME)SUBPARTITIONBYLIST(YY_ID)SUBPARTITIONTEMPLATE( ...

  7. oracle分区表加索引,Oracle 分区表上的索引

    分区表上的索引分为:本地(局部)索引(local index) 和 全局索引(global index) 1.本地索引 (1)普通索引 SQL > CREATE INDEX INDEX_NAME ...

  8. oracle 建分区索引_Oracle的分区表和Local索引创建与维护

    Oracle的分区表和Local索引创建与维护 SQL> connect eygle/eygle Connected. SQL> CREATE TABLE dbobjs 2  (OBJEC ...

  9. oracle 修索引改空间_记一次Oracle分区表全局索引重修的历程

    1.查询数据库各个表空间利用率: SELECT Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间巨细(M)&q ...

  10. oracle不适合建立索引的场景,Oracle 分区表中本地索引和全局索引的适用场景

    背景 分区表创建好了之后,如果需要最大化分区表的性能就需要结合索引的使用,分区表有两种索引:本地索引和全局索引.既然存在着两种的索引类型,相信存在即合理.既然存在就会有存在的原因,也就是在特定的场景中 ...

最新文章

  1. c# 网站在服务器上第一次请求都需要耗时很久,最.net面试题目.doc
  2. python3是unicode还是utf-8_ASCII、Unicode、UTF-8以及Python3编码问题
  3. 2020年 第11届 蓝桥杯 Java B组 省赛真题详解及小结【第1场省赛 2020.7.5】
  4. Mac nginx PCRE install ngnix
  5. 【DP】错排问题(ybtoj DP-1-1)
  6. 链上存证、链下传输的可信数据共享平台
  7. 我很想走到一个森林里旅游
  8. 中国离婚大数据:离婚/结婚比东北三省和四大直辖市霸榜
  9. 矩阵经典题目六:poj 3070 Fibonacci
  10. IT营Beego教程 Golang+Beego+Grom仿小米商城项目实战视频教程
  11. 看懂555定时器,有哪些应用?
  12. FlashFXP使用及连接不上的错误问题
  13. 线性表学习归纳总结一
  14. signature=d601b7b6eb512df6319aad970c9aaeab,Excise Tax Return Serial Number 97-17 971101 971115
  15. nginx+uwsgi+django1.9+mysql+python2.7部署到CentOS6.5
  16. endnote更新之后打开word出现乱码
  17. 互联网广告请求链路_生产环境的全链路压测应该怎么做?答案都在这里了
  18. SylixOS GSLX680触摸屏驱动移植
  19. echarts动态加载数据生成饼状图
  20. 基于华为mate10 与iphone x 的拆机手册对比的

热门文章

  1. 微软Office Powerpoint双击打不开后的修复办法
  2. UIKit Dynamics入门
  3. 革命炉石传说,Gods Unchained
  4. Java笔记 - 黑马程序员_08(Lambda表达式,接口组成更新,方法引用,类加载器,反射)
  5. HTML5:移动互联网的第二个苹
  6. c++中显示“无法打开xxx.exe进行写入”
  7. 软件删不掉要计算机管理,控制面板卸载不了程序,小编教你如何处理控制面板中卸载不掉的软件...
  8. Unity3D 模型分块
  9. 【JavaEE】简单了解操作系统、进程内存管理
  10. Java面试问题集锦