oracle 生成 20 位随机数字的函数

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

 

-- Create sequence 
create sequence SEQU_SOFA_FID
minvalue 1
maxvalue 99999
start with 7
increment by 1
cache 100
cycle;


CREATE OR REPLACE FUNCTION SOFA_NUID RETURN NUMBER IS
  RE NUMBER(20);
BEGIN
  SELECT TO_NUMBER(TO_CHAR(SYSDATE, 'YYMMDDhh24miSS') ||
                   LPAD(ABS(MOD(DBMS_RANDOM.RANDOM, 1000)), 3, 0) ||
                   LPAD(SEQU_SOFA_FID.NEXTVAL, 5, 0))
    INTO RE
    FROM DUAL;
  RETURN RE;
END;

 

转载于:https://my.oschina.net/liyonglee/blog/718461

你可能感兴趣的:(oracle 生成 20 位随机数字的函数)