我有一个sql文件(以及许多其他东西)将数据从csv文件复制到postgres数据库表。 sql文件包含以下命令:
\COPY stg_gebruikers(gbr_id,klt_id,rol_id,email,ind_actief,ind_bevestigd,wachtwoord,datum_aanmaak) FROM 'stg_gebruikers.csv' WITH DELIMITER ';' CSV HEADER;
文件stg_gebruikers.csv包含以下内容:
gbr_id;klt_id;rol_id;email;ind_actief;ind_bevestigd; wachtwoord;datum_aanmaak
1;1;2;Admin;1;1; sha1:64000:18:cz6hWKx5YG/7LzIYtM+UVu7mYLHTDSRc:VJJ179dwAOnyjJbv1tsZNeMy; 11-4-2018 00:00
2;12;1;demo;1;1; sha1:64000:18:rtTvjCN/p6ak6cB5n00JslVin7i7jjrY:Kqqn6HKHX8It4ZZCfAywRRpl; 11-4-2018 00:00
字段'wachtwoord'(表示荷兰语密码)中填充了已加密的密码。当我运行完整的脚本时,最终在字段'wachtwoord'中的值与csv文件中的值不同。更奇怪的是,在后续运行中,密码填充了不同的值
首先记录输出:
11:09:48.549 ... DEBUG ... - doin: INSERT INTO stg_gebruikers (gbr_id,klt_id,rol_id,email,ind_actief,ind_bevestigd,wachtwoord,datum_aanmaak) VALUES (1,1,2,'Admin',true,true, 'sha1:64000:18:+eyO/5Yd6FunshgDYY/o5hxncey6+oz9:pZ4eNhI/gMO7ujanLCFBxukD',current_timestamp)
11:09:48.769 ... DEBUG ... - doin: INSERT INTO stg_gebruikers (gbr_id,klt_id,rol_id,email,ind_actief,ind_bevestigd,wachtwoord,datum_aanmaak) VALUES (2,12,1,'demo',true,true, 'sha1:64000:18:decGMCFVX2XeN7qHSeCvpGHgFmoe3qVZ:/xU7PsttviAVeg9O1Ii8fluP',current_timestamp)
记录输出第二次运行:
11:30:45.341 ... DEBUG ... - doin: INSERT INTO stg_gebruikers (gbr_id,klt_id,rol_id,email,ind_actief,ind_bevestigd,wachtwoord,datum_aanmaak) VALUES (1,1,2,'Admin',true,true, 'sha1:64000:18:Bqh7+emzuzJsixtwKbQ11aSc32LOZ4l+:8YR85LoNjNIef17f+Girmuk6',current_timestamp)
11:30:45.452 ... DEBUG ... - doin: INSERT INTO stg_gebruikers (gbr_id,klt_id,rol_id,email,ind_actief,ind_bevestigd,wachtwoord,datum_aanmaak) VALUES (2,12,1,'demo',true,true, 'sha1:64000:18:W2k95Oc6uY0MSYAViWnTe3eKbTqTqeA3:vkBrOCp3RO5UlzwvXHHizafS',current_timestamp)
sha1:64000:18之后的值不同,即使源文件没有更改。
我认为密码值本身可能是加密的,所以我尝试将'sha1:64000:18:decGMCFVX2XeN7qHSeCvpGHgFmoe3qVZ:/ xU7PsttviAVeg9O1Ii8fluP'更改为'sha1:64000:18:abc'希望密码为'abc',但它不是
如果我在wachtwoord字段中手动更新用户管理员的csv(因此:'sha1:64000:18:cz6hWKx5YG / 7LzIYtM + UVu7mYLHTDSRc:VJJ179dwAOnyjJbv1tsZNeMy')中定义的值,则会设置正确的密码
这是stg_gebruikers的创建表语句:
CREATE TABLE STG.STG_GEBRUIKERS(
GBR_ID BigSerial NOT NULL,
KLT_ID Bigint NOT NULL,
ROL_ID Bigint NOT NULL,
EMAIL Character varying(200) NOT NULL,
IND_ACTIEF Boolean DEFAULT false NOT NULL,
IND_BEVESTIGD Boolean DEFAULT false NOT NULL,
IND_GEEN_VOORKEUREN Boolean,
WACHTWOORD Character varying(100) NOT NULL,
DATUM_AANMAAK Timestamp NOT NULL
)
我查看了文档,但我找不到任何相关内容。