How to Rename SQL Table Names (Urgent Please)

Discussion in 'PHP' started by bushib, Sep 9, 2008.

  1. #1
    Hi there,

    I want to know that how to rename the SQL table names with a command.

    Any help will be highly appreciated.

    Regards
    bushib
     
    bushib, Sep 9, 2008 IP
  2. themaster

    themaster Well-Known Member

    Messages:
    934
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    140
    #2
    RENAME TABLE first_name TO second_name;
     
    themaster, Sep 9, 2008 IP
  3. bushib

    bushib Banned

    Messages:
    1,096
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    I used the same command but it don't work.

    I exported the database and changed the table names. Now When I import the database it gives me the error.

    Any help please.

    Thanks
    bushib
     
    bushib, Sep 9, 2008 IP
  4. themaster

    themaster Well-Known Member

    Messages:
    934
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Can you try this;
    ALTER TABLE first_name RENAME TO second_name;
     
    themaster, Sep 9, 2008 IP
  5. bushib

    bushib Banned

    Messages:
    1,096
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi there,

    I tried it too but it generate the following error.

    "Error

    SQL query:

    ALTER TABLE

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 "

    Any help?

    Regards
    bushib
     
    bushib, Sep 9, 2008 IP
  6. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #6
    Select the table you want to change, go to operations, then go the the form table "Table options" then just change the name.
     
    dannywwww, Sep 9, 2008 IP
  7. bushib

    bushib Banned

    Messages:
    1,096
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi,

    I created the table by running SQL Query.

    So there is no such option to select the table.

    The only way to change the name is through command but no command seems to change the name of the table.

    I get error when I try to change it through command.

    Any help please.

    Thanks
    bushib
     
    bushib, Sep 9, 2008 IP
  8. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #8
    dannywwww, Sep 9, 2008 IP
  9. bushib

    bushib Banned

    Messages:
    1,096
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    hi,

    In PhyMyAdmin > Database > Operations, there is only option for renaming the database and not for the table.

    Actually, I created the tables in question with command.

    And

    This command also don't work RENAME TABLE tablename TO tablename_renamed and give errors.

    I don't know how to fix this problem.

    Any more help please.

    Regards
    bushib
     
    bushib, Sep 9, 2008 IP
  10. iam.xavier

    iam.xavier Well-Known Member

    Messages:
    521
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    125
    #10
    before running the command Check the privileges if it is not a Root user and try again
     
    iam.xavier, Sep 9, 2008 IP
  11. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #11
    You have to actually go to the table you want to rename, when you click that you'll see browse, insert and so on click on operations on there.

    phpmyadmin > database > table > operation
     
    dannywwww, Sep 9, 2008 IP