SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    USA
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Rename Column

    How do you rename a database column with SQL?
    I looked on this one site and it showed this..
    Code:
    ALTER TABLE distributors RENAME COLUMN address TO city;
    Well I tried that and it didn't work. Does anybody know how?
    Chad Crouch
    http://chadmc.com

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RENAME is for tables. Try

    Code:
    ALTER TABLE tablename CHANGE OLD_COLNAME NEW_COLNAME definition
    Example Change a field named in Name in a Table Users to varchar(255) NOT NULL.

    Code:
    ALTER TABLE Users CHANGE Name FirstName varchar(255) NOT NULL
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •