Postgres 相当于 Oracle 的“DIRECTORY"对象 [英] Postgres equivalent to Oracle's "DIRECTORY" objects

查看:79
本文介绍了Postgres 相当于 Oracle 的“DIRECTORY"对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建"DIRECTORY" 对象在 Postgres 中?

Is it possible to create "DIRECTORY" object in Postgres?

如果没有可以帮助我解决如何在 PostgreSQL 上实现它.

If not can some help me with a solution how implement it on PostgreSQL.

推荐答案

Postgres 中没有与Oracle 目录"等效的概念.

There is no equivalent concept to an "Oracle directory" in Postgres.

替代方案取决于为什么需要Oracle 目录".

The alternatives depend on why the "Oracle directory" is needed.

如果需要目录在数据库服务器上读写文件,那么可以通过通用文件访问函数.对这些功能的访问仅限于超级用户(详细信息在手册的链接部分).如果普通用户应该能够使用它们,最好的办法是创建包装函数,然后将这些函数的执行权限授予相关用户.

If the directory is needed to read and write files on the database server, then this can be done through Generic File Access Functions. Access to those functions is restricted to superusers (details in the linked section of the manual). If regular users should be able to use them, the best thing would be to create wrapper functions and then grant execute on those functions to the users in question.

出于安全原因,只有数据库集群内的目录 可以访问.

For security reasons, only directories inside the database cluster can be accessed.

但是可以在数据目录内创建指向数据目录外目录的符号链接.需要为 postgres 操作系统用户(启动 postgres 进程的用户)正确设置对这些目录的访问权限

But it's possible to create symlinks inside the data directory that point to directories outside the data directory. Access privileges on those directories need to be properly setup for the postgres operating system user (the one under which the postgres process is started)

如果需要访问目录,例如CSV 文件通过 Oracle 的外部表,则不需要目录".file FDW 外部数据包装器,可以访问外部文件数据目录(前提是已在文件系统级别正确设置了访问权限).

If the directory is needed to access e.g. CSV files through Oracle's external tables, then there is no need for a "directory". The file FDW foreign data wrapper, can access files outside the data directory (provided access privileges have been setup correctly on the file system level).

这篇关于Postgres 相当于 Oracle 的“DIRECTORY"对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆