MySQL foreign key in a table in another database?

Is it possible to bind (InnoDB) a foreign key in another database in MySQL?

Is this a bad practice?

+4
source share
2 answers

Yes, it is possible on the same database server. The database name prefix when adding a constraint, for example. databasename.tablename.fieldname . Observe user permissions.

I do not consider this a bad practice, although this is not something that should happen very often.

+4
source

Yes, you can use the foreign key link in another database in MYSQL.

Thanks.

+1
source

Source: https://habr.com/ru/post/1314911/


All Articles