Oracle数据库如何识别个人信息的?

Oracle数据库也是众多数据库相对比较常见的数据库。很多个人或者企业都在使用Oracle数据库进行处理一些数据。就好比Oracle数据库如何识别个人信息的等的问题。本文主要介绍Oracle根据身份证号获取人员城市,性别和年龄的信息。同时用示例代码向您详细展示,该示例代码对每个人的学习或工作都有一定的参考价值,需要的朋友可以参考它。

Oracle数据库如何识别个人信息的?_业界动态_数字化

 1、通过身份证号查询所在省市

SELECT

count(*) as total,

case substr(t.CERTNO,0,2)

when '11' then '北京市'

when '12' then '天津市'

when '13' then '河北省'

when '14' then '山西省'

when '15' then '内蒙古自治区'

when '21' then '辽宁省'

when '22' then '吉林省'

when '23' then '黑龙江省'

when '31' then '上海市'

when '32' then '江苏省'

when '33' then '浙江省'

when '34' then '安徽省'

when '35' then '福建省'

when '36' then '江西省'

when '37' then '山东省'

when '41' then '河南省'

when '42' then '湖北省'

when '43' then '湖南省'

when '44' then '广东省'

when '45' then '广西壮族自治区'

when '46' then '海南省'

when '50' then '重庆市'

when '51' then '四川省'

when '52' then '贵州省'

when '53' then '云南省'

when '54' then '西藏自治区'

when '61' then '陕西省'

when '62' then '甘肃省'

when '63' then '青海省'

when '64' then '宁夏回族自治区'

when '65' then '新疆维吾尔自治区'

when '71' then '台湾省'

when '81' then '香港特别行政区'

when '82' then '澳门特别行政区'

else '未知'

end AS province

FROM uip_bjt_userinfo t

group by case substr(t.CERTNO,0,2)

when '11' then '北京市'

when '12' then '天津市'

when '13' then '河北省'

when '14' then '山西省'

when '15' then '内蒙古自治区'

when '21' then '辽宁省'

when '22' then '吉林省'

when '23' then '黑龙江省'

when '31' then '上海市'

when '32' then '江苏省'

when '33' then '浙江省'

when '34' then '安徽省'

when '35' then '福建省'

when '36' then '江西省'

when '37' then '山东省'

when '41' then '河南省'

when '42' then '湖北省'

when '43' then '湖南省'

when '44' then '广东省'

when '45' then '广西壮族自治区'

when '46' then '海南省'

when '50' then '重庆市'

when '51' then '四川省'

when '52' then '贵州省'

when '53' then '云南省'

when '54' then '西藏自治区'

when '61' then '陕西省'

when '62' then '甘肃省'

when '63' then '青海省'

when '64' then '宁夏回族自治区'

when '65' then '新疆维吾尔自治区'

when '71' then '台湾省'

when '81' then '香港特别行政区'

when '82' then '澳门特别行政区'

else '未知'end order by province desc

 2、通过身份证号得到性别(第17位为奇数为男,偶数为女)

select

decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男') as sex

from uip_ca_userinfo t

Oracle数据库如何识别个人信息的?_业界动态_数字化

 3、通过身份证号得到年龄

select to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) as age from uip_ca_userinfo t

Oracle数据库如何识别个人信息的?_业界动态_数字化

 4、通过身份证号统计所在年龄段的人数

select count(t.id),

case

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 1 and 20 then

'1-20岁'

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 21 and 30 then

'21-30岁'

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 31 and 40 then

'31-40岁'

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 41 and 50 then

'41-50岁'

else

'50岁以上'

end as 年龄段

from uip_ca_userinfo t

group by case

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 1 and 20 then

'1-20岁'

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 21 and 30 then

'21-30岁'

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 31 and 40 then

'31-40岁'

when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 41 and 50 then

'41-50岁'

else

'50岁以上'

end

order by 年龄段 asc

Oracle数据库如何识别个人信息的?_业界动态_数字化

 5、通过身份证号统计男女数量

select count(t.id),

decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男') as sex

from uip_ca_userinfo t

where to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 1 and 26

group by decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男')

Oracle数据库如何识别个人信息的?_业界动态_数字化

Oracle数据库如何识别个人信息的相信大家已经知晓了吧,想了解更多关于Oracle数据库的信息,请继续关注。

31
40
0
30

相关资讯

  1. 1、极速pdf阅读器怎么复制文字?极速pdf阅读器复制文字的方法1706
  2. 2、微视如何打榜?微视给明星打榜的方法4841
  3. 3、U盘属性没有安全选项怎么办?4502
  4. 4、阿里旺旺怎么添加联系人?阿里旺旺添加联系人方法分享536
  5. 5、电脑帧数很低怎么办?fps太低解决方法1598
  6. 6、法语助手如何查询不认识单词?法语助手查询不认识单词的方法782
  7. 7、Win10怎么设置远程连接?2268
  8. 8、如何利用美图秀秀修改GIF图片尺寸大小?2859
  9. 9、腾讯视频怎么换明星装扮?明星装扮启用方法分享1778
  10. 10、古装相机如何使用?古装相机使用方法5039
全部评论(0)
我也有话说
0
收藏
点赞
顶部