我正在尝试在DB2 v10.5中创建DB2 MQT表,但是我收到以下错误消息:
意外的令牌“CREATE TABLE T_MQT AS( 在“BEGIN-OF-STATEMENT”之后找到SELECT ID,COL1,C“。预期的令牌可能包括:”“.. SQLCODE = -104,SQLSTATE = 42601,DRIVER = 4.16.53 SQL代码:-104,SQL状态: 42601
这是我的create table语句:
CREATE TABLE T ( ID VARCHAR(128) NOT NULL, COL1 VARCHAR(128), COL2 VARCHAR(128), COL3 VARCHAR(128), COL4 VARCHAR(128), COL5 VARCHAR(128), PRIMARY KEY (ID) ); CREATE TABLE T_MQT AS ( SELECT ID, COL1, COL2, COL3 FROM T ) DATA INITIALLY DEFERRED REFRESH IMMEDIATE SET INTEGRITY FOR T_MQT IMMEDIATE CHECKED NOT INCREMENTAL;
答案 0 :(得分:0)
您在CREATE TABLE T_MQT ...
语句和SET INTEGRITY
语句之间缺少分号。
答案 1 :(得分:0)
我发现原因是基表是“ORGANIZE BY COLUMN”。所以我将sql改为
CREATE TABLE T ( ID INTEGER NOT NULL, COL1 VARCHAR(128), COL2 VARCHAR(128), COL3 VARCHAR(128), COL4 VARCHAR(128), COL5 VARCHAR(128), PRIMARY KEY (ID) ) ORGANIZE BY ROW; CREATE TABLE T_MQT ( ID, COL1, COL2, COL3 ) AS ( select ID, COL1, COL2, COL3 from T ) DATA INITIALLY DEFERRED REFRESH IMMEDIATE MAINTAINED BY SYSTEM; SET INTEGRITY FOR T_MQT IMMEDIATE CHECKED FULL ACCESS;