Search

'foreign key'에 해당되는 글 1건

  1. 2010.05.20 Oracle - foreign key 생성

Oracle - foreign key 생성

Database 2010.05.20 11:13 Posted by 파란크리스마스

CREATE TABLE ERD_EMP (
  EMP_ID         NUMBER            NOT NULL,
  EMP_NAME       VARCHAR2(256)         NULL,
  EMP_ADDRESS    VARCHAR2(256)         NULL,
  EMP_TEL        VARCHAR2(256)         NULL,
  DEPT_ID        NUMBER                NULL,
  CONSTRAINT PK_ERD_EMP PRIMARY KEY(EMP_ID)
);

CREATE TABLE ERD_DEPT (
  DEPT_ID      NUMBER            NOT NULL,
  DEPT_NAME    VARCHAR2(256)         NULL,
  CONSTRAINT PK_ERD_DEPT PRIMARY KEY(DEPT_ID)
);

ALTER TABLE ERD_EMP ADD
(
    CONSTRAINT FK_DEPTNO
    FOREIGN KEY ( DEPT_ID )
        REFERENCES ERD_DEPT ( DEPT_ID )
);


 

신고


 

티스토리 툴바