mysql fdw_PostgreSQL通过mysql_fdw访问MySQL数据库

[root@server mysql_fdw-1.0.1]# catREADME

MySQL FDWfor PostgreSQL 9.1+

==============================This PostgreSQL extension implements a Foreign Data Wrapper (FDW)forthe MySQL.

This code is experimental, and largely intended as a pet projectforme

to experiment with and learn about FDWsinPostgreSQL.

By all means use it, butdo so entirely at your own risk!You have been

warned!Building--------Install MySQL, or just the C client library, and Once that's done, the

extension can be built with:

PATH=/usr/local/pgsql/bin/:/usr/local/mysql/bin:$PATH make USE_PGXS=1

sudo PATH=/usr/local/pgsql/bin/:/usr/local/mysql/bin:$PATH make USE_PGXS=1 install(assuming you have PostgreSQL9.1 in /usr/local/pgsql and MySQL in

/usr/local/mysql).

I've tested on Mac OS X 10.7 only, but other *nix's should also work.

I haven't tested on Windows, but the code should be good on MinGW.

Limitations-----------

-No attempt is made to pushdown quals to MySQL.- The MySQL connection used to plan queries isn't currently reused

during execution.

Usage-----The following parameters can be set on a MySQL foreign server:

address: The address orhostnameof the MySQL server.

Default:127.0.0.1port: The port number onwhichthe MySQL server is listening.

Default:3306The following parameter can be set on a MySQL foreign table:

database: The name of the MySQL database to query.

Default: NULL

query: An SQL query to define the data set on the MySQL server.

table: The name of a table (quoted and qualified as required)

on the MySQL table.

Note that the query and table paramters are mutually exclusive. Using

query can provide either a simple way to push down quals (whichof

course is fixed at definitiontime), or to base remote tables onmorecomplex SQL queries.

The following parameter can be set on a user mappingfora MySQL

foreign server:

username: The username to use when connecting to MySQL

Defaultpassword: The password to authenticate to the MySQL server with.

Default:Example-------

--Install the extension

CREATE EXTENSION mysql_fdw;--Create the foreign server, a pointer to the MySQL server.

CREATE SERVER mysql_svr

FOREIGN DATA WRAPPER mysql_fdw

OPTIONS (address'127.0.0.1', port '3306');-- Create one or moreforeign tables on the MySQL server. The first of--these maps to a remote table, whilst the second uses an SQL query.

CREATE FOREIGN TABLE employees (idinteger,

name text,

address text)

SERVER mysql_svr

OPTIONS (table'hr.employees');

CREATE FOREIGN TABLE overtime_2010 (idinteger,

employee_id integer,

hours integer)

SERVER mysql_svr

OPTIONS (query'SELECT id, employee_id, hours FROM hr.overtime WHERE year = 2010;');-- Create a user mapping to tell the FDW the username/password to-- use to connect to MySQL, for PUBLIC. This could be done on a per-

--role basis.

CREATE USER MAPPING FOR PUBLIC

SERVER mysql_svr

OPTIONS (username'dpage', password '');--Dave Page

dpage@pgadmin.org

[root@server mysql_fdw-1.0.1]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值