3000sunqin 和hujingyu 兩位大蝦,請教一個概念。分區鍵的功能就是用來指示相應的數據在哪個數據庫分區上的,也就是說是數據庫分布在不同的節點上,通過節點組分布表空間,在上面進行數據分布。
1、在節點組這一層,沒有問題
2、分布表空間指定了每個節點的容器,數據以hash的方式分布於容器中
3、建表的時候指定了表空間,則表數據以hash的方式分布於表空間容器中
4、建表的時候指定PARTITIONING KEY (MIX_INT) USING HASHING,數據不能夠分布在不同的表空間吧。
5、對於表空間,分布在不同的節點上,你能指定表數據存儲在哪個節點的容器上,我認為不可以。
6、之所以作分區,是為了提高性能,但是如果按照這種方法,應該還是要操作整個表,而不是一個表的分區
我們可以看一個Oracle(大型網站數據庫平台)數據庫的分區例子,
CREATE TABLE FO_GINCALL
(
DAY_ID NUMBER(,
HOUR_ID NUMBER(2),
CALLKND_ID NUMBER(4) NOT NULL,
CITYCODE_ID NUMBER(4),
FEEKND_ID NUMBER(16),
CALLTIME VARCHAR2(14 BYTE) NOT NULL,
SVC_ID VARCHAR2(20 BYTE) NOT NULL,
OPPOSENUMBER VARCHAR2(20 BYTE) NOT NULL,
BALANCE NUMBER(12,2),
CALLDURATION NUMBER(12),
CALLFEE NUMBER(12,2),
FEATUREFLAG NUMBER(1),
BEARERFLAG NUMBER(1),
FORWARDINGFLAG NUMBER(1),
ISFIRSTCALL NUMBER(1),
TIMESTAMP DATE,
SUBPARTNO NUMBER(2) NOT NULL
)
TABLESPACE TBS_ODS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 60
STORAGE (
INITIAL 300M
MINEXTENTS 1
MAXEXTENTS 255
PCTINCREASE 0
NOLOGGING
PARTITION BY RANGE (SUBPARTNO)
(
PARTITION P_GINCALL_01 VALUES LESS THAN (2)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN01
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_02 VALUES LESS THAN (3)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN02
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_03 VALUES LESS THAN (4)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_04 VALUES LESS THAN (5)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN04
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_05 VALUES LESS THAN (6)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN05
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_06 VALUES LESS THAN (7)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN06
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_07 VALUES LESS THAN (
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN07
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_08 VALUES LESS THAN (9)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN08
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_09 VALUES LESS THAN (10)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN09
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_10 VALUES LESS THAN (11)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN10
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_11 VALUES LESS THAN (12)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN11
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_12 VALUES LESS THAN (13)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN12
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_13 VALUES LESS THAN (14)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN13
PCTFREE 10
INITRANS 1
MAXTRANS 60
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_14 VALUES LESS THAN (15)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN14
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_15 VALUES LESS THAN (16)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN15
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_16 VALUES LESS THAN (17)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN16
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_17 VALUES LESS THAN (1
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN17
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_18 VALUES LESS THAN (19)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN18
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_19 VALUES LESS THAN (20)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN19
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_20 VALUES LESS THAN (21)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN20
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_21 VALUES LESS THAN (22)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN21
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_22 VALUES LESS THAN (23)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN22
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_23 VALUES LESS THAN (24)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN23
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_24 VALUES LESS THAN (25)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN24
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_25 VALUES LESS THAN (26)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN25
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_26 VALUES LESS THAN (27)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN27
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_27 VALUES LESS THAN (2
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN27
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_28 VALUES LESS THAN (29)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN28
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_29 VALUES LESS THAN (30)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN29
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_30 VALUES LESS THAN (31)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN30
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_31 VALUES LESS THAN (MAXVALUE)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN31
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
NOCACHE
PARALLEL ( DEGREE DEFAULT INSTANCES 1 ;
如果我用了這樣一個SQL,可以保證他只會訪問分區 P_GINCALL_30 (及只對TABLESPACE TBS_IN30操作,極大的提高了性能)
SELECT DAY_ID
FROM FO_GINCALL
WHERE SUBPARTNO=30
如果按照DB2表可以分區(和Oracle(大型網站數據庫平台)表分區一樣,而不是按照索引、常規數據、大對象的不同表空間分布),那麼也就是說上面Oracle(大型網站數據庫平台)的表分區方法在DB2裡面可以實現了(當然不是通過union all的視圖,union all的視圖可以做到這一點),請大蝦指點實現方法
還有,分區數據庫,就是將數據庫實例分布於不同節點的數據庫吧。
還有,是不是我們對表分區的概念有不同的理解。
不對之處請大家多多指點,大家共同學習,共同進步。