Skip to main content

How To Rename Or Change Name of Table Columns in MySQL

To change column name in MySQL Table,
ALTER TABLE table_name CHANGE old_column_name new_column_name DATA_TYPE;

For example,to change misspelled column name 'fist_name',
ALTER TABLE users CHANGE fist_name first_name VARCHAR(64);

In addition, you can change multiple column names in a query and set languages, default value, etc.
ALTER TABLE users CHANGE fist_name first_name VARCHAR( 64 ) NOT NULL,
  CHANGE username user_name VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ,
  CHANGE gend gender TINYINT( 1 ) NOT NULL DEFAULT 0;

Comments

Popular posts from this blog

Google's Favorite Colors By Hex Codes (With New Google Logo)

Google keeps its color scheme cross their products. Of course, each uses different colors but it keeps the main philosophy. I heard that the test period for new Google logo was more than one year. It may the reason that the colors are comfortable to look. Sometimes, I copy the colors for designing my blogs and web sites. Copyright? oh..

Why Blogger Mobile Template Not Work?

Google Blogger shows blog pages with mobile CSS on mobile devices unless you change it disabled. You can see next figure by clicking mobile setting button on Template page. Since I want to change CSS and I remember there are some CSS elements starting with '.mobile', I open the template editor and edit as I want. And open my blog in my smart phone. Nothing changed.