...

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



bazz
02-24-2009, 12:38 AM
Hi,

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.

bazz

Fumigator
02-24-2009, 12:45 AM
Well wait a sec, did you create the FK constraint, or just the two tables?

bazz
02-24-2009, 01: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 )
) ENGINE=INNODB DEFAULT CHARSET=LATIN1


bazz

Old Pedant
02-24-2009, 01: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