Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Not able to add Foreign key on table column

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 277
    Comment on it

    Error Code : 1005 Can't create table 'DatabaseName.#sql-9cc_1' (errno: 150) (0 ms taken)

    After searching a lot i have got solution for the above problem while i was adding FK to a column. The error was because of different MySQL engine. There are different MySQL engines and the table i had PK (Primary Key ) was on InnoDB Engine and the other table on which i was putting FK (Foreign Key)constraint was on MyISAM Engine.

    Change MySQL Engine using following Command

    ALTER TABLE blob_data ENGINE=InnoDB;
    

    Now Add Constraint Foring Key as:

    ALTER TABLE users_role_map
    ADD CONSTRAINT FK_users_role_map1
    FOREIGN KEY (email) REFERENCES usert(email)
    ON UPDATE CASCADE
    ON DELETE CASCADE
    

    If still not able to solve the issue,follow the link below : Read the link data you may find the solution.

    stackoverflow.com

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: