我正在尝试将Postgres表中的/镜像数据反映到MySQL表中。我发现mysql_fwd并在连接到localhost之后,我无法将数据输入到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)
答案 0 :(得分:1)
要转换的一大堆不同方法,这里 - > http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL