http://docs.oracle.com/cd/B10501_01/server.920/a96524/c12parti.htm#460945html
Hash partitioning enables easy partitioning of data that does not lend itself to range or list partitioning. It does this with a simple syntax and is easy to implement. It is a better choice than range partitioning when:數據庫
The concepts of splitting, dropping or merging partitions do not apply to hash partitions. Instead, hash partitions can be added and coalesced.oracle
CREATE TABLE sales_hash (salesman_id NUMBER(5), salesman_name VARCHAR2(30), sales_amount NUMBER(10), week_no NUMBER(2)) PARTITION BY HASH(salesman_id) PARTITIONS 4 STORE IN (data1, data2, data3, data4);
The preceding statement creates a table sales_hash
, which is hash partitioned on salesman_id
field. The tablespace names are data1
,data2
, data3
, and data4
.app
https://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm#i1007318less
http://www.2cto.com/database/201202/118595.htmlui
跨分區查詢this
select sum( *) from
(select count(*) cn from t_table_SS PARTITION (P200709_1)
union all
select count(*) cn from t_table_SS PARTITION (P200709_2)
);spa
查詢表上有多少分區code
SELECT * FROM useR_TAB_PARTITIONS WHERE TABLE_NAME='tableName'orm
查詢索引信息
select object_name,object_type,tablespace_name,sum(value)
from v$segment_statistics
where statistic_name IN ('physical reads','physical write','logical reads')and object_type='INDEX'
group by object_name,object_type,tablespace_name
order by 4 desc
顯示數據庫全部分區表的信息:
select * from DBA_PART_TABLES
顯示錶分區名稱之類的信息:
select *
from DBA_PART_COL_STATISTICS
where table_name like '%MIGRAT%'
另外關於查詢分區表的信息能夠參考:
https://docs.oracle.com/cd/E18283_01/server.112/e16541/part_admin005.htm
爲表添加索引的方法
https://docs.oracle.com/cd/B28359_01/server.111/b28310/indexes003.htm#i1006525
CREATE INDEX emp_ename ON emp(ename)
TABLESPACE users
STORAGE (INITIAL 20K
NEXT 20k
PCTINCREASE 75);
注意:當設置主鍵的時候,是默認會加上一個惟一索引的,是自動建立的。能夠指定包含這個索引的用戶空間。
Creating an Index Associated with a Constraint
Oracle Database enforces a UNIQUE
key or PRIMARY KEY
integrity constraint on a table by creating a unique index on the unique key or primary key. This index is automatically created by the database when the constraint is enabled. No action is required by you when you issue the CREATE TABLE
or ALTER TABLE
statement to create the index, but you can optionally specify a USING INDEX
clause to exercise control over its creation. This includes both when a constraint is defined and enabled, and when a defined but disabled constraint is enabled.
To enable a UNIQUE
or PRIMARY KEY
constraint, thus creating an associated index, the owner of the table must have a quota for the tablespace intended to contain the index, or the UNLIMITED TABLESPACE
system privilege. The index associated with a constraint always takes the name of the constraint, unless you optionally specify otherwise.