oracle解析身份证号码.sql
2017-01-05 23:05
1311 查看
-- 创建一个表
drop table employee ;create table employee (
NO number(4) primary key not null ,
NAME varchar(60) not null ,
SN number(18)
);comment on table employee
is '员工信息表';
comment on column employee.NO
is '工号';
comment on column employee.NAME
is '姓名';
comment on column employee.SN
is '身份证号';
--插入数据
insert into employee (NO, NAME, SN) values (100, '王盼东', 410482199012052339) ;
insert into employee (NO, NAME, SN) values (101, '张三', 110226198501272116) ;
insert into employee (NO, NAME, SN) values (102, '李四', 410050197712452649) ;
insert into employee (NO, NAME, SN) values (103, '王五', 410110198911152468) ;
insert into employee (NO, NAME, SN) values (104, '刘六', 110105199401051599) ;
insert into employee (NO, NAME, SN) values (105, '赵七', 440100200012311224) ;--搜索并解析
select distinct
case substr(SN,1,2)
when '41'
then '河南'
when '11'
then '北京'
when '44'
then '广东'
end 省份,
case substr(SN,1,2)
when '41'
then case substr(SN,3,4)
when '0110'
then '漯河'
when '0482'
then '汝州'
when '0050'
then '安阳'
end
when '11'
then case substr(SN,3,4)
when '0226'
then '平谷'
when '0105'
then '朝阳'
end
when '44'
then case substr(SN,3,4)
when '0100'
then '广州'
when '0302'
then '盐田'
end
end 地市,
case
when substr(SN,17,1) in ('1','3','5','7','9')
then '男'
when substr(SN,17,1) in ('0','2','4','6','8')
then '女'
end 性别,
NAME "姓名",to_date(substr(SN,7,8),'YYYY/MM/DD') "出生日期"
from employee where NO = (&NO);
drop table employee ;create table employee (
NO number(4) primary key not null ,
NAME varchar(60) not null ,
SN number(18)
);comment on table employee
is '员工信息表';
comment on column employee.NO
is '工号';
comment on column employee.NAME
is '姓名';
comment on column employee.SN
is '身份证号';
--插入数据
insert into employee (NO, NAME, SN) values (100, '王盼东', 410482199012052339) ;
insert into employee (NO, NAME, SN) values (101, '张三', 110226198501272116) ;
insert into employee (NO, NAME, SN) values (102, '李四', 410050197712452649) ;
insert into employee (NO, NAME, SN) values (103, '王五', 410110198911152468) ;
insert into employee (NO, NAME, SN) values (104, '刘六', 110105199401051599) ;
insert into employee (NO, NAME, SN) values (105, '赵七', 440100200012311224) ;--搜索并解析
select distinct
case substr(SN,1,2)
when '41'
then '河南'
when '11'
then '北京'
when '44'
then '广东'
end 省份,
case substr(SN,1,2)
when '41'
then case substr(SN,3,4)
when '0110'
then '漯河'
when '0482'
then '汝州'
when '0050'
then '安阳'
end
when '11'
then case substr(SN,3,4)
when '0226'
then '平谷'
when '0105'
then '朝阳'
end
when '44'
then case substr(SN,3,4)
when '0100'
then '广州'
when '0302'
then '盐田'
end
end 地市,
case
when substr(SN,17,1) in ('1','3','5','7','9')
then '男'
when substr(SN,17,1) in ('0','2','4','6','8')
then '女'
end 性别,
NAME "姓名",to_date(substr(SN,7,8),'YYYY/MM/DD') "出生日期"
from employee where NO = (&NO);
相关文章推荐
- ORACLE对身份证号码处理相关的SQL汇总
- ORACLE对身份证号码处理相关的SQL汇总
- ORACLE对身份证号码处理相关的SQL【收藏】
- Oracle PL.SQL解析 XMl文件
- Oracle PL/SQL 的 DOM API 解析 XML 文档
- oracle SQL解析步骤小结
- oracle SQL解析步骤
- oracle pl/sql身份证15位转18位的function
- Oracle SQL Parsing Flow Diagram(SQL 解析流程图)
- ORACLE中SQL语句解析步骤(转载)
- SQL简单验证身份证号码位数、出生日期、性别(转)
- Oracle SQL Parsing Flow Diagram(SQL 解析流程图)
- 给定一个一oracle建表的sql语句,解析读出的字符串,将表名、字段名、字段类型数据取出,怎么实现啊?
- Oracle SQL Parsing Flow Diagram(SQL 解析流程图)
- Oracle SQL Parsing Flow Diagram(SQL 解析流程图)
- Oracle SQL的硬解析和软解析
- 号码升位sql,Oracle
- 如何在JS中解析身份证号码得到出生日期
- SQL 将身份证的15位号码升级为18位
- Oracle SQL Parsing Flow Diagram(SQL 解析流程图)