用加密值更新postgres列

时间:2018-11-28 20:58:48

标签: postgresql encryption sql-update

我正在尝试通过更新查询对postgres表中的列进行加密,但是遇到了问题。该列是bigint,因此我创建了第二个类型为bytea的列,并尝试将加密的值放入bytea列中。这是查询:

update mytable t1 
  set field1 = t2.field1 
from (
  select encode(digest(cast(field1 as VarChar),'sha1'),'hex') as field1 
  from mytable
) t2 
where t1.field1 = t2.field1::bigint;

我收到以下错误:

ERROR:  invalid input syntax for integer: "0ceeb59193f4d16570da23d662ca8"
SQL state: 22P02

我不确定自己在做什么错。任何有关如何完成此操作或使用其加密值更新列的建议都将受到赞赏。

0 个答案:

没有答案
相关问题