mon*_*nja 2 linux postgresql bash file-io
在PostgreSQL和bash(linux)中,有没有办法从文件系统直接导入文件
[execute.sh]
pgsql .... -f insert.txt
[insert.txt]
插入表(id,file)值(1,import('/ path/to/file'))
似乎没有导入函数,bytea_import也是如此,lo_import会保存int而我不知道如何获取文件(这些文件的大小很小所以使用lo_import似乎不合适)
我怎样才能将insert.txt语句移动到PostgreSQL?
我不确定你在追求什么,但是如果你有带有SQL语句的脚本,例如你提到的insert语句,你可以运行psql然后从psql中运行脚本.例如:
postgres@server:~$ psql dbname
psql (8.4.1)
Type "help" for help.
dbname=# \i /tmp/queries.sql
Run Code Online (Sandbox Code Playgroud)
这将运行/tmp/queries.sql中的语句.
希望这是你要求的.
| 归档时间: |
|
| 查看次数: |
7364 次 |
| 最近记录: |