postgresql – 如何从Postgres内部列出文件夹中的文件?
发布时间:2020-12-13 18:09:42 所属栏目:百科 来源:网络整理
导读:有没有办法列出文件夹中的文件? 就像是: 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 file
有没有办法列出文件夹中的文件?
就像是: select * from pg_ls_dir('/home/christian') 我试过pg_ls_dir但是,per documentation:
我需要列出postgres目录之外的文件夹中的文件,类似于COPY的操作方式.
它通常对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... (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |