我有两个定义相同但所有者不同的表。 基于以下之一创建新表:
CREATE TABLE SHADOW.ADM LIKE USR1.ADM;
ALTER TABLE SHADOW.ADM ADD SHTYPE CHAR(1);
ALTER TABLE SHADOW.ADM ADD SHCOUNTER INTEGER GENERATED ALWAYS AS IDENTITY;
CREATE UNIQUE INDEX SHADOW.IXADM ON SHADOW.ADM(SHCOUNTER) USING STOGROUP SG1;
当我尝试执行下面的SQL时,出现语法错误:
INSERT INTO SHADOW.ADM
OVERRIDING USER VALUE
SELECT A.*,0 FROM
(SELECT O.*,'B' FROM USR1.ADM O UNION ALL
SELECT N.*,'A' FROM USR2.ADM N) A;
错误是:
OVERRIDING USER VALUE CLAUSE IS NOT PERMITTED. SQLCODE=-109, SQLSTATE=42601, DRIVER=3.72.44
奇怪的是,下面的SQL执行没有错误:
INSERT INTO SHADOW.ADM
OVERRIDING USER VALUE
SELECT A.*,'B',0 FROM USR1.ADM A;
这是DB2的SQL解析器中的错误还是我缺少了什么?
btw:这是在DB2 z / OS V7版上,可以从DBeaver作为客户端访问。