mysql - 将 postgres 表与 mysql 表链接在测试中失败

标签 mysql sql database postgresql heterogeneous

I am trying to reflect/mirror data from a Postgres table to a MySQL table. I found mysql_fwd and after connection everything to a localhost, I cannot enter data into the postgres FOREIGN TABLE. nor does data entered into MySQL, show up in postgres (backwards test)?? Data from MySQL does not reflect in postgres and if I test the other way (the correct direction) post_sync=# INSERT INTO mysql_sync (user_name, user_id) VALUES ('Joe', 3); ERROR: cannot change foreign table "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)

最佳答案

关于mysql - 将 postgres 表与 mysql 表链接在测试中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18967501/

相关文章:

mysql - 更新 Woocommerce 可变产品的所有产品变体销售价格

java - 数据库连接: protocoling data for hundereds to million objects

c - (mysql_real_query) 在插入一些记录时中断

mysql - 如何在 OS X 上运行 MySQL?

php - 准备好的语句句柄可以存储在成员变量中吗?

mysql - 简单的sql查询返回零行

sql - 通过 Ant 构建文件创建数据库(而不是填充它)

mysql - 如何根据另一个表的 PK 获取一个表的两列的计数?

mysql - 按 MySQL 中的前 N ​​个分组

mysql - SQL 连接表以获取其他表数据