mysql - Unable to create foreign key reference with different column lables -


while creating schema "cannot add foreign key constraint" error getting.

query :

create database sample; use sample;  create table sys_admin_user_t (   sys_admin_id mediumint not null,   admin_name varchar(255) not null,   admin_password varchar(255) not null,   primary key (sys_admin_id) );  create table sys_user_roles_t (   role_id mediumint not null,   privilege_id mediumint not null,   role_name varchar(255) not null,   role_description varchar(255) not null,   created_by mediumint not null,   created_date date not null,   modified_by mediumint not null,   foreign key (privilege_id) references privileges_t (privilege_id),   foreign key (created_by) references sys_admin_user_t(sys_admin_id),   foreign key (modified_by) references sys_admin_user_t(sys_admin_id),   primary key (role_id) ); 

kindly 1 me resolve this.

this can occur in following cases:

  • you not create table privileges_t
  • in table privileges_t not exists primary key field privilege_id
  • the field privilege_id table sys_user_roles_t not same data type in table privileges_t
  • you not using innodb engine on tables

and find specific error run this:

show engine innodb status\g 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -