我在Postgres中有一个表,我需要在MySQL中反映出来。我发现这个http://wiki.postgresql.org/wiki/Foreign_data_wrapper#mysql_fdw虽然方向很清楚如何实际链接到MySQL。 CREATE FOREIGN TABLE在Postgres中工作,但在MySQL中是一个语法错误。 在运行所有CREATE FOREIGN TABLE并在Postgres中创建CREATE SERVER mysql_svr后,MySQL中没有任何数据神奇地出现,所以我必须错过一个步骤,他们不提供。
mysql> CREATE FOREIGN TABLE ex_staff ( id integer, name text, address text) SERVER mysql_svr OPTIONS (query ‘SELECT * FROM hr.employees WHERE date_left IS NOT NULL’);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOREIGN TABLE ex_staff ( id integer, name text, address text) SERVER mysql_svr O' at line 1
答案 0 :(得分:2)
... DOH
OPTIONS (
database 'myplace',
schema 'test',
table 'dblist',
sql_query 'select description,id,name,created_datetime,sd,users from `test`.`dblist`',
sql_count 'select count(id) from `test`.`dblist`',
db_id 'id',
db_name 'name',
db_desc 'description',
db_users 'users',
db_createdtime 'created_datetime'
);