How do I do to rename a mysql table field?
This is how far I've come:

$query = mysql_query("ALTER TABLE tablename...");

    Why are you doing this Riklund? Are you renaming your database fields on the fly? I hope not.

    I cannot take responsibility if you hose your database with the following suggestion so please back it up before proceeding. 😛

    In fact, I would suggest creating a dummy database to test on!

    The SQL query to pull this off would be:

    ALTER TABLE TableName RENAME COLUMN ColumnName TO NewColumnName

    Example:
    ALTER TABLE Employees RENAME COLUMN SocSec To SocialSecurity

      well, why I wanted to do this was that phpMyAdmin isn't working correctly on my dev server, and therefor I've made a little mysql query script, kinda like the one in phpMyAdmin...

        ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]

        I copied it from the Mysql Docs.

        Basically you have it right at the start. But we need to see the rest. You may wanna use mysql_error();

          Write a Reply...