오류 코드 : 1005 테이블 'custom_db2.durableProfile'(errno : 150)을 만들 수 없습니다.

StackOverflow https://stackoverflow.com//questions/25014220

  •  21-12-2019
  •  | 
  •  

문제

데이터베이스를 만들 수 없습니다

--------------------------------------------------------
create table DurableArticle(

    durable_code varchar(30) not null,
    durable_name varchar(100),
    durable_number varchar(20),
    durable_brandname varchar(125),
    durable_modelordetail varchar(125), 
    durable_price varchar(20),
    durable_entrance varchar(20),

    constraint durable_PK primary key (durable_code)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

---------------------------------------------


create table DurableProfile(

    profile_year integer not null,
    profile_status varchar(100),
    profile_note varchar(100),
    staff_id integer not null,
    owner_id integer not null,
    room_id integer not null,
    durable_code varchar(30) not null,

    constraint profile_PK primary key (profile_year,durable_code),
    constraint profile_FK1 foreign key (staff_id) references staff(staff_id),
    constraint profile_FK2 foreign key (owner_id) references owner(owner_id),
    constraint profile_FK3 foreign key (room_id) references room(room_id),
    constraint profile_Fk4 foreign key (durable_code) references durablearticle (durable_code)

)ENGINE=InnoDB;
.

도움이 되었습니까?

해결책

두 번째 문장에서 3 개의 테이블을 참조하여 분명히 존재하지 않습니다 (아직). 외부 키를 제거하거나 해당 테이블을 만들면 작동합니다.

create table DurableProfile(

    profile_year integer not null, 
    profile_status varchar(100), 
    profile_note varchar(100), 
    staff_id integer not null, 
    owner_id integer not null, 
    room_id integer not null, 
    durable_code varchar(30) not null,

    constraint profile_PK primary key (profile_year,durable_code), 
    constraint profile_Fk4 foreign key (durable_code) references durablearticle (durable_code)

)ENGINE=InnoDB;
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top