Creating a sequence for a varchar2 field in Oracle

后端 未结 4 1391
傲寒
傲寒 2021-01-14 00:58

I want to create a sequence for this varchar. It would have been easier had it been a number instead of varchar. In that case, I could do

seq_no := se

4条回答
  •  臣服心动
    2021-01-14 01:50

    This can be done by

    to_char(seq_no,'FM0000000')
    

    your example can be done by creating sequence in oracle

    create sequence seq_no  start with 1 increment by 1;
    

    then

    select 'A'||to_char(seq_no.nextval,'FM0000000') from dual;
    

    Right now i have used in dual ..but place this

    'A'||to_char(seq_no.nextval,'FM0000000')
    

    in your required query ..this will create sequence as you mentioned

    sqlfiddle

提交回复
热议问题