Search code examples
mysqldatabaseforeign-keysinnodb

MySQL InnoDB foreign key between different databases


I would like to know if it's possible in InnoDB in MySQL to have a table with foreign key that references another table in a different database ?

And if so, how this can be done ?


Solution

  • I do not see any limitation on https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html.

    So just use otherdb.othertable and you will be good.