Generate Upper and Lowercase Alphanumeric Random String in Oracle

前端 未结 6 632
北荒
北荒 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:22

    Try this,

    with
      r as (
        select
          level lvl,
          substr(
            'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
            mod(abs(dbms_random.random), 62)+1, 1) a
        from dual connect by level <= 10
      )
    select
      replace(sys_connect_by_path(a, '/'), '/') random_string
    from r
    where lvl = 1
    start with lvl = 10
    connect by lvl + 1 = prior lvl
    ;
    

    Output,

    FOps2k0Pcy
    

提交回复
热议问题