英文:
Masking Name Column
问题
我需要遮蔽我的报告中的账号和姓名数据。我的表格如下:
ACC_NUM | NAME |
---|---|
100000111 | THISISMYNAME |
100000522 | EVAN DIMASATRIO |
100000631 | THIS IS MYNAME |
100000851 | RAUL HOLMES |
100000999 | RAUL HOLMES AGUSTINA |
我需要在ACC_NUM
列显示最后3位数字,并在NAME
列的每个单词的开头显示前3位数字。我可以使用CONCAT('xxxxxxx', RIGHT(ACC_NUM, 3))
来处理ACC_NUM
列,但我找不到一种方法来遮蔽NAME
列。
我的期望输出如下:
MASK_ACC | NAME |
---|---|
xxxxxxx111 | THIXXXXX |
xxxxxxx522 | EVAXXXXX DIMXXXXX |
xxxxxxx631 | THIXXXXX IS MYNXXXXX |
xxxxxxx851 | RAUXXXXX HOLXXXXX |
xxxxxxx851 | RAUXXXXX HOLXXXXX AGUXXXXX |
这是我的dbfiddle链接:https://dbfiddle.uk/3K_MpRoE
英文:
I need to mask the account number and name data from my reports. My table looks like this
ACC_NUM | NAME |
---|---|
100000111 | THISISMYNAME |
100000522 | EVAN DIMASATRIO |
100000631 | THIS IS MYNAME |
100000851 | RAUL HOLMES |
100000999 | RAUL HOLMES AGUSTINA |
I need to show the last 3 digits for the ACC_NUM
column and the first 3 digits from every word for the NAME
column. I can use CONCAT('xxxxxxx', RIGHT(ACC_NUM, 3))
for the ACC_NUM
column, but I can't find a way to mask the NAME
column.
My expected output is something like this
MASK_ACC | NAME |
---|---|
xxxxxxx111 | THIXXXXX |
xxxxxxx522 | EVAXXXXX DIMXXXXX |
xxxxxxx631 | THIXXXXX IS MYNXXXXX |
xxxxxxx851 | RAUXXXXX HOLXXXXX |
xxxxxxx851 | RAUXXXXX HOLXXXXX AGUXXXXX |
This is my dbfiddle link: https://dbfiddle.uk/3K_MpRoE
答案1
得分: -1
substring(x.acc_num,1,0)+'*****'+substring(x.acc_num,len(x.acc_num)-2,len(x.acc_num)) from acc x
英文:
Select substring(x.acc_num,1,0)+'*****'+substring(x.acc_num,len(x.acc_num)-2,len(x.acc_num)) from acc x
答案2
得分: -1
我找到了,大家,我会使用这个查询:
REGEXP_REPLACE(NAME, '([A-Z]{3})([A-Z]+)', '****')
这是 dbfiddle 链接:https://dbfiddle.uk/4QGiz9RF
英文:
I found it everyone, I will use this query
REGEXP_REPLACE(NAME, '([A-Z]{3})([A-Z]+)', '****')
This is the dbfiddle: https://dbfiddle.uk/4QGiz9RF
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论