SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Index question

  1. #1
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Index question

    Ok so I have a primary index auto-incrementing 'id'. Now I have 3 rows in the table
    Id | Field
    '1', 'a'
    '2', 'b'
    '3', 'c'

    When I delete row 2 I am left with
    '1', 'a'
    '3', 'c'

    What would be the most effective way of renumbering the id column?

    Sorry if this is too basic of a questions. Thanks for the help.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by optl
    What would be the most effective way of renumbering the id column?
    the most effective way is... don't do it

    leave the gaps, they aren't hurting anybody

    if for some reason your design requires sequential numbers, then don't use an auto_increment
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My design does require sequential numbers. If I was in the situation above, what would be the best way to handle it.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    simple, just redesign your table so that it doesn't use auto_increments
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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