DB2 统计表所有列长度之和

 

ContractedBlock.gif ExpandedBlockStart.gif Code
describe select * from syscat.column

select sun(length) as total_length 
from syscat.column 
where tabschema ='schemaname' and tabname ='tabname'

 

This statement can be used for caculate a tough table space occupied.

-----------------------------------------------------------------------------------------------------

About : SYSCAT

The database manager creates and maintains two sets of system catalog views that are defined on top of the base system catalog tables:SYSCAT and SYSSTAT

 

  • SYSCAT views are read-only catalog views that are found in the SYSCAT schema. SELECT privilege on these views is granted to PUBLIC by default.
  • SYSSTAT views are updatable catalog views that are found in the SYSSTAT schema. The updatable views contain statistical information that is used by the optimizer. The values in some columns in these views can be changed to test performance. (Before changing any statistics, it is recommended that the RUNSTATS command be invoked so that all the statistics reflect the current state.) Applications should be written to the SYSSTAT views rather than the base catalog tables.

 

All the system catalog views are created at database creation time. The catalog views cannot be explicitly created or dropped. The views are updated during normal operation in response to SQL data definition statements, environment routines, and certain utilities. Data in the system catalog views is available through normal SQL query facilities. The system catalog views (with the exception of some updatable catalog views) cannot be modified using normal SQL data manipulation statements.

An object (table, column, function, or index) will appear in a user's updatable catalog view only if that user created the object, holds CONTROL privilege on the object, or holds explicit DBADM authority.

The order of columns in the views may change from release to release. To prevent this from affecting programming logic, specify the columns in a select list explicitly, and avoid using SELECT *. Columns have consistent names based on the types of objects that they describe.

Described Object
Column Names
Table
TABSCHEMA, TABNAME
Index
INDSCHEMA, INDNAME
View
VIEWSCHEMA, VIEWNAME
Constraint
CONSTSCHEMA, CONSTNAME
Trigger
TRIGSCHEMA, TRIGNAME
Package
PKGSCHEMA, PKGNAME
Type
TYPESCHEMA, TYPENAME, TYPEID
Function
ROUTINESCHEMA, ROUTINENAME, ROUTINEID
Method
ROUTINESCHEMA, ROUTINENAME, ROUTINEID
Procedure
ROUTINESCHEMA, ROUTINENAME, ROUTINEID
Column
COLNAME
Schema
SCHEMANAME
Table Space
TBSPACE
Database partition group
NGNAME
Buffer pool
BPNAME
Event Monitor
EVMONNAME
Creation Timestamp
CREATE_TIME

 

转载于:https://www.cnblogs.com/alexkong/archive/2008/12/19/1358085.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值