对DB2的sample数据库进行数据迁移后,如何在新的数据库中,使那些处于set integrity pending 的表从此状态解脱出来呢?
db2 connect to db_name
db2 -tx +w "
with gen(tabname,
seq) as
(select rtrim(tabschema) || '.' || rtrim(tabname) as tabname,row_number() over(partition by status) as seq
from syscat.tables where status = 'C'),
r(a, seq1) as
(select cast(tabname as varchar(3900)), seq
from gen where seq = 1
union all
select r.a || '.' || rtrim(gen.tabname), gen.seq from gen, r where (r.seq1 + 1) = gen.seq),
r1 as
(select a, seq1 from r)
select 'SET INTEGRITY FOR ' || a || ' IMMEDIATE CHECKED;'
from r1 where seq1 = (select max(seq1) from r1)">>db2FixCheckIntegrityPending.sql
db2 -tvf db2FixCheckIntegrityPending.sql