Oracle根据身份证计算出年龄的sql脚本
1、select to_char(sysdate, 'yyyy') - substr('610526199807067651', 7, 4) as age from dual;
2、如果是表中有列 ,姓名、身份证没有年龄
--增加一列年龄
alter table TMP1 add age nvarchar2(3);
update TMP1 set age=to_char(sysdate, 'yyyy') - substr(CERT_NUM, 7, 4) where cert_type=1;
--TMP1 表名
--CERT_NUM 身份证号码 列名
--cert_type 证件类型 1代表身份证