create table primarytable
(
  A   NUMBER not null,
  B       VARCHAR2(30) ,
 )
alter table primarytable
  add constraint FK_NAME foreign key (B)
  references foreignTalbe (B);

解决方案 »

  1.   

    楼上的写法稍微有点差错~
    注意标点符号:
    create table primarytable
    (
      A   NUMBER not null,
      B       VARCHAR2(30)
     );
    alter table primarytable
      add constraint FK_NAME foreign key (B)
      references foreignTalbe (B);
      

  2.   

    CREATE TABLE t1 (
       pk NUMBER PRIMARY KEY,
       fk NUMBER,
       c1 NUMBER,
       c2 NUMBER,
       CONSTRAINT ri FOREIGN KEY (fk) REFERENCES t1,
       CONSTRAINT ck1 CHECK (pk > 0 and c1 > 0),
       CONSTRAINT ck2 CHECK (c2 > 0)
    );
      

  3.   

    create table TABLENAME(
       ANUMBER(9)                        not null,
       JSJ                  CHAR(8)                          not null,
       XJZ                  CHAR(8)                          not null,
       ZDXH                 NUMBER(9)                        not null,
       DDRQ                 DATE                             not null,
       BJBZ                 CHAR                             not null,
       constraint CCKLDB_PK1 primary key (LDXH)
             using index
           pctfree 1
           tablespace yz_flow2_inx
    )
      

  4.   

    create table TABLENAME  (
       A                 NUMBER(9)                        not null,
       B                  CHAR(8)                          not null,
       C                  CHAR(8)                          not null,
       constraint TABLENAME_PK1 primary key (A)
             using index
    );