Home > Backend Development > PHP Tutorial > A brief explanation of DB2 table space_PHP tutorial

A brief explanation of DB2 table space_PHP tutorial

WBOY
Release: 2016-07-12 09:04:57
Original
1185 people have browsed it

A brief description of DB2 table space

1. Create a new test library:

[db2inst2@localhost shell]$ db2 "create database ghan on /db2inst2/db2inst2 using codeset utf- 8 territory cn collate using system"
DB20000I CREATE DATABASE command completed successfully.

[db2inst2@localhost shell]$ db2 connect to ghan


Database connection information


Database server = DB2/LINUXX8664 9.7.5
SQL authorization ID = DB2INST2
Local database alias = GHAN


[db2inst2@localhost shell]$




2. Create a new buffer pool:

[db2inst2@localhost shell]$ db2 "create bufferpool bp32k pagesize 32k"
DB20000I SQL command completed successfully.
[db2inst2@localhost shell]$


db2inst2@localhost ~]$ db2 "SELECT * FROM SYSCAT.BUFFERPOOLS"


BPNAME BUFFERPOOLID DBPGNAME NPAGES PAGESIZE ESTORE NUMBLOCKPAGES BLOCKSIZE NGNAME
------------------------------------------------ -------------------------------------------------- ---------------------------------- ---------- ----- -------------------------------------------------- -------------------------------------------------- ----------------------- ---------- ---------- ----- -------------- ----------- -------------------------- -------------------------------------------------- -------------------------------------------------- ---
IBMDEFAULTBP 1 - -2 4096 N 0 0 -
BP32K 2 - -2 32768 N 0 0 -


2 records selected.



3. Create a new database management (DMS) large tablespace

[db2inst2@localhost shell]$ db2 -tsvf create_tabs.sql
create large tablespace tbs_data pagesize 32k managed by database using (file '/db2inst2/data_tb/cont0' 100M, file '/db2inst2/data_tb/cont1' 100M) EXTENTSIZE 32 prefetchsize automatic bufferpool bp32k no file system caching
DB20000I SQL command completed successfully.

[db2inst2@localhost shell]$ cd /db2inst2/data_tb/
[db2inst2@localhost data_tb]$ ll
Total 205008
-rw------ 1 db2inst2 db2inst2 104857600 10-20 08:48 cont0
-rw------- 1 db2inst2 db2inst2 104857600 10-20 08:48 cont1
[db2inst2@localhost data_tb]$


1. Reset the size of the DMS table space
alter tablespace tbs_data extend (file '/db2inst2/data_tb/cont0' 100M, file '/db2inst2/data_tb/cont1' 500M)

4. Create a new temporary table space


[db2inst2@localhost shell]$ db2 "create temporary tablespace tbs_temp pagesize 32k managed by system using ('/db2inst2/data_tb/tab_temp') bufferpool bp32k"
DB20000I SQL command completed successfully.
[db2inst2@localhost shell]$

[db2inst2@localhost tab_temp]$ db2 "create user temporary tablespace tbs_usertemp pagesize 32k managed by system using ('/db2inst2/data_tb/tab_usertemp') bufferpool bp32k"
DB20000I SQL command completed successfully.
[db2inst2@localhost tab_temp]$

5. Create a new automatic management table space

[db2inst2@localhost tab_temp]$ db2 "create tablespace tab_data2 initialsize 100M increasesize 100M MAXSIZE 10G"
DB20000I SQL command completed successfully.
[db2inst2@localhost tab_temp]$
[db2inst2@localhost tab_temp]$ db2 "create tablespace tab_data3 pagesize 32k bufferpool bp32k"
DB20000I SQL command completed successfully.
[db2inst2@localhost tab_temp]$

6. Create a new DMS management table space

CREATE TABLESPACE tab_sp4 MANAGED BY DATABASE USING (FILE '/db2inst2/data_tb/tab_sp4' 100M)

7. Add database layer to automatically manage storage

[db2inst2@localhost autodb]$ db2 "alter database ghan add storage on '/db2inst2/autodb'"
DB20000I SQL command completed successfully.
[db2inst2@localhost autodb]$ db2pd -d ghan -storagepaths




8. Modify the DMS table space to automatically store and manage the table space


[db2inst2@localhost T0000008]$ db2 " ALTER TABLESPACE tab_sp4 MANAGED BY AUTOMATIC STORAGE"
DB20000I SQL command completed successfully.
[db2inst2@localhost T0000008]$ db2 "alter tablespace tab_sp4 rebalance"
DB20000I SQL command completed successfully.
[db2inst2@localhost T0000008]$ db2pd -d ghan -tablespaces


[db2inst2@localhost ~]$ db2pd -d ghan -tablespaces


Database Partition 0 -- Database GHAN -- Active -- Up 0 days 00:00:05 -- Date 10/22/2015 03:02:24


Tablespace Configuration:
Address Id Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x00002B810664E400 0 DMS Regular 4096 4 Yes 4 1 1 Off 1 0 3 SYSCATSPACE
0x00002B810664FB80 1 SMS SysTmp 4096 32 Yes 64 1 1 On 2 0 31 TEMPSPACE1
0x00002B81066534C0 2 DMS Large 4096 32 Yes 32 1 1 Off 1 0 31 USERSPACE1
0x00002B8106654C40 3 DMS Large 4096 4 Yes 4 1 1 Off 1 0 3 SYSTOOLSPACE
0x00002B81066563C0 4 DMS Large 32768 32 Yes 64 2 2 Off 2 0 31 TBS_DATA
0x00002B8106657D40 5 SMS SysTmp 32768 32 Yes 32 2 2 On 1 0 31 TBS_TEMP
0x00002B810665B480 6 SMS UsrTmp 32768 32 Yes 32 2 2 On 1 0 31 TBS_USERTEMP
0x00002B810665EBC0 7 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 TAB_DATA2
0x00002B8106660540 8 DMS Large 32768 32 Yes 64 2 2 Off 2 0 31 TAB_DATA3
0x00002B8106661EC0 9 DMS Large 4096 32 Yes 64 1 1 Off 2 0 31 TAB_SP4


Tablespace Statistics:
Address Id TotalPgs UsablePgs UsedPgs PndFreePgs FreePgs HWM Max HWM State MinRecTime NQuiescers PathsDropped
0x00002B810664E400 0 24576 24572 22884 0 1688 22884 22884 0x00000000 0 0 No
0x00002B810664FB80 1 2 2 2 0 0 0 0 0x00000000 0 0 No
0x00002B81066534C0 2 8192 8160 96 0 8064 96 96 0x00000000 0 0 No
0x00002B8106654C40 3 8192 8188 152 0 8036 152 152 0x00000000 0 0 No
0x00002B81066563C0 4 6400 6336 96 0 6240 96 96 0x00000000 0 0 No
0x00002B8106657D40 5 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B810665B480 6 1 1 1 0 0 0 0 0x00000000 0 0 No
0x00002B810665EBC0 7 51200 51136 96 0 51040 96 96 0x00000000 0 0 No
0x00002B8106660540 8 2048 1984 96 0 1888 96 96 0x00000000 0 0 No
0x00002B8106661EC0 9 256 192 96 0 96 96 96 0x00000000 0 0 No


Tablespace Autoresize Statistics:
Address Id AS AR InitSize IncSize IIP MaxSize LastResize LRF
0x00002B810664E400 0 Yes Yes 33554432 -1 No None None No
0x00002B810664FB80 1 Yes No 0 0 No 0 None No
0x00002B81066534C0 2 Yes Yes 33554432 -1 No None None No
0x00002B8106654C40 3 Yes Yes 33554432 -1 No None None No
0x00002B81066563C0 4 No No 0 0 No 0 None No
0x00002B8106657D40 5 No No 0 0 No 0 None No
0x00002B810665B480 6 No No 0 0 No 0 None No
0x00002B810665EBC0 7 Yes Yes 104857600 104857600 No 10737418240 None No
0x00002B8106660540 8 Yes Yes 33554432 -1 No None None No
0x00002B8106661EC0 9 Yes Yes 786432 -1 No None None No


Containers:
Address TspId ContainNum Type TotalPgs UseablePgs PathID StripeSet Container
0x00002B810664F940 0 0 File 24576 24572 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000000/C0000000.CAT
0x00002B8106651060 1 0 Path 1 1 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000001/C0000000.TMP
0x00002B8106651270 1 1 Path 1 1 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000001/C0000001.TMP
0x00002B8106654A00 2 0 File 8192 8160 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000002/C0000000.LRG
0x00002B8106656180 3 0 File 8192 8188 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000003/C0000000.LRG
0x00002B8106657900 4 0 File 3200 3168 - 0 /db2inst2/data_tb/cont0
0x00002B8106657B10 4 1 File 3200 3168 - 0 /db2inst2/data_tb/cont1
0x00002B8106659220 5 0 Path 1 1 - 0 /db2inst2/data_tb/tab_temp
0x00002B810665C960 6 0 Path 1 1 - 0 /db2inst2/data_tb/tab_usertemp
0x00002B8106660100 7 0 File 25600 25568 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000007/C0000000.LRG
0x00002B8106660310 7 1 File 25600 25568 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000007/C0000001.LRG
0x00002B8106661A80 8 0 File 1024 992 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000008/C0000000.LRG
0x00002B8106661C90 8 1 File 1024 992 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000008/C0000001.LRG
0x00002B8106663400 9 0 File 128 96 0 0 /db2inst2/db2inst2/db2inst2/NODE0000/GHAN/T0000009/C0000000. LRG
0x00002B8106663610 9 1 File 128 96 1 0 /db2inst2/autodb/db2inst2/NODE0000/GHAN/T0000009/C0000001.LRG




9. About table space quiesce test

[db2inst2@localhost ~]$ db2 quiesce tablespaces FOR table empl share
DB20000I QUIESCE TABLESPACES command completed successfully

[db2inst2@localhost ~]$ db2 -tsvf create-tm.sql
CREATE TABLE EMPLdd (ENO INTEGER, LASTNAME VARCHAR(30),HIREDATE DATE, SALARY INTEGER) IN TAB_SP4
DB21034E This command is processed as a SQL
statement because it is invalid "Command line processing "device" command. During SQL
processing it returned:
SQL0290N Access to tablespace not allowed. SQLSTATE=55039




Tablespace ID = 9
Name = TAB_SP4
Type = Database Managed Space
Content = All persistent data. Large tablespace.
Status = 0x0001
Detailed explanation:
Paused: SHARE
Total pages = 8448
Available pages = 8384
Used pages = 5504
Available pages = 2880
High water mark (pages) = 5504
Page size (in bytes) = 4096
Extents size (pages) = 32
Prefetch size (pages) = 64
Number of containers = 2
Number of stallers = 1
Staller 1:
Tablespace ID = 9
Object ID = 4



[ db2inst2@localhost ~]$ db2 quiesce tablespaces FOR table empl reset
DB20000I QUIESCE TABLESPACES command completed successfully.
[db2inst2@localhost ~]$ db2 -tsvf create-tm.sql
CREATE TABLE EMPLdd (ENO INTEGER, LASTNAME VARCHAR(30),HIREDATE DATE, SALARY INTEGER) IN TAB_SP4
DB20000I SQL command completed successfully .


[db2inst2@localhost ~]$

Tablespace ID = 9
Name = TAB_SP4
Type = Database Managed Space
Content = all persistent data. Large tablespace.
Status = 0x0000
Detailed explanation:
Normal
Total pages = 8448
Available pages = 8384
Used pages = 5568
Available pages = 2816
High water mark (pages) = 5568
Page size (in bytes) = 4096
Extents size (pages) = 32
Prefetch size (pages) = 64
Containers Number = 2

[db2inst2@localhost ~]$ db2 drop table empl
DB20000I SQL command completed successfully.
[db2inst2@localhost ~]$ db2 list tablespaces show detail

Tablespace ID = 9
Name = TAB_SP4
Type = Database Managed Space
Content = all persistent data. Large tablespace.
Status = 0x0000
Detailed explanation:
Normal
Total pages = 8448
Available pages = 8384
Used pages = 160
Available pages = 8224
High expansion block size (pages) = 32
Prefetch size (pages) = 64
Number of containers = 2


[db2inst2@localhost ~]$ db2 "alter tablespace tab_sp4 lower high water mark"
DB20000I SQL command completed successfully.



Tablespace ID = 9
Name = TAB_SP4
Type = Database Managed Space
Contents = All persistent data. Large tablespace.
Status = 0x0000
Detailed explanation:
Normal
Total pages = 8448
Available pages = 8384
Used pages = 160
Available pages = 8224
High water mark (pages) = 160
Page size (in bytes) = 4096
Extent size (pages) = 32
Prefetch size (pages) = 64
Containers Number = 2


Water mark (pages) = 5568
Page size (in bytes) = 4096
Extended

[db2inst2@localhost ~]$ db2 -tsvf showtables
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_ kb )/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME TABLESPACE_TYPE TOTAL_MB USED_MB FREE_MB PAGE_SIZE
--------- ---------- --------------- -------------------- ---- ---------------- -------------------------------- ----------
SYSCATSPACE ANY 96 89 6 4096
SYSTOOLSPACE LARGE 32 0 31 4096
TAB_DATA2 LARGE 200 0 199 4096
TAB_DATA3 LARGE 64 3 59 32768
TAB_SP4 LARGE 33 0 32 4096
TBS_DATA LARGE 200 3 195 32768
TBS_TEMP SYSTEMP 0 0 0 32768
TBS_USERTEMP USRTEMP 0 0 0 32768
TEMPSPACE1 SYSTEMP 0 0 0 4096
USERSPACE1 LARGE 32 0 31 4096


10 条记录已选择。
[db2inst2@localhost ~]$ db2 -tsvf insert.sql
INSERT INTO EMPL WITH DT(ENO) AS (VALUES(1) UNION ALL SELECT ENO 1 FROM DT WHERE ENO DB21034E 该命令被当作 SQL
语句来处理,因为它是无效的“命令行处理器”命令。在 SQL
处理期间,它返回:
SQL0289N 未能在表空间 "TBS_DATA" 中分配新页面。 SQLSTATE=57011

[db2inst2@localhost ~]$ db2 -tsvf showtables
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_kb)/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME TABLESPACE_TYPE TOTAL_MB USED_MB FREE_MB PAGE_SIZE
-------------------- --------------- -------------------- -------------------- -------------------- -----------
SYSCATSPACE ANY 96 89 6 4096
SYSTOOLSPACE LARGE 32 0 31 4096
TAB_DATA2 LARGE 200 0 199 4096
TAB_DATA3 LARGE 64 3 59 32768
TAB_SP4 LARGE 33 0 32 4096
TBS_DATA LARGE 200 198 0 32768
TBS_TEMP SYSTEMP 0 0 0 32768
TBS_USERTEMP USRTEMP 0 0 0 32768
TEMPSPACE1 SYSTEMP 0 0 0 4096
USERSPACE1 LARGE 32 0 31 4096


10 条记录已选择。
[db2inst2@localhost ~]$

表空间标识 = 4
名称 = TBS_DATA
类型 = 数据库管理空间
内容 = 所有持久数据。大型表空间。
状态 = 0x0000
详细解释:
正常
总计页数 = 6400
可用页数 = 6336
已用页数 = 6336
可用页数 = 0
高水位标记(页) = 6336
页大小(以字节计) = 32768
扩展数据块大小(页) = 32
预取大小(页) = 64
容器数 = 2


DMS表空间添加容器:

alter tablespace tbs_data extend (file '/db2inst2/data_tb/cont0' 100M, file '/db2inst2/data_tb/cont1' 500M)


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1071440.htmlTechArticleDB2 表空间简单说明 一、新建测试库: [db2inst2@localhost shell]$ db2 "create database ghan on /db2inst2/db2inst2 using codeset utf-8 territory cn collate using system...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template