Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there any command in mysql that makes the following: if I create a new field and I set the type to TEXT than it automatically knows that by this I mean not latin1_swedish_ci but utf8_hungarian_ci charset.

I would like to apply this changes to the whole database without create a new table.

share|improve this question
add comment

migrated from stackoverflow.com Feb 1 '12 at 14:07

This question came from our site for professional and enthusiast programmers.

3 Answers

You can specify this option in a field definition - CREATE TABLE Syntax, ALTER TABLE Syntax. Try this ALTER statement -

ALTER TABLE table1
  ADD COLUMN column2 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_hungarian_ci DEFAULT NULL AFTER column1;
share|improve this answer
    
It it possible to do this globally and without create a new table? –  2astalavista Feb 1 '12 at 9:51
    
No, it is not possible to do it globally, the 'ALTER TABLE' statement can be used only for one specified table. So, you should execute 'ALTER TABLE' for each table, ...but you can change all table fields at a time;-) –  Devart Feb 1 '12 at 10:10
add comment

The column level setting inherits from the table, database and instance settings

Globally, it is set at command line on startup.

I'd think carefully about the consequences of changing this because it affects more than the default for tables. For that, then look at ALTER DATABASE

share|improve this answer
add comment
ALTER TABLE `database_name`.`table_name`  
CHANGE `column_name` `column_name`  VARCHAR(255) CHARSET utf8 COLLATE utf8_hungarian_ci NULL;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.