db2怎么查看表空间使用率
2个回答
展开全部
db2 查看表空间使用率
1. 统计所有节点表空间使用率
select substr(TABLESPACE_NAME,1,20) as TBSPC_NAME,bigint(TOTAL_PAGES * PAGE_SIZE)/1024/1024 as "TOTAL(MB)",
used_pages*PAGE_SIZE/1024/1024 as "USED(MB)", free_pages*PAGE_SIZE/1024/1024 as "FREE(MB)"
from table(snapshot_tbs_cfg('DB_NAME', -2)) as snapshot_tbs_cfg
2、查看表空间使用率
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
3、通过存储过程查看数据库大小和容量
db2 call GET_DBSIZE_INFO (?,?,?,0)
输出参数的值
--------------------------
参数名: SNAPSHOTTIMESTAMP
参数值: 2008-05-26-10.53.06.421000
参数名: DATABASESIZE
参数值: 1203863552
参数名: DATABASECAPACITY
参数值: 4281493504
unit=byte, byte/1024/1024=m
db2 call GET_DBSIZE_INFO (?,?,?,0)
注意:
a、从V8以上版本支持,此存储过程看数据库大小和容量;如果要看各表空间使用情况上面的sql方便,
b、还有DPF环境下,db2 call GET_DBSIZE_INFO (?,?,?,0)只能看dbsize大小,无法看db的容量
SYSIBM.SYSTABLESPACES
SYSIBM.SYSTBSPACEAUTH
2.db2查看表空间和增加表空间容量
Db2 connect to xxx
Db2 “LIST TABLESPACES SHOW DETAIL”
Tablespace ID = 7
Name = TSASNAA
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
Total pages = 14800
Useable pages = 14752
Used pages = 12864
Free pages = 1888
High water mark (pages) = 12864
Page size (bytes) = 8192
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
增加表空间大小
DB2数据库使用时,如果表空间满了,该如何扩容呢?下文将教给您DB2数据库表空间扩容的方法,供您参考,希望对您有所帮助。
1)直接添加一个容器的例子:
db2 " ALTER TABLESPACE PAYROLL ADD (DEVICE '/dev/rhdisk9' 10000) "
加容器之后DB2会有一个自动balance的过程,可能会持续几个小时!!! 一定要注意该选项,修改前确认该选项是否能满足业务需求!
2)改变现有容器的大小(该方法不会触发balance,但如果表空间建立在裸设备上,则要扩冲裸设备空间):
db2 " ALTER TABLESPACE TS1 RESIZE (FILE '/conts/cont0' 2000, DEVICE '/dev/rcont1' 2000, FILE 'cont2' 2000) "
注意这种方式就是将原有的相应容器都改成大小是2000页
db2 "ALTER TABLESPACE TS1 RESIZE (ALL 2000)"
这种方式就是把表空间中所有的容器大小都改成2000页
db2 " ALTER TABLESPACE TS1 EXTEND (FILE '/conts/cont0' 1000, DEVICE '/dev/rcont1' 1000, FILE 'cont2' 1000) "
这种方式就是将相应的容器都扩大1000页,也就是增加1000页。
db2 " ALTER TABLESPACE DATA_TS EXTEND (ALL 1000)"
这种方式就是将所有的容器都增加1000页。
3.db2数据字典
select name from sysibm.systables where type='T' and creator='USERID' and tbspace='TS4R_DNJC' order by name;
select name from sysibm.systables where type='V' and creator='USERID' order by name;
type:数据库表用T表示;数据库视图用V表示
creator:数据库对象的创建者
select * from sysibm.syscolumns
select tabname from syscat.tables where tabschema=current schema ;
获取当前模式下面的所有用户表
describe table XXXX
SELECT NAME
,COLNO
,COLTYPE || '('
|| CAST(LENGTH AS CHAR(5)) || ','
|| CAST(SCALE AS CHAR(5)) || ')'
,CASE WHEN NULLS = 'N'
THEN 'NOT NULL' ELSE ' ' END
,TBNAME
WHERE TBCREATOR = 'TEST' -- < OR 'TEST'
-- AND (NAME = 'YOUR_COL_NAME' -- < COLUMN NAME \ ONLY USE ONE
AND (TBNAME = 'T_QUICK_MENU' -- < TABLE NAME /
)
ORDER BY TBNAME, COLNO
SELECT NAME FROM SYSIBM.SYSCOLUMNS
1. 统计所有节点表空间使用率
select substr(TABLESPACE_NAME,1,20) as TBSPC_NAME,bigint(TOTAL_PAGES * PAGE_SIZE)/1024/1024 as "TOTAL(MB)",
used_pages*PAGE_SIZE/1024/1024 as "USED(MB)", free_pages*PAGE_SIZE/1024/1024 as "FREE(MB)"
from table(snapshot_tbs_cfg('DB_NAME', -2)) as snapshot_tbs_cfg
2、查看表空间使用率
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
3、通过存储过程查看数据库大小和容量
db2 call GET_DBSIZE_INFO (?,?,?,0)
输出参数的值
--------------------------
参数名: SNAPSHOTTIMESTAMP
参数值: 2008-05-26-10.53.06.421000
参数名: DATABASESIZE
参数值: 1203863552
参数名: DATABASECAPACITY
参数值: 4281493504
unit=byte, byte/1024/1024=m
db2 call GET_DBSIZE_INFO (?,?,?,0)
注意:
a、从V8以上版本支持,此存储过程看数据库大小和容量;如果要看各表空间使用情况上面的sql方便,
b、还有DPF环境下,db2 call GET_DBSIZE_INFO (?,?,?,0)只能看dbsize大小,无法看db的容量
SYSIBM.SYSTABLESPACES
SYSIBM.SYSTBSPACEAUTH
2.db2查看表空间和增加表空间容量
Db2 connect to xxx
Db2 “LIST TABLESPACES SHOW DETAIL”
Tablespace ID = 7
Name = TSASNAA
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x0000
Detailed explanation:
Normal
Total pages = 14800
Useable pages = 14752
Used pages = 12864
Free pages = 1888
High water mark (pages) = 12864
Page size (bytes) = 8192
Extent size (pages) = 32
Prefetch size (pages) = 32
Number of containers = 1
增加表空间大小
DB2数据库使用时,如果表空间满了,该如何扩容呢?下文将教给您DB2数据库表空间扩容的方法,供您参考,希望对您有所帮助。
1)直接添加一个容器的例子:
db2 " ALTER TABLESPACE PAYROLL ADD (DEVICE '/dev/rhdisk9' 10000) "
加容器之后DB2会有一个自动balance的过程,可能会持续几个小时!!! 一定要注意该选项,修改前确认该选项是否能满足业务需求!
2)改变现有容器的大小(该方法不会触发balance,但如果表空间建立在裸设备上,则要扩冲裸设备空间):
db2 " ALTER TABLESPACE TS1 RESIZE (FILE '/conts/cont0' 2000, DEVICE '/dev/rcont1' 2000, FILE 'cont2' 2000) "
注意这种方式就是将原有的相应容器都改成大小是2000页
db2 "ALTER TABLESPACE TS1 RESIZE (ALL 2000)"
这种方式就是把表空间中所有的容器大小都改成2000页
db2 " ALTER TABLESPACE TS1 EXTEND (FILE '/conts/cont0' 1000, DEVICE '/dev/rcont1' 1000, FILE 'cont2' 1000) "
这种方式就是将相应的容器都扩大1000页,也就是增加1000页。
db2 " ALTER TABLESPACE DATA_TS EXTEND (ALL 1000)"
这种方式就是将所有的容器都增加1000页。
3.db2数据字典
select name from sysibm.systables where type='T' and creator='USERID' and tbspace='TS4R_DNJC' order by name;
select name from sysibm.systables where type='V' and creator='USERID' order by name;
type:数据库表用T表示;数据库视图用V表示
creator:数据库对象的创建者
select * from sysibm.syscolumns
select tabname from syscat.tables where tabschema=current schema ;
获取当前模式下面的所有用户表
describe table XXXX
SELECT NAME
,COLNO
,COLTYPE || '('
|| CAST(LENGTH AS CHAR(5)) || ','
|| CAST(SCALE AS CHAR(5)) || ')'
,CASE WHEN NULLS = 'N'
THEN 'NOT NULL' ELSE ' ' END
,TBNAME
WHERE TBCREATOR = 'TEST' -- < OR 'TEST'
-- AND (NAME = 'YOUR_COL_NAME' -- < COLUMN NAME \ ONLY USE ONE
AND (TBNAME = 'T_QUICK_MENU' -- < TABLE NAME /
)
ORDER BY TBNAME, COLNO
SELECT NAME FROM SYSIBM.SYSCOLUMNS
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
2015-08-06 · 知道合伙人软件行家
关注
展开全部
1. 统计所有节点表空间使用率
select substr(TABLESPACE_NAME,1,20) as TBSPC_NAME,bigint(TOTAL_PAGES * PAGE_SIZE)/1024/1024 as "TOTAL(MB)",
used_pages*PAGE_SIZE/1024/1024 as "USED(MB)", free_pages*PAGE_SIZE/1024/1024 as "FREE(MB)"
from table(snapshot_tbs_cfg('DB_NAME', -2)) as snapshot_tbs_cfg
2、查看表空间使用率
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
select substr(TABLESPACE_NAME,1,20) as TBSPC_NAME,bigint(TOTAL_PAGES * PAGE_SIZE)/1024/1024 as "TOTAL(MB)",
used_pages*PAGE_SIZE/1024/1024 as "USED(MB)", free_pages*PAGE_SIZE/1024/1024 as "FREE(MB)"
from table(snapshot_tbs_cfg('DB_NAME', -2)) as snapshot_tbs_cfg
2、查看表空间使用率
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询