Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Copenhagen
    Posts
    220

    Question Unanswered: Identity columns

    Theres been a lot of talk about:
    'slapping on identity columns'

    Very well, now I slapped an integer column
    on my table. How do i fill it up with consecutive
    numbers using sql?

    (I'd rather not move all data to a new table
    with a generated column, and you can't set
    the column to autogeneration if you slap it on
    after table creation)

    Cheers
    Kristian K. Hansen
    Project Supervisor
    National Board of Health

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    Code:
    ALTER TABLE YourTbl 
    ADD COLUMN YOURNR INTEGER 
    GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 );
    F. Celaia
    DBA Sybase/DB2/Oracle/MS-SQL

  3. #3
    Join Date
    Feb 2004
    Location
    Copenhagen
    Posts
    220

    Exclamation No fillup on existing table

    I'm afraid that doesn't
    work on existing tables
    Kristian K. Hansen
    Project Supervisor
    National Board of Health

Posting Permissions

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