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代表身份證