Adding a new field to the end of a table - mysql

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
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Adding a new field to the end of a table - mysql

Post by watson516 »

how does one go about adding a new field to the end of a mysql table via php?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I believe it will involve the SQL command ALTER TABLE. Beyond that, I'm not sure. Do you have phpMyAdmin? If so, use their utility to add a field to the table and copy the generated SQL command. :wink:
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Post by watson516 »

fantastic

$sql = 'ALTER TABLE `cbox` ADD `c_cat6` INT NOT NULL;';
Post Reply