how do i add ID's to an existing mysql database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrthumbs
    salad tossing sig guy
    • Apr 2002
    • 11702

    #1

    how do i add ID's to an existing mysql database?

    I have this huge database and want to assign a unique number to every record.. how can i do this?

    If i create a new field and set it autoincrement it will start counting
    for new entries how do i adjust the old entries?
  • ssp
    Confirmed User
    • Jan 2005
    • 7990

    #2
    How about edit?

    Comment

    • JD
      Too lazy to set a custom title
      • Sep 2003
      • 22651

      #3
      they should already have an id.....maybe i'm just misunderstanding something

      Comment

      • psili
        Confirmed User
        • Apr 2003
        • 5526

        #4
        Originally posted by SPeRMiNaToR
        they should already have an id.....maybe i'm just misunderstanding something
        I think he's saying he has a table that already has records.
        When you alter the table and add a new field, those previous records default to null - where he wants them to get a prepopulated ID from the alter table command. Or something like that.
        Your post count means nothing.

        Comment

        • psili
          Confirmed User
          • Apr 2003
          • 5526

          #5
          This is the only solution I could readily think of.

          Your original table:

          "table1 ( name, value )"

          make a new table with the new ID column set to auto_increment:

          "table2 ( id, name, value)"

          then run a select into table type query:

          INSERT INTO table2 (name,value) SELECT * from table1
          Your post count means nothing.

          Comment

          • s9ann0
            Confirmed User
            • Sep 2001
            • 4873

            #6
            google for "MySQL front" its the shit

            Comment

            • VideoJ
              Confirmed User
              • Aug 2002
              • 750

              #7
              http://dev.mysql.com/doc/refman/5.0/en/alter-table.html

              or download and install http://www.phpmyadmin.net/home_page/index.php
              Somebody stole my damn signture...

              Comment

              Working...