View Full Version : foreign key to another db on same server - question

02-23-2009, 11:38 PM

in phpMyAdmin, I have created a table with a foreign key, which references a pk from another table in another db, on the same server.

It didn't error and the table was created so I wonder does that prove that a fk can ref a pk in another db?

I have read loads online about it - a mixture of yes you can do it to no you can't. no clarity on which mysql they speak of but they say even oracle can;t do it.


02-23-2009, 11:45 PM
Well wait a sec, did you create the FK constraint, or just the two tables?

02-24-2009, 12:00 AM
I created the table in the second db and included its constraint.

The first tbale was already created.

, CONSTRAINT season_business_fk
FOREIGN KEY ( business_id)
REFERENCES first_db.business_details ( business_id )


Old Pedant
02-24-2009, 12:22 AM
Given that you can easily utilize tables in other DBs in any MySQL query, I don't think the capability is surprising. Well, maybe somewhat surprising, but not exactly amazing.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum