mydb=# create table test_desensitization(id integer,name varchar(32),phone_num varchar(11)); CREATE TABLE mydb=# insert into test_desensitization select num,‘name_‘||num,18500000000+(random()*90000000)::int from generate_series(1,100) g(num);; INSERT 0 100 mydb=# create table test_desensitization_result as select id,substring(name,1,2)||‘******‘||substring(name,length(name),1) as name,substring(phone_num,3)||‘****‘||substring(phone_num,length(phone_num) -3,4) as phone_num from test_desensitization ; SELECT 100 mydb=# select * from test_desensitization_result ; id | name | phone_num -----+-----------+------------- 1 | na******1 | 185****9782 2 | na******2 | 185****2419 3 | na******3 | 185****5163 4 | na******4 | 185****9263 5 | na******5 | 185****1941 6 | na******6 | 185****0390 7 | na******7 | 185****2158 8 | na******8 | 185****8646 9 | na******9 | 185****9253 10 | na******0 | 185****4371
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。