Quote:
Originally Posted by gubbachchi
Hi,
How to index foreign key between two separate databases.
I have indexed foreign key between tables. Here is the sql query I have used
CREATE TABLE User_Login(user_id int(10) UNSIGNED NOT NULL, user_name char(15) NOT NULL, user_pwd char(10) NOT NULL, PRIMARY KEY(user_id)) TYPE=INNODB;
CREATE TABLE Per_Info(user_id int(10) UNSIGNED NOT NULL, sms_date datetime NOT NULL, INDEX(user_id), FOREIGN KEY(user_id) REFERENCES User_Login(user_id))ENGINE=INNODB;
where the 2 tables User_Login and Per_Info are in the same database database1, but how to index foreign key when the 2 tables are in the seperate databases database1 and database2.
Can anyone help me.
Hi,
You can use the same syntax only change you need to make is to how to refer the table.. like in your above example if your
user_login table is in
db1 and
per_info is in
db2. so your second create query will be something like this.......
-
CREATE TABLE Per_Info(user_id int(10) UNSIGNED NOT NULL, sms_date datetime NOT NULL, INDEX(user_id), FOREIGN KEY(user_id) REFERENCES db1.User_Login(user_id))ENGINE=INNODB;
-