1

我在 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
4

1 回答 1

2

哦...

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'
);
于 2013-09-23T08:25:25.180 回答