Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL 9.x-pg_read_binary_文件&;将文件插入bytea_Postgresql_Postgresql 9.1_Postgresql 9.2 - Fatal编程技术网

PostgreSQL 9.x-pg_read_binary_文件&;将文件插入bytea

PostgreSQL 9.x-pg_read_binary_文件&;将文件插入bytea,postgresql,postgresql-9.1,postgresql-9.2,Postgresql,Postgresql 9.1,Postgresql 9.2,我一直在到处(google、stackoverflow等)寻找关于如何使用PostgreSQLpg_read\u binary_file()函数的文档 我能找到的唯一有意义的东西就是官方文件 每次尝试使用此函数时,都会出现错误 例如: SELECT pg_read_binary_file('/some/path/and/file.gif'); ERROR: absolute path not allowed 或 我是否需要将我的文件放在一个特定的目录中,Postgres才能访

我一直在到处(google、stackoverflow等)寻找关于如何使用PostgreSQL
pg_read\u binary_file()
函数的文档

我能找到的唯一有意义的东西就是官方文件

每次尝试使用此函数时,都会出现错误

例如:

    SELECT pg_read_binary_file('/some/path/and/file.gif');
    ERROR:  absolute path not allowed

我是否需要将我的文件放在一个特定的目录中,Postgres才能访问它?如果是的话,什么目录



如果重要的话,我之所以使用这个函数是因为我试图在数据库中插入一个文件,而不使用。

正如@a_horse_with_no_name和@guedes所述,解决方案是确保上传的文件位于PGDATA目录中的服务器上

不会将文件位置作为要求进行说明


此外,我还创建了一个从另一个目录到PGDATA目录的符号链接,这样我就不会干扰postgres的任何数据结构。这似乎工作得很好,我不必执行上述任何操作。

您是否知道该文件应该位于服务器上,而不是运行SQL语句的客户端上?此外,“只能访问数据库群集目录和日志目录中的文件”中的“只能访问数据库群集目录和日志目录中的文件。请为群集目录中的文件使用相对路径,并为日志文件使用与日志目录配置设置相匹配的路径。”。文件必须在PGDATA目录下。你们都是正确的。谢谢你的帮助。@Losshorse你能给我一个答案吗?我很乐意投票。@ChrisTravers-我已经添加了答案。。。我很高兴你觉得这很有用。
    SELECT pg_read_binary_file('file.gif');
    ERROR:  could not stat file "file.gif": No such file or directory