Oracle分区表技术(PartitionedTables)

2015-01-22 21:10:08 · 作者: · 浏览: 2

?

?

自Oracle 8(1997年左右)就引入了分区表&分区索引(Partitioned Tables & Indexes)的概念来调整大表和大索引,提升性能,提升运维管理的能力。分区表和分区索引机制是海量 数据库管理(Very Large Databases ,即VLDB) 中一个重要的提升性能的机制。
Oracle分区技术的历史Oracle 8引入了分区的概念,后续的每个版本都有对分区机制优化和改进。 \使用分区表/索引的好处 性能提升: Select语句只检索本分区的记录,减少了记录总数,可有效的提升了查询性能。另外,可以通过表空间将分区映射到不同的物理磁盘上,分散设备IO,提升性能; 分区运维:可以针对不同分区,管理数据的加载、索引的创建(以及重建)、数据备份与恢复。因为可针对分区的管理,所以可以有效的降低了分区间的干扰、影响。更多分区的好处可以 阅读 Oracle Partitioning这篇文章,写的更加详细些。
什么时候使用分区表什么时候使用分区表,并没有一个精确的界限,Oracle只有一些通用的建议,具体使用需要自行评估:
tables="" greater="" than="" 2gb="" should="" always="" be="" considered="" for="" partitioning.tables="" containing="" historical="" data,="" in="" which="" new="" data="" is="" added="" into="" the="" newest="" partition.="" a="" typical="" example="" table="" where="" only="" current="" month's="" updatable="" and="" other="" 11="" months="" are="" read="" only.tip:="" 计算表大小的sql
如何分区(分区的方法) Partition Key分区表/索引是以一个或多个字段为依据来决定记录存储在哪个分区,被选用的分区字段称为Partition Key,Oracle会根据Partition Key自动找到对应的分区中做insert, update, delete操作。
分区的方法Oracle提供了6种分区方法: \

Partitioning Method

Brief Description

Range Partitioning

Used when there are logical ranges of data. Possible usage: dates, part numbers, and serial numbers

Hash Partitioning

Used to spread data evenly over partitions. Possible usage: data has no logical groupings

List Partitioning

Used to list together unrelated data into partitions. Possible usage: a number of states list partitioned into a region

Composite Range-Hash Partitioning

Used to range partition first, then spreads data into hash partitions. Possible usage: range partition by date of birth then hash partition by name; store the results into the hash partitions

Composite Range-List Partitioning

Used to range partition first, then spreads data into list partitions.Possible usage: range partition by date of birth then list partition by state, then store the results into the list partitions


Examples Range Partitioning Example--创建表空间create tablespace invoices_2010 datafile 'e:\app\TianPan\oradata\tbs01.dbf' size 50m;
List Partitioning Example--创建表空间
Useful Query [Query]如何知道一个表或索引是否有被分区SELECT * FROM dba_part_tables;
[Query]如何列出分区表或索引的分区对象SELECT * FROM dba_tab_partitions WHERE table_name = '';
分区表的数据导出导入 全表导出C:\Users\TianPan> exp system/welcome@ptian file=c:\test.dmp tables=Invoices
分区表导出C:\Users\TianPan> exp system/welcome@ptian file=c:\test_part.dmp tables=Invoices:part03
全表导入 imp system/welcome@ptian file=test.dmp full=y
分区表导入imp system/welcome@ptianfile=test_part.dmp full=y
数据泵expdp/impdp的方式
导出整个表