Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.
25% off Hosting at HostGator.com:
Use Code techbits25



How can I rename a field in a mysql table?

Last updated: 07/03/2009

You can change a field name in an existing table, using the CHANGE keyword:


alter table rss_feed change unsubscribe_url referring_url varchar(255) NULL;


This comes in handy to keep field names closer to the actual meaning of the data, or if there was a misspelling made during table creation.

blog comments powered by Disqus
Have your own Tech-bit to contribute? Submit it here


Showing: 1-4 of 4  
Comments:
  • 06/10/2011   |   karan

  • It is very useful to me.



  • 02/22/2010   |   Fergal

  • tnx this was very helpful :)



  • 12/22/2009   |   addhe

  • thank you, this tutorial is working



  • 05/13/2008   |   jani pasha

  • Have a nice day to all,
    i was trying to rename a particular column name in a table .....and the syntax is
    alter table <table_name> change <old_column_name> <new_column_name> null;
    its working successfully....
    thanks with regards
    (Md.Jani Pasha)



    Add comment:
    Name:
    Email:
    Comment: *
    (Use BBcode - No HTML)


    You MUST answer this simple math equation - to prevent spammers:  


    Other questions in this category:
    What causes an error 150 when loading data into a mysql database?
    How can I display long records in mysql without wrapping?
    How can I import data in mysql
    How can I get mysql table definitions in my php script?
    How can I execute commands on mysql using a php script?
    What causes mysql to give an error 145?
    How can I add a conditional statement in the field list of my sql statement?
    How can I dump table definitions (with no data) using mysqldump?
    How can I manipulate a table with a reserved word as a column name?
    How can I find out table information in mysql?
    How can a change a user password in mysql?
    How can I reset the auto_increment id field in my table?
    How can I see the syntax used to create a table in mysql?
    How can I delete or remove a field from a mysql table?
    What does an error 'Got error 122 from storage engine' mean?
    How can I run sql commands from a file or import tables from the mysqldump?
    How can I create a CSV file from a query?
    How can I dump selected records using mysqldump?
    How can I sum a field in mySQL only if it contains a value?
    How can I find out all the unique values stored in a specific field?
    How can I give a custom name to a field in my SQL query?
    How can I copy a table from one database to another?
    How can I do a search and replace in a mysql table?
    How can I load in a sql file using the mysql command line?
    How can I setup a field to record the last update of a record in mysql?
    I need a php function to put all rows from a mysql query into an array
    How can I find old or expired records in a database?
    What's an easy backup script for my mysql databases?
    How can I load a mysql query into a hash in php?
    How to match a mysql datetime field for a specific day
    How can I total up the number of entries in a database table by month?
    SQL basics
    Why use Mysql?
    How do I remove / delete a field from a table?
    How can I get rid of strange characters in my database output?
    Tuning your mysql database.
    How can a rearrange or reorder the column order in my table?
    How can I fix this error: Can't create/write to file '/tmp/#sql_1111.MYD' (Errcode: 17)?
    How do I reset my mysql quota on a 1&1 shared account?
    How can I figure out the next auto_increment value for my table?
    How can I see how big each mysql table is?
    How can I remove a primary key from my database table?
    How can I restore part of a table from a mysqldump backup file?
    How to use Mysql subqueries instead of a join
    How can I re-order the fields in my mysql database?
    How can I recreate all the users in my database to a new database?
    How can I log slow queries in mysql?



    Powered by KnowledgebasePublisher 1.1
    Host Gator
    Content provided by Roberts WebForge, Inc.