在 psql 中使用内联 '--command' 参数不会在 .psql_history 中生成日志

Using the inline '--command' argument with psql doesn't produce logs in .psql_history

当我在 Ubuntu 上手动登录我的 PostgreSQL 服务器并执行命令时,我可以发现它已登录 /root/.psql_history

然而,当我尝试通过 psql -c "*query goes here*" 在 bash 脚本中 运行 命令时,命令 returns 数据未登录 .psql_history .

有没有人遇到过这种情况?

命令行检索和编辑以及历史文件是链接到 psql 的“readline”库的功能。

Readline 支持仅在交互式会话中有效,因此如果您使用 -c-f 选项调用 psql,也不会写入历史记录。