updating seguence no. using sqlplus
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: updating seguence no. using sqlplus

  1. #1
    Join Date
    Aug 2000
    Location
    Jolo, Sulu
    Posts
    639

    updating seguence no. using sqlplus

    Hi Friends,

    I have an existing table A with rows in it.
    I am adding a new column seq_no(number) to this table A.
    Is there a way (using sqlplus) to update all rows
    with a generated sequence no. on this new column?

    Thanks again for ur unfailing support.

  2. #2
    Join Date
    May 2002
    Posts
    108

    Rownum

    The following may help you have a sequence number in the column(Though it may not be the one you desire)

    Update set = rownum;

    - Nandu
    Never give up !

    Nanda Kumar - Vellore

  3. #3
    Join Date
    May 2001
    Posts
    736

  4. #4
    Join Date
    Sep 2001
    Location
    Makati, Philippines
    Posts
    857
    hi kris,
    take a look in this:
    CREATE SEQUENCE BATCH_SEQ INCREMENT BY 1 START WITH
    1 MAXVALUE 1.0E27 MINVALUE 1 NOCYCLE
    NOCACHE
    /
    SQL> DESC DEAD_TAB;
    Name Null? Type
    ----------------------------------------- -------- -------------
    TRANID NOT NULL NUMBER(15)
    WITHOLDING_TAX NUMBER(13,2)
    SQL> ALTER TABLE DEAD_TAB ADD (BATCHNO NUMBER(9));

    Table altered.

    SQL> DESC DEAD_TAB;
    Name Null? Type
    ----------------------------------------- -------- ------------
    TRANID NOT NULL NUMBER(15)
    WITHOLDING_TAX NUMBER(13,2)
    BATCHNO NUMBER(9)
    SQL> UPDATE DEAD_TAB SET BATCHNO = BATCH_SEQ.NEXTVAL;

    10002 rows updated.

    SQL> SELECT BATCH_SEQ.CURRVAL FROM DUAL;

    CURRVAL
    ----------
    10002

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width