插入一个文件到PostgreSQL。

huangapple 未分类评论45阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年4月10日 02:56:06
  • 转载请务必保留本文链接:https://java.coder-hub.com/61128319.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定