Generate Upper and Lowercase Alphanumeric Random String in Oracle

前端 未结 6 636
北荒
北荒 2021-02-05 14:55

How does one generate an upper and lowercase alphanumeric random string from oracle?

I have used select DBMS_RANDOM.STRING(\'x\', 10) from dual to generate

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 15:06

    create or replace procedure r1
        is
        v_1 varchar2(1);
        v_2 varchar2(10);
        begin 
        for inner_c in 1..10
        loop
        select  substr('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',mod(abs(dbms_random.random), 62)+1, 1) into v_1 from dual;
        v_2 := v_2 || v_1;
        end loop;
        dbms_output.put_line(v_2);
        end;
        /
    

提交回复
热议问题