rt
外键是int类型的,不能建立外键。
不能解决吗?

解决方案 »

  1.   

    可以啊你的 create table 语句是什么?贴出来,大家可以测试一下。
      

  2.   

    create table DG (
    ID                   SERIAL (10)  not null,
    PID                  NUMERIC(5)           null,
    NAME                 VARCHAR(64)          not null,

    constraint PK_M2MNAP_DG primary key (ID)
    );alter table DG
       add constraint FK_M2MNAP_DG_SELF foreign key (PID)
          references DG (ID)
          on delete restrict on update restrict;建立外键无法成功,错误提示说数据类型不一直,
    表的主键是NUMERIC就没为题。数字与字符串做主外键也有这个问题。
      

  3.   

    改表PID字段为integer       reate table DG (
    ID           SERIAL (10)  not null,
    PID          integer       null,
    NAME         VARCHAR(64)      not null,
      

  4.   

    字段类型要一致,SERIAL是INT型,将PID修改为INT