我们能做点什么吗
\echo 'Type username to show its properties';
SELECT * FROM mY_users WHERE username = ?;
\echo 'End of script';
Run Code Online (Sandbox Code Playgroud)
在psql脚本文件中?
系统将等到我们输入内容然后回显"脚本结束"字符串.
我刚刚意识到内部并不意味着将变量定义到postgresql.conf中.
所以,我可以使用 \prompt
\prompt 'Please, enter an username ', my_user
SELECT * FROM mY_users WHERE username = :my_user;
\echo 'End of script'
Run Code Online (Sandbox Code Playgroud)
编辑
与命令\ echo一样,您不需要; 在末尾添加一个.实际上,如果在使用时添加一个\prompt,则会出现错误.
您可以显示使用从标准输入读取的值.
\echo 'Here\'s the value read from stdin : ' :my_user
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3104 次 |
| 最近记录: |