GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   how do i add ID's to an existing mysql database? (https://gfy.com/showthread.php?t=568442)

mrthumbs 01-26-2006 10:18 AM

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 01-26-2006 10:23 AM

How about edit?

JD 01-26-2006 10:30 AM

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

psili 01-26-2006 10:35 AM

Quote:

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.

psili 01-26-2006 11:00 AM

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

s9ann0 01-26-2006 12:06 PM

google for "MySQL front" its the shit

VideoJ 01-26-2006 02:38 PM

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

or download and install http://www.phpmyadmin.net/home_page/index.php


All times are GMT -7. The time now is 03:22 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123