91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

db2 定義分區表和分區鍵

發布時間:2020-07-24 00:28:15 來源:網絡 閱讀:4975 作者:18620626259 欄目:MySQL數據庫

下面,為了提高數據庫性能,我們將不同的分區放到不同的表空間下。首先創建6個表空間,3個數據表空間,3個索引表空間:
db2 "create tablespace ts_dat managed by database using (file '/home/db2inst1/data/ts_dat' 100M)"
db2 "create tablespace ts_dat1 managed by database using (file '/home/db2inst1/data/ts_dat1' 100M)"
db2 "create tablespace ts_dat2 managed by database using (file '/home/db2inst1/data/ts_dat2' 100M)"
db2 "create tablespace ts_idx managed by database using (file '/home/db2inst1/data/ts_idx' 100M)"
db2 "create tablespace ts_idx1 managed by database using (file '/home/db2inst1/data/ts_idx1' 100M)"
db2 "create tablespace ts_idx2 managed by database using (file '/home/db2inst1/data/ts_idx2' 100M)"

首次執行后不需要執行
--DDL for Bufferpools--
CREATE BUFFERPOOL "BP32K_DATA" SIZE 32768 PAGESIZE 32768;
CREATE BUFFERPOOL "BP32K_INDEX" SIZE 32768 PAGESIZE 32768;

--Minic Storage Groups--
ALTER STOGROUP "IBMSTOGROUP" OVERHEAD 6.725000 DEVICE READ RATE 100.000000 DATA TAG NONE SET AS DEFAULT;


創建用戶臨時表空間
CREATE USER TEMPORARY TABLESPACE "USER_TMP" IN DATABASE PARTITION GROUP IBMDEFAULTGROUP PAGESIZE 32768 MANAGED BY SYSTEM
--修改表空名TABLESPACE "USER_TMP"
 USING ('/home/db2inst1/data/usrtmp')----修改路徑'/home/db2inst1/data/usrtmp'
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;
 
創建系統臨時表空間
CREATE TEMPORARY TABLESPACE "TMP_SYSTEM"  PAGESIZE 32768 MANAGED BY SYSTEM
 USING ('/home/db2inst1/data/SYStmp')
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;
 
創建普通表空間
CREATE LARGE TABLESPACE "IDM_DATATABLE"  PAGESIZE 32768 MANAGED BY DATABASE
----修改表空間TABLESPACE "IDM_DATATABLE"
 USING (file '/home/db2inst1/data/IDM_datatable' 100M)-----修改路徑和大小
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;
 

 
CREATE TABLESPACE "IDMINDX"  PAGESIZE 32768 MANAGED BY DATABASE
 USING (file '/home/db2inst1/data/IDMINDX' 100M)
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;
 
 
CREATE LARGE TABLESPACE "IDMDTL1"  PAGESIZE 32768 MANAGED BY DATABASE
 USING (file '/home/db2inst1/data/IDMDTL1' 100M)
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;
 
 
CREATE LARGE TABLESPACE "IDMDTL2"  PAGESIZE 32768 MANAGED BY DATABASE
 USING (file '/home/db2inst1/data/IDMDTL2' 100M)
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;
 
 
 CREATE LARGE TABLESPACE "IDMDTL3"  PAGESIZE 32768 MANAGED BY DATABASE
 USING (file '/home/db2inst1/data/IDMDTL3' 100M)
 EXTENTSIZE 64
 PREFETCHSIZE AUTOMATIC
 BUFFERPOOL "BP32K_DATA"
 OVERHEAD 6.725000
 TRANSFERRATE 0.320000
 NO FILE SYSTEM CACHING
 DROPPED TABLE RECOVERY OFF;


分區表類型
  1、自動分區
  2、手工分區      
 
PARTITION BY RANGE(分區列)   

(PART 分區名 STARTING 開始  ENDING 結束 IN 表空間 INDEX IN 索引鎖在表空間)


省略starting,下一個上一個結束  
STARTING(2017,1) ENDING (2017,6),
                 ENDING (2017, 9),                
                 ENDING (2017, 12),               
                 ENDING (2018, 12));
                
省略ending,結束為上一個的開始
PARTITION BY RANGE(COL35)
 (PART PART0 STARTING('2017-01-01') IN IDMDTL1,
 PART PART1 STARTING('2017-04-01') IN IDMDTL2,
 PART PART2 STARTING('2017-07-01') IN IDMDTL3,
 PART PART3 STARTING('2017-10-01') ENDING('2017-12-31') IN IDMDTL1,


EEXCLUSIVE 分區2018-02-01這個排除在外
PART IDM_TRANSDTL_PART201801 STARTING('2018-01-01') ENDING('2018-02-01') EXCLUSIVE IN IDMDTL1 INDEX IN IDMINDX,                              

表分區鍵不支持的數據類型如下:
用戶定義的類型(結構化)
LONG VARCHAR
LONG VARCHAR FOR BIT DATA
BLOB
BINARY LARGE OBJECT
CLOB
CHARACTER LARGE OBJECT
DBCLOB
LONG VARGRAPHIC
REF
C變長字符串
Pascal變長字符串
XML

db2 "describe DATA PARTITIONS for table parttabtest02 show detail"

實例:

實例1、表空間均勻分布在表空間上
CREATE TABLE parttabtest01
( ID                INTEGER NOT NULL,
  SALES_PERSON       VARCHAR(50),
  REGION             VARCHAR(50),
  SALES_DATE         DATE)
  IN ts_dat1,ts_dat2     ------指定表在分區上
  INDEX IN ts_idx        ------指定索引分區上
  PARTITION BY RANGE(SALES_DATE)
( STARTING MINVALUE, STARTING '1/1/2012' ENDING '12/31/2012' EVERY 1 MONTH,ENDING MAXVALUE);

實例2、
類似的,我們也可以在分區后面加表空間名稱,顯式地為分區指定所在的表空間。
對于建立分區語句里沒有指定表空間的分區,使用CREATE TABLE里指定的表空間。
CREATE TABLE  parttabtest02
( ID                 INTEGER NOT NULL,
  SALES_PERSON       VARCHAR(50),
  REGION             VARCHAR(50),
  SALES_DATE         DATE)
  IN TS_DAT
  INDEX IN TS_IDX
  PARTITION BY RANGE(SALES_DATE)
( PART PJAN STARTING '1/1/2017' ENDING '3/31/2017' IN TS_DAT1 INDEX IN TS_IDX1,-----指定分區在指定的表空間上
  PART PFEB STARTING '4/1/2017' ENDING '7/31/2017' IN TS_DAT1 INDEX IN TS_IDX1,
  PART PMAR STARTING '8/1/2017' ENDING '12/31/2017' IN TS_DAT2 INDEX IN TS_IDX2,
  PART PAPR STARTING '1/1/2018' ENDING '11/31/2018' )
 
 

實例3、
如果選擇使用CREATE TABLE語句的EVERY子句來自動生成數據分區,那么只能將一列用作表分區鍵。
如果選擇通過在CREATE TABLE語句的PARTITION BY子句中指定每個范圍來手動生成數據分區,
那么可以將多個列用作表分區鍵,如以下示例所示:
CREATE TABLE parttabtest03
( ID                INTEGER NOT NULL,
  SALES_PERSON     VARCHAR(50),
  REGION            VARCHAR(50),
  SALES_YEAR       INT,
  SALES_MONTH      INT)
  PARTITION BY RANGE(SALES_YEAR, SALES_MONTH)
( STARTING(2017,1) ENDING (2017,6),
  ENDING (2017, 9),
  ENDING (2017, 12),
  ENDING (2018, 12));
 
 
實例4、 
CREATE TABLE parttabtest04
( ID              INTEGER NOT NULL,
  SALES_PERSON     VARCHAR(50),
  REGION           VARCHAR(50),
  SALES_DATE       DATE,
  SALES_MONTH      GENERATED ALWAYS AS (month(SALES_DATE)))
  PARTITION BY RANGE(SALES_MONTH)
( STARTING FROM 1 ENDING AT 12 EVERY 1 );
 


表名
CREATE TABLE IDM_TRANSDTL (
 COL1 VARCHAR(22) NOT NULL,
 COL2 VARCHAR(8) NOT NULL,
 COL3 VARCHAR(8) NOT NULL,
 COL4 VARCHAR(6) NOT NULL,
 COL5 VARCHAR(6) ,
 COL6 VARCHAR(6) ,
 COL7 VARCHAR(40) ,
 COL8 VARCHAR(4) ,
 COL9 VARCHAR(3) ,
 COL10 VARCHAR(8) ,
 COL11 VARCHAR(22) ,
 COL12 VARCHAR(4) ,
 COL13 VARCHAR(14) ,
 COL14 VARCHAR(5) ,
 COL15 VARCHAR(30) ,
 COL16 VARCHAR(100) ,
 COL17 VARCHAR(20) ,
 COL18 VARCHAR(30) ,
 COL19 VARCHAR(30) ,
 COL20 VARCHAR(20) ,
 COL21 VARCHAR(1) ,
 COL22 VARCHAR(1) ,
 COL23 VARCHAR(20) ,
 COL24 VARCHAR(2) ,
 COL25 VARCHAR(14) ,
 COL26 VARCHAR(2) ,
 COL27 VARCHAR(10) ,
 COL28 VARCHAR(256) ,
 COL29 VARCHAR(20) ,
 COL30 VARCHAR(100) ,
 COL31 VARCHAR(100) ,
 COL32 VARCHAR(100) ,
 COL33 VARCHAR(100) ,
 COL34 VARCHAR(100) , 
 COL35 DATE NOT NULL WITH DEFAULT CURRENT DATE)
 INDEX IN IDMINDX PARTITION BY RANGE(COL35)
 (PART PART0 STARTING('2017-01-01') IN IDMDTL1,
 PART PART1 STARTING('2017-04-01') IN IDMDTL2,
 PART PART2 STARTING('2017-07-01') IN IDMDTL3,
 PART PART3 STARTING('2017-10-01') ENDING('2017-12-31') IN IDMDTL1,
 PART IDM_TRANSDTL_PART201801 STARTING('2018-01-01') ENDING('2018-02-01') EXCLUSIVE IN IDMDTL1 INDEX IN IDMINDX,
 PART IDM_TRANSDTL_PART201802 STARTING('2018-02-01') ENDING('2018-03-01') EXCLUSIVE IN IDMDTL2 INDEX IN IDMINDX, 
 PART IDM_TRANSDTL_PART201803 STARTING('2018-03-01') ENDING('2018-04-01') EXCLUSIVE IN IDMDTL3 INDEX IN IDMINDX, 
 PART IDM_TRANSDTL_PART201804 STARTING('2018-04-01') ENDING('2018-05-01') EXCLUSIVE IN IDMDTL1 INDEX IN IDMINDX,
 PART IDM_TRANSDTL_PART201805 STARTING('2018-05-01') ENDING('2018-06-01') EXCLUSIVE IN IDMDTL2 INDEX IN IDMINDX, 
 PART IDM_TRANSDTL_PART201806 STARTING('2018-06-01') ENDING('2018-07-01') EXCLUSIVE IN IDMDTL3 INDEX IN IDMINDX,  
 PART IDM_TRANSDTL_PART201807 STARTING('2018-07-01') ENDING('2018-08-01') EXCLUSIVE IN IDMDTL1 INDEX IN IDMINDX,
 PART IDM_TRANSDTL_PART201808 STARTING('2018-08-01') ENDING('2018-09-01') EXCLUSIVE IN IDMDTL2 INDEX IN IDMINDX, 
 PART IDM_TRANSDTL_PART201809 STARTING('2018-09-01') ENDING('2018-10-01') EXCLUSIVE IN IDMDTL3 INDEX IN IDMINDX, 
 PART IDM_TRANSDTL_PART201810 STARTING('2018-10-01') ENDING('2018-11-01') EXCLUSIVE IN IDMDTL1 INDEX IN IDMINDX,
 PART IDM_TRANSDTL_PART201811 STARTING('2018-11-01') ENDING('2018-12-01') EXCLUSIVE IN IDMDTL2 INDEX IN IDMINDX, 
 PART IDM_TRANSDTL_PART201812 STARTING('2018-12-01') ENDING('2019-01-01') EXCLUSIVE IN IDMDTL3 INDEX IN IDMINDX)  
 


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

青河县| 本溪市| 阿尔山市| 清水县| 万盛区| 朝阳区| 循化| 永宁县| 洛川县| 吉安县| 贵港市| 天台县| 德州市| 商河县| 沙坪坝区| 东源县| 文昌市| 吉首市| 宾阳县| 陕西省| 兴宁市| 三明市| 陈巴尔虎旗| 上高县| 化德县| 砚山县| 汤阴县| 宁波市| 军事| 汝南县| 时尚| 怀远县| 元谋县| 泰州市| 广东省| 卓尼县| 阜阳市| 临桂县| 屏东县| 胶州市| 宁都县|