1

我想加入一个带有视图的表,其中一个表L是本地的,而视图FFEDERATED驻留在另一台服务器上的视图:

SELECT * FROM L LEFT JOIN F ON L.id = F.id;

现在,尽管表和视图之间实际上有很多匹配项,但 JOIN 不会导致任何命中。ID 字段是bigint

沮丧,我创建了一个TEMPORARYT并将所有内容转储F到其中,从而制作了F. 使用T代替F, JOIN 按预期工作。但是创建过程T会消耗内存和时间。

这种奇怪的 MySQL 行为可能是什么原因?


表定义:

CREATE TABLE `L` (
  `id` bigint(20) NOT NULL,
  `id2` bigint(20) NOT NULL,
  PRIMARY KEY (`id`,`id2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

和(这个表实际上是远程服务器上的一个视图):

CREATE TABLE `F` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `field1` bigint(20) NOT NULL,
   ...
  `field5` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://userName:pword...';
4

1 回答 1

2

As it states from definition of what FEDERATED storage-engine is, you must have table structure definition (so, for example .frm files for MyISAM) on both servers. That is because how FEDERATED engine works:

enter image description here

Therefore, you can not use VIEW since it has completely different meaning and structure. So instead you should mirror your table and then you'll be able to use it in your queries.

于 2014-06-26T11:59:17.653 回答