英文:
insert a file into postgres
问题
我尝试过
insert into lob_file VALUES (5, pg_read_file('c://temp//sample.txt')::BYTEA);
但是出现了
ERROR: could not start file c://temp//sample.txt. No such file or directory.
英文:
How do I insert a file that resides in windows in c:\temp\sample.txt
I have tried
insert into lob_file VALUES (5, pg_read_file('c://temp//sample.txt')::BYTEA);
and got
> ERROR: could not start file c://temp//sample.txt. No such file or
> directory.
答案1
得分: 0
数据是否在本地运行或在Windows服务器上运行,并且您已将文件移动到服务器上。请参阅文档
表9.94中显示的函数可以在托管服务器的计算机上对文件进行本机访问。只有数据库集群目录和log_directory中的文件可以被访问,除非授予用户pg_read_server_files角色。对于集群目录中的文件,请使用相对路径,对于日志文件,请使用与log_directory配置设置相匹配的路径。
英文:
Is data base running locally or on a Windows server and you have moved the file to the server. See Docs
> The functions shown in Table 9.94 provide native access to files on
> the machine hosting the server. Only files within the database cluster
> directory and the log_directory can be accessed unless the user is
> granted the role pg_read_server_files. Use a relative path for files
> in the cluster directory, and a path matching the log_directory
> configuration setting for log files.
专注分享java语言的经验与见解,让所有开发者获益!
评论