SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Probably a LAME question...

    Hello yet again everyone,

    I have a simple, yet seemingly too simple question:I know that you can rename tables in a MySQL database with the ALTER TABLE statement...but can you rename a column somehow? Or do you have to drop it and re-add it? I really don't want to do that, but I will if I absolutely have to.

    Cheers,

    XGuy.

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sure there is. you do have to redifine the column though when you rename it. (it's not dropped though, so you won't lose data). from the MySQL manual: http://www.mysql.com/documentation/m...ml#ALTER_TABLE

    You can rename a column using a CHANGE old_col_name create_definition clause. To do so, specify the old and new column names and the type that the column currently has. For example, to rename an INTEGER column from a to b, you can do this:

    mysql> ALTER TABLE t1 CHANGE a b INTEGER;
    Last edited by DR_LaRRY_PEpPeR; Jul 2, 2001 at 18:56.

  3. #3
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •