数据库创建自增id

来源:互联网 发布:描述网络暴力的电影 编辑:程序博客网 时间:2024/06/05 09:57
数据库创建自增id——创建序列create   sequence STUDENT_seq INCREMENT  BY   1    START  WITH   1     NOMAXVALUE       NOCYCLE       noCACHE;----创建触发器create or replace trigger STUDENTbefore insert on STUDENTfor each rowbeginselect STUDENT_seq.nextval into :new.id from dual;end;
下面是uuidString id=UUID.randomUUID().toString().replace("-","").toUpperCase();
创建工具类uuidpackage com.jzkj.career.utils;import java.util.UUID;public class UUIDUtils {    public static String getUUID() {        UUID uuid = UUID.randomUUID();        String str = uuid.toString();        // 去掉"-"符号        String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);        return temp;    }    public static void main(String[] args) {        for (int i = 0; i < 9; i++) {            String uuid = UUIDUtils.getUUID();            System.out.println(uuid);        }    }}
0 0
原创粉丝点击