【发布时间】:2020-08-27 20:16:57
【问题描述】:
如何在更改某些值的同时将一个表复制到另一个表?
我的意思是例如:
perso=# create table chk ( id serial primary key, Q text , R text not null unique, p text not null unique) ;
CREATE TABLE
perso=# select * from chk
perso-# ;
id | q | r | p
----+---+---+---
(0 rows)
作为目的地
我会使用来自
的数据perso=# select * from tmp
;
idt | qt | rt | pt
-----+----+----+----
我想将数据从 tmp 表复制到 chk 表,并在可能的情况下立即更新 chk 上的数据,所以
chk.p 等于 tmp.t 与crypt('t', gen_salt('bf'))
我尝试使用子选择进行复制,但出现了很多不同类型的错误……我无法解释也无法将它们全部粘贴在这里。
简短的询问:更新表中的数据以将结果存储在另一个表中
我想最好的方法应该是:
update chk
set
......
from tmp (colums, crypt('t', gen_salt('bf'))
....
但是如何?
【问题讨论】:
标签: sql postgresql encryption copy sql-insert