新建表添加主外键约束

新建表添加主外键约束

1.

 

CREATE TABLE WFWZ_SSBS
(
   SSBSID               VARCHAR2(10)           not null,
   XWBH                 NUMBER(4),
   WFWZ_LZBS            VARCHAR(255),
   WFWZ_WSBS            VARCHAR(255),
   LRRQ                 DATE,
   LRR_DM               VARCHAR(4),
   YXBJ_DM              VARCHAR(2),
   CONSTRAINT PK_WFWZ_SSBS PRIMARY KEY (SSBSID),
   CONSTRAINT FK_WFWZ_SSBS FOREIGN KEY(XWBH) REFERENCES USER_ACCOUNT(USERID)
);

 2.

CREATE TABLE WFWZ_SSBS
(
   SSBSID               VARCHAR2(10)           not null,
   XWBH                 NUMBER(4),
   WFWZ_LZBS            VARCHAR(255),
   WFWZ_WSBS            VARCHAR(255),
   LRRQ                 DATE,
   LRR_DM               VARCHAR(4),
   YXBJ_DM              VARCHAR(2),
   CONSTRAINT PK_WFWZ_SSBS PRIMARY KEY (SSBSID)
);

ALTER TABLE WFWZ_SSBS ADD CONSTRAINT FK_WFWZ_SSBS FOREIGN KEY(XWBH) REFERENCES USER_ACCOUNT(USRID);
 

你可能感兴趣的:(Oracle)