今天收到上游发来的数据,因为涉及到名字住址等敏感信息,所以需要马赛克。
打码过程:
update 数据库.A
set name = 'xxxx‘
,date_1 = cast(extract(year from(date_1)) || '01' ||'01' as date format 'yyyymmdd' (要求是只保留年份,但是由于存储的类型为date,所以需要把月日补充为0101)
,date_2 = case when date_2 is not null then cast(extract (year from date_2) || '01' || '01' as date format 'yyyymmdd'
else null end (在保留年份的基础上添加判断,节省空间)
,address_1 = case when address_1 is not null then ’xxx' else null end
注:SQL中不支持IF ELSE
检验过程:
找出全表中name 不等于xxxx的:
select * from A where name <> 'xxxx' (注意不等于的用法)