Db2 无法在HADR standby中执行子选择或联合操作
尝试使用union运算符或subselect在HADR数据库中使用RoS Read only Standby执行某些查询时,我得到了错误SQL1773N原因代码5 原因是什么?它们是不生成写入的操作 联合 再选择Db2 无法在HADR standby中执行子选择或联合操作,db2,union,subquery,standby,Db2,Union,Subquery,Standby,尝试使用union运算符或subselect在HADR数据库中使用RoS Read only Standby执行某些查询时,我得到了错误SQL1773N原因代码5 原因是什么?它们是不生成写入的操作 联合 再选择 with hist(start_time, operationtype) as ( select start_time, operationtype from sysibmadm.db_history where operation = 'B' ) select 'delta',
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')
这似乎是sysibmadm.db_历史中特有的问题。 在启用ROS的情况下,在待机状态下尝试了以下union all和subSelect,两者都工作正常
CREATE TABLE TAB101 (
id bigint NOT NULL,
createTimestamp TIMESTAMP NOT NULL,
primary key (id))
insert into tab101 (id, CREATETIMESTAMP) values
(1, current timestamp - 35 minutes),
(2, current timestamp - 30 minutes),
(3, current timestamp - 25 minutes),
(4, current timestamp - 20 minutes),
(5, current timestamp - 15 minutes),
(6, current timestamp - 10 minutes),
(7, current timestamp - 5 minutes),
(8, current timestamp)
with tempTab101 (id, CREATETIMESTAMP) as (
select id, CREATETIMESTAMP from tab101
)
select id, CREATETIMESTAMP from tempTab101
where id > 1
union all
select id, CREATETIMESTAMP from tempTab101
where id <= 10
with tempTab101 (id, CREATETIMESTAMP) as (
select id, CREATETIMESTAMP from tab101
)
select * from tempTab101
where id = (
select id from tempTab101 where id=2
)
这可能只是一个猜测,它必须将这些子查询具体化为一个工作文件,该文件仍然被视为在待机状态下的写入。我同意你的观点,但是文档中没有定义这一点。文档说,在待机状态下的数据库上的查询只能使用SMS系统临时表空间。这可能与此相关,最好检查一下。
CREATE TABLE TAB101 (
id bigint NOT NULL,
createTimestamp TIMESTAMP NOT NULL,
primary key (id))
insert into tab101 (id, CREATETIMESTAMP) values
(1, current timestamp - 35 minutes),
(2, current timestamp - 30 minutes),
(3, current timestamp - 25 minutes),
(4, current timestamp - 20 minutes),
(5, current timestamp - 15 minutes),
(6, current timestamp - 10 minutes),
(7, current timestamp - 5 minutes),
(8, current timestamp)
with tempTab101 (id, CREATETIMESTAMP) as (
select id, CREATETIMESTAMP from tab101
)
select id, CREATETIMESTAMP from tempTab101
where id > 1
union all
select id, CREATETIMESTAMP from tempTab101
where id <= 10
with tempTab101 (id, CREATETIMESTAMP) as (
select id, CREATETIMESTAMP from tab101
)
select * from tempTab101
where id = (
select id from tempTab101 where id=2
)