首页 > 学院 > 开发设计 > 正文

PostgreSQL学习篇14.1 SQL/MED

2019-11-09 13:38:00
字体:
来源:转载
供稿:网友
SQL/MED是sql语言中管理外部数据的一个扩展标准。MED:management of external data。它通过定义一个外部数据包装器和数据连接类型来管理外部数据。9.1开始提供对SQL/MED的支持,通过SQL/MED可以连接到各种异构数据库或其他PostgreSQL数据库。其相当于一套连接其他数据源的框架和标准。在SQL/MED标准中,实现了一下四类数据库对象来访问外部数据源:foreign data wrapper:外部数据包装器,FDW。相当于定义外部数据驱动server:外部数据服务器,相当于定义一个外部数据源,需要制定外部数据源的FDWuser mapping:用户映射,主要把外部数据源的用户映射到本地用户,用于控制权限foreign table:外部表,把外部数据源映射成数据库中的一张外部表FDW:  --使用之前,需要到crontab下,make  make install创建FDW示例:、postgres=# create extension file_fdw;CREATE EXTENSIONpostgres=# create server file_fdw_server foreign data wrapper file_fdw;CREATE SERVERpostgres=# create foreign table passwd(postgres(# username text,postgres(# pass text,postgres(# uid int4,postgres(# gid int4,postgres(# gecos text,postgres(# home text,postgres(# shell textpostgres(# ) server file_fdw_serverpostgres-# options (format 'text', filename '/etc/passwd' ,delimiter ':', null '');CREATE FOREIGN TABLEpostgres=# select * from passwd limit 5; username | pass | uid | gid | gecos  |      home      |     shell     ----------+------+-----+-----+--------+----------------+--------------- root     | x    |   0 |   0 | root   | /root          | /bin/bash bin      | x    |   1 |   1 | bin    | /bin           | /sbin/nologin daemon   | x    |   2 |   2 | daemon | /sbin          | /sbin/nologin adm      | x    |   3 |   4 | adm    | /var/adm       | /sbin/nologin lp       | x    |   4 |   7 | lp     | /var/spool/lpd | /sbin/nologin(5 rows)postgres=#
上一篇:lvm配置

下一篇:sqlserver2008R2还原数据库

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表