Jump to content


Photo

syntax for changing column name


  • Please log in to reply
2 replies to this topic

#1 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 21 March 2006 - 12:52 PM

Hi,
I need to know how to change the name of some columns in my database. I would also like to change the name of my database. All of this without altering data stored in the database or dropping anyhing. If you know the syntax to do this please let me know. Thanks.

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 21 March 2006 - 01:30 PM

ALTER TABLE will change table and column names, ALTER DATABASE will change database name... See the documentation at www.mysql.com for more details.

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 23 March 2006 - 08:08 AM

To change a column name:

ALTER TABLE yourTable CHANGE COLUMN yourOldColumn yourNewColumn <column details>

To rename a DB, you really need to shutdown the server, rename the actual directory itself, and then handle all the privileges. I don't think there's another way, though I think 5.1 will have a RENAME DATABASE command.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users