![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
salad tossing sig guy
Join Date: Apr 2002
Location: mrthumbs*gmail.com
Posts: 11,702
|
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? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jan 2005
Location: United Kingdom
Posts: 7,990
|
How about edit?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Too lazy to set a custom title
Industry Role:
Join Date: Sep 2003
Posts: 22,651
|
they should already have an id.....maybe i'm just misunderstanding something
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
Quote:
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. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Sep 2001
Location: Boston
Posts: 4,873
|
google for "MySQL front" its the shit
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Join Date: Aug 2002
Location: S. Florida
Posts: 750
|
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... |
![]() |
![]() ![]() ![]() ![]() ![]() |