数据库自动生成编号SQL | 您所在的位置:网站首页 › sql数据库列自动生成编号怎么设置 › 数据库自动生成编号SQL |
1、不支持修改编号的生成规则: select concat('371072',date_format(now(),'%Y'),'1',right(concat('000',ifnull(count(1)+1,'')),3)) AS "plantNumber" from scjg_spot_check_plan aoracle版: select '部门编号'||to_char(sysdate,'yyyyMMdd')|| substr(concat('000000',nvl(count(1)+1,'')),length(count(1)+1)+1) as dasda from wx_record_query
2、支持用户修改编号的生成规则: select concat('371072',date_format(now(),'%Y'),'1',right(concat('000',ifnull(count(1)+1,'')),3)) AS "plantNumber" from scjg_spot_check_plan a union select concat('371072',date_format(now(),'%Y'),'1',right(concat('000',ifnull(max(right(plant_number,3))+1,'1')),3)) from scjg_spot_check_plan a如果用户修改编号,当前SQL语句会返回2条结果,选择第二条即可. |
CopyRight 2018-2019 实验室设备网 版权所有 |