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.


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

  ADD COLUMN column2 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_hungarian_ci DEFAULT NULL AFTER column1;
  • 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
ALTER TABLE `database_name`.`table_name`  
CHANGE `column_name` `column_name`  VARCHAR(255) CHARSET utf8 COLLATE utf8_hungarian_ci NULL;

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


While specifying the collate to the table you have been careful about the table.

alter table `table_name`
add column column_name varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL
comment 'Comment to the attachment file';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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