有没有办法列出文件夹中的文件?
就像是:
select * from pg_ls_dir('/home/christian')
我试过pg_ls_dir但是,per documentation:
Only files within the database cluster directory and the
log_directory
can be accessed. Use a relative path for files in the cluster
directory,and a path matching thelog_directory
configuration setting
for log files. Use of these functions is restricted to superusers.
它通常对sql客户端没用.
无论如何,你需要实现它,这是像plperlu这样的脚本语言的典型用例.例:
CREATE FUNCTION nosecurity_ls(text) RETURNS setof text AS $$ opendir(my $d,$_[0]) or die $!; while (my $f=readdir($d)) { return_next($f); } return undef; $$language plperlu;
除了限制之外,这相当于System Administration Functions中提到的pg_ls_dir(text)函数.
=> select * from nosecurity_ls('/var/lib/postgresql/9.1/main') as ls;
ls ----------------- pg_subtrans pg_serial pg_notify pg_clog pg_multixact .. base pg_twophase etc...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。