开发者

MySQL Foreign Key in Table in Another Database?

开发者 https://www.devze.com 2023-01-06 17:44 出处:网络
Is it possible to reference (Inn开发者_如何学编程oDB) a foreign key in another database in MySQL?

Is it possible to reference (Inn开发者_如何学编程oDB) a foreign key in another database in MySQL?

Is this bad practice?


Yes, it's possible on the same DB server. Prefix the database name when adding the constraint, e.g. databasename.tablename.fieldname. Watch your user permissions.

I don't consider it bad practice, though it's not something that should be happening very often.


Yes, You can use reference a foreign key in another database in MYSQL.

Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消