- 浏览: 1255283 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
jackhong1108:
你可能只知道Oracle有like,不知道Oracle有其他的 ...
Hive使用regexp,RLIKE需要使用转义字符 -
pktangshao:
a_bun 写道iijjll 写道使用wmsys.wm_con ...
Oracle 列转行函数 Listagg() -
nayouzhenai:
Spring读取properties文件作为环境变量 -
a_bun:
iijjll 写道使用wmsys.wm_concat()函数也 ...
Oracle 列转行函数 Listagg() -
Horse_Chasing:
鼓励鼓励鼓励鼓励鼓励鼓励鼓励鼓励鼓励鼓励
广州面试小结
说到大数据,在传统数据库里面,分区是首要的解决方案。那么,我总结了一下公司里面的培训资料,做了一份Oracle分区攻略。仅供学习参考。
首先,回顾一下Oracle的表空间创建和表创建。
表空间和表建好了,就要正式开始我们的分区攻略了。
范围分区:
Hash 分区:
列分区:
首先,回顾一下Oracle的表空间创建和表创建。
--表空间创建 create tablespace user_temp tempfile 'D:\oracle\oradata\Oracle9i\user_temp1.dbf'size 50m, 'D:\oracle\oradata\Oracle9i\user_temp1.dbf'size 50m --指出表空间包含什么文件,默认大小 autoextend on --是否自动扩展 next 50m maxsize 20480m --每次扩大多少,扩张到最大是多少 extent management local ; --创建表 create table X_SMALL_AREA ( SMALL_AREA_ID NUMBER(10) not null ) tablespace TBSL_SDDQ --表段X_SMALL_AREA放在表空间TBSL_SDDQ中 pctfree 10 --指定一个百分比 比如说10% 那么当某个数据块使用率超过百分之80的时候系统就会停止往这个数据块里 --插入新的数据 剩下10% 空间留给将来对数据的更新使用 这样可以防止迁移行和链接行的出现 initrans 1 --初始化事务槽的个数 maxtrans 255 --指定最多有多少个事务可以并发操作此数据块 storage --存储参数 ( initial 64k --区段(extent)一次扩展64k minextents 1 --最小区段数 maxextents unlimited --最大区段无限制 );
表空间和表建好了,就要正式开始我们的分区攻略了。
范围分区:
drop table DEPT_RNG; CREATE TABLE DEPT_RNG (DEPTNO NUMBER(2), DEPTNAME VARCHAR2(30)) PARTITION BY RANGE(DEPTNO) (PARTITION D1 VALUES LESS THAN (10) tablespace ts1, PARTITION D2 VALUES LESS THAN (20), PARTITION D3 VALUES LESS THAN (30) tablespace ts3); select segment_name,partition_name,tablespace_name from dba_segments where owner='TEST' and segment_name='DEPT_RNG'; select table_name,partition_name,high_value from user_tab_partitions where table_name='DEPT_RNG'; insert into DEPT_RNG values(1,'Fin'); insert into DEPT_RNG values(10,'Tech'); insert into DEPT_RNG values(25,'HR'); commit; select * from DEPT_RNG; select * from DEPT_RNG partition (d1); select * from DEPT_RNG partition (d2); select * from DEPT_RNG partition (d3); --如果插入的数据在规定分区以外就会出现 ORA-1440 insert into DEPT_RNG values(null,'Office'); --OR insert into DEPT_RNG values(40,'Office'); ERROR at line 1: ORA-14400: inserted partition key does not map to any partition --这个时候就要求添加一个分区: alter table DEPT_RNG add partition Dmax values less than (maxvalue); --为了更好第解决这种分区问题,Oracle 11g推出了Interval Partition(区间分区) CREATE TABLE DEPT_NEW2 (DEPTNO NUMBER(2), DEPT_NAME VARCHAR2(30)) PARTITION BY RANGE(DEPTNO) INTERVAL(10) (PARTITION D1 VALUES LESS THAN (10), PARTITION D2 VALUES LESS THAN (20), PARTITION D3 VALUES LESS THAN (30)) ; 这时候,再插入 insert into DEPT_RNG values(40,'Office'); 通过查询: select segment_name, partition_name from dba_segments where segment_name = 'DEPT_NEW2' 就会由dbms自动创建一个SYS_开头的分区,根据INTERVAL(10)的设置,RANGE每增加,新增一个分区。 根据日期的范围分区使用以下: interval (numtoyminterval (1,’month’)) --每一个月份增加一个分区 interval (numtoyminterval (1,’year’)) --每一年增加一个分区 这样创建的表分区会默认分配在SYSTEM表空间。 可以使用store in (test,PERFSTAT)放在interval语句后面,如: INTERVAL(10) store in (test,PERFSTAT) --则会均匀地放在预设的表空间里面 ( PARTITION D1 VALUES LESS THAN (10), PARTITION D2 VALUES LESS THAN (20), PARTITION D3 VALUES LESS THAN (30) )
Hash 分区:
drop table product; CREATE TABLE product (id NUMBER(5), name VARCHAR2(30)) PARTITION BY HASH(id) PARTITIONS 16 STORE IN (ts1,ts2,ts3,ts4); insert into product values(10,0); insert into product values(11,1); insert into product values(22,2); insert into product values(33,3); insert into product values(44,4); insert into product values(55,5); insert into product values(66,6); insert into product values(77,7); insert into product values(88,8); insert into product values(99,9); insert into product values(10,10); insert into product values(11,11); commit; select segment_name,partition_name,tablespace_name from dba_segments where owner='TEST' and segment_name='PRODUCT'; select * from product partition(SYS_P67); select * from product partition(SYS_P68); select * from product partition(SYS_P66);
列分区:
CREATE TABLE DEPT_LIST ( DeptNo NUMBER(2), Dname VARCHAR2(14), Loc VARCHAR2(13)) PARTITION BY LIST (Loc) (PARTITION D_East VALUES ('Shanghai', 'Nanjing'), PARTITION D_West VALUES ('Chengdu', 'Chongqing'), PARTITION D_South VALUES ('Guangzhou', 'Fuzhou'), PARTITION D_North VALUES ('Beijing', 'Shenyang') ); insert into DEPT_LIST values (1,'GZ','Guangzhou'); insert into DEPT_LIST values (1,'GZ','GuangZhou'); insert into DEPT_LIST values (2,'BJ','Beijing'); select * from DEPT_LIST; select * from DEPT_LIST partition(D_South);
发表评论
-
你真的会SQL吗?关于SQL的join和on之间的区别
2014-12-05 22:11 2561写了那么多年的SQL,居然发现自己写的是错的,实在是惭愧不 ... -
慎用堆表
2014-11-18 11:14 1449有时候我们常常为了使用方便,省略建主键的建表方式。 因为很 ... -
Oracle谓词推入
2014-04-08 09:20 7002在Oracle中,谓词一般就是指where后面的那些过滤条 ... -
Oracle 执行计划
2013-11-14 10:40 0explain plan for select a.produ ... -
Oracle Share Pool 与ORA-04031
2013-07-16 11:25 1777oracle share pool详解:http://blo ... -
Oracle 分析函数Lead(),Lag()
2013-04-22 21:18 12762其实这2个函数的作用非常好理解,Lead()就是取当前顺序的 ... -
总结Oracle数组和BULK COLLECT INTO
2013-04-19 23:29 1747Oracle中使用数组,就像JAVA使用对象List< ... -
[转]Oracle表连接方式学习
2013-04-10 20:40 1458出自:http://www.itpub.net/threa ... -
Oracle SQL 嵌套CASE WHEN
2013-04-09 20:11 13141尝试了一下,Oracle CASE WHEN 是可以支持嵌套 ... -
Oracle FUNCTION与PROCEDURE的最大区别
2013-04-03 15:12 1835Oracle function里面是可以允许有DML语句的, ... -
Oracle Merge into语句
2013-03-29 15:35 2816研究这个语句完全是为了偷懒而使用的。 因为在Java写后 ... -
Oracle填坑指南之长度为0的字符串
2013-03-18 16:20 1369用一下语句查询,你认为结果是什么?? select cas ... -
Oracle数据库设计中的不更新原则
2013-02-04 16:39 1101在新增数据的时候,如果新的逻辑涉及到原有的信息,那么尽量是能 ... -
Oracle SQL判断字符串是否在目标字符串中的函数
2013-01-18 15:33 5572根据需求,写了一段方法。 用于识别以下的情况: 判断 字 ... -
[转]Oracle中使用正则表达式
2012-11-13 14:05 1398Oracle10开始支持正则表达式。 介绍内容如下: OR ... -
Oracle中使用Java存储过程
2012-11-13 13:51 1565从Oracle8i开始,就有了对Java存储过程的支持。 O ... -
Oracle索引的新认识
2012-11-08 16:16 1286首先,Oracle的索引有。 普通索引B*树,BitMap索 ... -
Oracle和Cognos Framework Manager中decode妙用,CASE WHEN也可以!
2012-11-05 17:44 2748我们都知道Decode函数可以用来做什么作用,如果这个不知道的 ... -
Oracle 数组类型
2012-10-16 11:07 4837Oracle的数组类型,范例 ... -
Oracle 列转行函数 Listagg()
2012-10-16 09:58 174745这是一个Oracle的列转行函数:LISTAGG() ...
相关推荐
ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区ORACLE分区
Oracle分区表详解 大家可以参考下 网上找的资料共享一下
oracle分区资料· oracle分区资料· oracle分区资料·
oracle分区表总结oracle分区表总结oracle分oracle分区表总结区表总结oracle分区表总结
Hash分区是Oracle实现表分区的三种基本分区方式之一。对于那些无法有效划分分区范围的大表,或者出于某些特殊考虑的设计,需要使用Hash分区,下面介绍使用方法
ORACLE 分区表 分区索引 索引分区 实例讲解
对orcle大数据的查询的优化,ORACLE分区表、分区索引ORACLE对于分区表方式其实就是将表分段存储,一般普通表格是一个段存储,而分区表会分成多个段,所以查找数据过程都是先定位根据查询条件定位分区范围,即数据在...
ORACLE分区表操作大全 ORACLE分区表操作大全
oracle表分区详解
oracle 分区表管理oracle 分区表管理oracle 分区表管理oracle 分区表管理oracle 分区表管理
公司内部培训ORACLE分区表使用的文档
Oracle 分区表全揭秘 ,非常详细,oracle dba可以看看
oracle表分区实例.doc oracle表分区实例.doc oracle表分区实例.doc
导入导出 Oracle 分区表数据
深入学习分区表及分区索引(详解oracle分区).docx
Oracle的UNDOTBS01.DBF文件太大的解决办法 1、.禁止undo tablespace自动增长 alter database datafile 'full_path\undotbs01.dbf' autoextend off; 2.-- 创建一个新的小空间的undo tablespace create undo ...
Oracle提供了分区技术以支持VLDB(Very Large DataBase)。将数据分散到各个分区中,减少了数据损坏的可能性;可以对单独的分区进行备份和恢复;可以将分区映射到不同的物理磁盘上,来分散IO ;提高可管理性、可用性和...
总结描述Oracle 11g分区表的种类及分区索引的类型。范围分区,列表分区,散列分区,组合分区,哈希分区,全局索引,分区索引
分享一个自己学习和实践的关于Oracle表自动按月分区知识点,已经在项目上线并且有效的方案。