Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2011
    Posts
    27

    Unanswered: reset autoincrement key

    the question is very simple i thing, but i couldn't find the solution.
    I deleted one table from db . which contains a auto increment variable
    i want to reset this variable's value to zero.

    I executed this cmd
    DBCC CHECKIDENT ('Logs', RESEED, 0)
    in db2. it worked.
    but i want to execute this through program interface.
    i tried like this, but its not working.
    Conn.Execute("call SYSPROC.ADMIN_CMD ('DBCC CHECKIDENT ('Logs', RESEED, 0)')")
    Pls help me to solve this

    Thanks in advance

    regards ,
    Manu

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Are you sure you're talking about DB2? DBCC is a SQL Server command.

  3. #3
    Join Date
    Dec 2011
    Posts
    27
    I need a solution in db2. help me pls

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If your design relies on the auto-increment value having meaning then your design is flawed. You shouldn't have to reseed.

    Why are you considering this?
    George
    Home | Blog

  5. #5
    Join Date
    Dec 2011
    Posts
    27
    hi gvee,

    the thing is like this. i deleted all data from a particular table which having one column constrain as auto increment value. after re-entering data i need to start from first value. that is i need to reset value of auto increment field.

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Find the DB2 SQL Reference Manual Vol 2, and look under alter table.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

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