Oracle分区技术

 

ORACLE的分区(Partitioning Option)是一种处理超大型表的技术。分区是一种“分而治之”的技术,通过将大表和索引分成可以管理的小块,从而避免了对每个表作为一个大的、单独的对象进行管理,为大量数据提供了可伸缩的性能。分区通过将操作分配给更小的存储单元,减少了需要进行管理操作的时间,并通过增强的并行处理提高了性能,通过屏蔽故障数据的分区,还增加了可用性。

select   *   from   user_tables   a   where   a.partitioned= 'YES '

 

Sql代码
  1. CREATE TABLE range    
  2. (id  NUMBER(5),    
  3. name VARCHAR2(30),    
  4. amount  NUMBER(10),   
  5. sdate DATE)   
  6. COMPRESS   
  7. PARTITION BY RANGE(sdate)   
  8. (PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('16/09/2009','DD/MM/YYYY')),   
  9.  PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('17/09/2009','DD/MM/YYYY')),   
  10.  PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('18/09/2009','DD/MM/YYYY')),   
  11.  PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('19/09/2009','DD/MM/YYYY')));  
CREATE TABLE range 
(id  NUMBER(5), 
name VARCHAR2(30), 
amount  NUMBER(10),
sdate DATE)
COMPRESS
PARTITION BY RANGE(sdate)
(PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('16/09/2009','DD/MM/YYYY')),
 PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('17/09/2009','DD/MM/YYYY')),
 PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('18/09/2009','DD/MM/YYYY')),
 PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('19/09/2009','DD/MM/YYYY')));

 

 

动态增加分区

 

Sql代码
  1. create or replace procedure addpart(tableName varchar2,   
  2.                                     partName  varchar2,   
  3.                                     adate     varchar2)   
  4.  is  
  5. begin  
  6.   execute immediate 'alter   table   ' || tableName || '   add   partition   ' || partName || '      
  7. values   less   than   (to_date(''' || adate || ''',''YYYY-MM-DD'')' || ')';   
  8. end addpart;  
create or replace procedure addpart(tableName varchar2,
                                    partName  varchar2,
                                    adate     varchar2)
 is
begin
  execute immediate 'alter   table   ' || tableName || '   add   partition   ' || partName || '   
values   less   than   (to_date(''' || adate || ''',''YYYY-MM-DD'')' || ')';
end addpart;

 

 

  增加一个分区:alter   table   add   partition/alter   table   split   partition  
  释放一个表分区   alter   table  ** drop   partition  **

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DSS queries on very large tables present special performance problems. An ad-hoc query that requires a table scan may take a long time, because it must inspect every row in the table; there is no way to identify and skip subsets of irrelevant rows. The problem is particularly important for historical tables, for which many queries concentrate access on rows that were generated recently. Partitions help solve this problem. An ad-hoc query that requires only rows that correspond to a single partition (or range of partitions) can be executed using a partition scan rather than a table scan. For example, a query that requests data generated in the month of October 1994 can scan just the rows stored in the October 1994 partition, rather than rows generated over years of activity. This improves response time. It may also substantially reduce the temporary disk space requirement for queries that require sorts. Load balancing Many DBAs want to be able to control how data is spread across physical devices. It is not sufficient to allow a table’s data to reside on multiple disks. The DBA must be able to specify where subsets of a table go, so that he can balance I/O utilization. With this level of control, the DBA can accommodate the special needs of applications requiring fast response time by reducing disk contention and utilizing faster devices. On the other hand data, that is accessed infrequently, such as old historical data, can be moved to slow disks or stored in subsystems that support a storage hierarchy. Partitioning satisfies this requirement by allowing partitions of a table or index to be stored in different tablespaces.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值