1

我正在尝试将 Postgres 表中的数据反映/镜像到 MySQL 表。我找到了 mysql_fwd,在将所有内容连接到本地主机后,我无法将数据输入到 postgres FOREIGN TABLE。输入 MySQL 的数据也不会显示在 postgres 中(向后测试)?来自 MySQL 的数据不会反映在 postgres 中,如果我测试其他方式(正确方向) post_sync=# INSERT INTO mysql_sync (user_name, user_id) VALUES ('Joe', 3); 错误:无法更改外部表“mysql_sync”

** * ** * ** * **构建过程* ** * ** * ** * ** * *

CREATE SERVER mysql_svr
FOREIGN DATA WRAPPER mysql_fdw
OPTIONS (address '127.0.0.1', port '3306');


CREATE FOREIGN TABLE mysql_sync (id float4, user_name text, user_id integer)
SERVER mysql_svr OPTIONS ( database 'postgres_link', query 'SELECT * FROM mysql_sync');


CREATE USER MAPPING FOR mysqlLink SERVER mysql_svr OPTIONS (username 'some_dude', pass '');

** * ** * ** * ** * ** * **结构* ** * ** * ** * **

Foreign table "public.mysql_sync"
Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
-----------+---------+-----------+-------------+----------+--------------+-------------
id | real | | | plain | |
user_name | text | | | extended | |
user_id | integer | | | plain | |
Server: mysql_svr
FDW Options: (database 'postgres_link', query 'SELECT * FROM mysql_sync')
Has OIDs: no

** * ** * ** * ** * ** * ** * ** mySQL结构 ** * ** * ** * ** * *

mysql> desc mysql_sync;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    92
Current database: postgres_link

+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| id        | int(11)     | NO   | PRI | NULL    | auto_increment |
| user_name | varchar(25) | NO   |     | NULL    |                |
| user_id   | varchar(10) | NO   |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
4

1 回答 1

1

一大堆不同的转换方法,在这里-> http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL

于 2013-09-28T21:05:25.670 回答