数据库自动生成编号SQL 您所在的位置:网站首页 sql数据库列自动生成编号怎么设置 数据库自动生成编号SQL

数据库自动生成编号SQL

2024-07-03 20:20| 来源: 网络整理| 查看: 265

1、不支持修改编号的生成规则:

select concat('371072',date_format(now(),'%Y'),'1',right(concat('000',ifnull(count(1)+1,'')),3)) AS "plantNumber" from scjg_spot_check_plan a

oracle版:

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 实验室设备网 版权所有