1. 程式人生 > >建聯合主鍵報錯DB2 Database Error: ERROR [42997] [IBM][DB2/AIX64] SQL0270N Function not supported (Reason c

建聯合主鍵報錯DB2 Database Error: ERROR [42997] [IBM][DB2/AIX64] SQL0270N Function not supported (Reason c

CREATE TABLE "mmm"."test" (   --建表語句
  "A" DATE,
  "B" VARCHAR(36),
  "C" VARCHAR(50),
  "D" VARCHAR(25) not null,
  "E" VARCHAR(15) not null,

  ) IN "MA_DATA"

DISTRIBUTE BY hash ("C") ; 

alter table "mmm"."test" add primary key(D,E);   --建立聯合主鍵語句  就是執行這個語句時報此錯誤;


錯誤原因是必須要把 DISTRIBUTE BY hash ("C") ;  改為聯合主鍵的任意一個欄位就ok了

如下 

drop table "mmm"."test" ;

CREATE TABLE "mmm"."test" (   --建表語句
  "A" DATE,
  "B" VARCHAR(36),
  "C" VARCHAR(50),
  "D" VARCHAR(25) not null,
  "E" VARCHAR(15) not null,

  ) IN "MA_DATA"

DISTRIBUTE BY hash ("D") ;