测试中,有时候需要临时修改/删除表中的数据,又不能影响用户的测试。这时,便需要使用PATCH来改变数据。
具体的方法是,在大机环境下,编写shell脚本来执行db2命令。
举例:
#! /usr/bin/ksh
#
#
#
db2 connect to 表名 user <userid> using <password>
db2 set current schema <schema名>
#导出表中数据,备份检证用
db2 "export to T37A00MG_01BEFORE.csv of del messages export.log select * from T37A00MG"
db2 "export to T37A00SF_01BEFORE.csv of del messages export.log select * from T37A00SF"
#查询
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00MG group by KA4ZN,TE0WA"
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00SF group by KA4ZN,TE0WA"
#更新数据
db2 "update T37A00MG set TE0WA='SYSTEM' where TE0WA<> 'SYSTEM'"
db2 "update T37A00SF set TE0WA='SYSTEM' where TE0WA<> 'SYSTEM'"
#查询确认
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00MG group by KA4ZN,TE0WA"
db2 "select KA4ZN,TE0WA,COUNT(*) from T37A00SF group by KA4ZN,TE0WA"
#导出表中数据,备份检证用
db2 "export to T37A00MG_02AFTER.csv of del messages export.log select * from T37A00MG"
db2 "export to T37A00SF_02AFTER.csv of del messages export.log select * from T37A00SF"