728x90

메세지

ORA-02264: name already used by an existing constraint 02264. 00000 - "name already used by an existing constraint"

*Cause: The specified constraint name has to be unique.

*Action: Specify a unique constraint name for the constraint.

 

원인

테이블명이 달라도 제약조건이 겹치면 에러 발생

 

상황

USER_GRADE2테이블을 USER_FOREIGNKEY2테이블에서 FOREIN KEY 제약조건을 걸려던 중 발생

 

해결

겹치는 제약 조건을 삭제

제약조건 삭제 ALTER TABLE 테이블명 DROP CONSTRAINT 제약조건명;

 

참고 코드

CREATE TABLE USER_GRADE2(
    GRADE_CODE NUMBER PRIMARY KEY,
    GRADE_NAME VARCHAR2(30) NOT NULL
);
INSERT INTO USER_GRADE2 VALUES(10, '일반회원');
INSERT INTO USER_GRADE2 VALUES(20, '우수회원'); 
INSERT INTO USER_GRADE2 VALUES(30, '특별회원');

CREATE TABLE USER_FOREIGNKEY2(
    USER_NO NUMBER PRIMARY KEY,
    USER_ID VARCHAR2(20) UNIQUE,
    USER_PWD VARCHAR2(30) NOT NULL,
    USER_NAME VARCHAR2(30),
    GENDER VARCHAR2(10),
    PHONE VARCHAR2(30),
    EMAIL VARCHAR2(50),
    GRADE_CODE NUMBER,
    CONSTRAINT UF_GC_FK FOREIGN KEY(GRADE_CODE) REFERENCES USER_GRADE2(GRADE_CODE)
);/* ERROR 발생
ORA-02264: name already used by an existing constraint
02264. 00000 -  "name already used by an existing constraint"
*Cause:    The specified constraint name has to be unique.
*Action:   Specify a unique constraint name for the constraint.
*/
728x90
반응형

+ Recent posts