如何在postgres psql UPDATE命令中分配参数/参数。我尝试使用以下命令。
c="openssl rand -base64 6"
ab=eval $c
psql -d db_name -c "UPDATE table_name SET password = '$ab' WHERE name = 'cde'"
上述命令将列'密码'中的表'table_name'更新为''(引号为空字符串),而不是更新'$ ab'的值。 '$ ab'是一个字符串。
有人可以为此提供帮助吗?
答案 0 :(得分:1)
这是它的工作方式:
c="openssl rand -base64 6"
ab=`$c`
psql -d db_name -c "UPDATE table_name SET password = '$ab' WHERE name = 'cde'"