尝试使用联合运算符或子选择在具有 RoS(只读备用)的 HADR 数据库中执行一些查询,我收到错误 SQL1773N 原因代码 5。
是什么原因?它们是不生成写入的操作。
联盟
with hist(start_time, operationtype) as (
select start_time, operationtype
from sysibmadm.db_history
where operation = 'B' )
select 'delta', timestampdiff(8, current timestamp - char(timestamp(max(start_time))))
from hist
where operationtype = 'D' or operationtype = 'E'
union all
select 'delta', timestampdiff(8, current timestamp - char(timestamp(max(start_time))))
from hist
where operationtype = 'I' or operationtype = 'O'
子选择
with hist(start_time, operationtype) as (
select start_time, operationtype
from sysibmadm.db_history
where operation = 'B' )
select 'delta', operationtype, start_time, timestampdiff(8, current timestamp - char(timestamp(start_time)))
from hist
where start_time = (
select max(start_time)
from hist
where operationtype = 'D' or operationtype = 'E')