建联合主键报错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 code = "1").  SQLSTATE=42997的问题

报错的sql语句:

建表的语句:
CREATE TABLE "MABAS"."WRK_MAP_ORACLE_SASB_PROD" (   --建表语句
  "REPORT_DATE" DATE,
  "DATA_SUPPLY" VARCHAR(36),
  "UNIQUE_NO" VARCHAR(50),
  "ORG_UNIT_ID" VARCHAR(25) not null,
  "SASB_COA_ID" VARCHAR(15) not null,
  "PROD_LOB_ID" VARCHAR(15),
  "CUST_TYPE_CD" VARCHAR(15)
  ) IN "MA_DATA"
  INDEX IN "MA_INDEX";

 

alter table "MABAS"."WRK_MAP_ORACLE_SASB_PROD" add primary key(ORG_UNIT_ID,SASB_COA_ID);   --创建联合主键语句  就是运行这个语句时报此错误;

原因:

在建表时ORG_UNIT_ID,SASB_COA_ID这两个字段应该放在最前面(db2的联合主键的字段必须在建表语句时必须放在最前面)比如:
CREATE TABLE "MABAS"."WRK_MAP_ORACLE_SASB_PROD" (
  "ORG_UNIT_ID" VARCHAR(25) not null,
  "SASB_COA_ID" VARCHAR(15) not null,
  "REPORT_DATE" DATE,
  "DATA_SUPPLY" VARCHAR(36),
  "UNIQUE_NO" VARCHAR(50),
  "PROD_LOB_ID" VARCHAR(15),
  "CUST_TYPE_CD" VARCHAR(15)
  ) IN "MA_DATA"
  INDEX IN "MA_INDEX";

 

 

你可能感兴趣的:(建联合主键报错DB2 Database Error: ERROR [42997] [IBM][DB2/AIX64] SQL0270N Function not supported (Reason c)