Jump to content

Changing the Column Name of a MySQL table


Zoey

Recommended Posts

I created the table character, which has the following info:

[code]`id` int(11) NOT NULL auto_increment,
  `character` varchar(255),
  PRIMARY KEY  (`id`)[/code]

However, I later realized that I wanted the column character to be called description so it matched up with some of my other tables.  So using this code:

[code]$sql = "ALTER TABLE `character` CHANGE `character` `description` varchar(255)";

mysql_query($sql) or DIE (mysql_error());[/code]

I attempted to do that.  I received no error messages so I assumed everything was fine... however, when I plugged in this code:

[code]$result = mysql_query("DESCRIBE `character`");
 
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    printf("%s %s", $row[0], $row[1]);
  echo"<br>";
  }
 
  mysql_free_result($result) OR DIE (mysql_error());[/code]

It was still displaying the following info, even after I refreshed a few times:

[quote]
id int(11)
character varchar(255)
[/quote]

Instead of:

[quote]
id int(11)
description varchar(255)
[/quote]

I dont have access to my server directly, so I have to make these adjustments via PHP.  I'm really hoping that someone can help me.  Thanks SO much!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.