在数据库应用项目的生命周期中充分利用 DB2 目录视图的最佳实践
2010-07-12 00:00:00 来源:WEB开发网在数据库开发和调试阶段,会遇到各种各样的错误,查询目录视图是对错误分析的一个有益补充。如 清单 2.所示,当试图删除 customer_info 表中的列 cust_name 时发生错误。通过分析目录视图 syscat.tables 了解到该表设置了 DATA CAPTURE 属性,意味着该表总是将数据变化写入系统日志,这个条件阻碍了删除表字段的操作。在关闭了这个表属性(DATA CAPTURE NONE)后,字段 cust_name 可以从表中删除。
清单 2. 当试图删除 customer_info 表中的列 cust_name 时发生错误
db2=> alter table test.customer_info drop cust_name
DB21034E The command was processed as
an SQL statement because it was not a
valid Command Line Processor command.
During SQL processing it returned:
SQL0270N Function not supported
(Reason code = "100"). SQLSTATE=42997
db2=> select DATACAPTURE from syscat.tables
where tabname = upper('customer_info')
and tabschema = upper('test')
DATACAPTURE
-----------
Y
db2=> alter table test.customer_info data capture none
DB20000I The SQL command completed successfully.
db2=> select DATACAPTURE from syscat.tables
where tabname = upper('customer_info')
and tabschema = upper('test')
DATACAPTURE
-----------
N
db2=> alter table test.customer_info drop cust_name
DB20000I The SQL command completed successfully.
更多精彩
赞助商链接