[SOLVED] How to insert new field and populate it with data?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
shucash
Forum Newbie
Posts: 2
Joined: Thu Mar 04, 2004 6:53 pm

[SOLVED] How to insert new field and populate it with data?

Post by shucash »

hey guys,

I'm sure this will be a no brainer for people in this forum.

I have a small database of products. I want to add a field, called product_id, to the database, so that every product now has an incremental product_id.

The original designer did not add this field when he created the database, and removing products is VERY ugly right now.

Any ideas?
Vin
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

read over this
shucash
Forum Newbie
Posts: 2
Joined: Thu Mar 04, 2004 6:53 pm

Post by shucash »

Perfect! Thank you.

For anyone reading this post who was curious, here is what worked:


ALTER TABLE t2 ADD product_id INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD INDEX (product_id);

Vin
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

**** moved to databases ****
Post Reply