Encoding

This is a discussion on Encoding within the MySQL Database forums, part of the Database Forums category; I have moved DB from one to another machine, but I forgot to set up the encoding of databases, so ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-26-2007
Marek Simon
 
Posts: n/a
Default Encoding

I have moved DB from one to another machine, but I forgot to set up the
encoding of databases, so some of them are wrong. Is it possible to
change database/table/column encoding without a need of exporting data,
re-create the database and importing the data?
Marek Simon, Prague, Czech Republic
Reply With Quote
  #2 (permalink)  
Old 04-26-2007
lark
 
Posts: n/a
Default Re: Encoding

Marek Simon wrote:
> I have moved DB from one to another machine, but I forgot to set up the
> encoding of databases, so some of them are wrong. Is it possible to
> change database/table/column encoding without a need of exporting data,
> re-create the database and importing the data?
> Marek Simon, Prague, Czech Republic


run this for your data abase:

ALTER DATABASE db_name
DEFAULT CHARACTER SET utf8 COLLATE utf8_persian_ci




then run this for each table already in the database :

ALTER TABLE table_XXX CONVERT TO CHARACTER SET utf8 COLLATE utf8_persian_ci;

replace collation and/or character set as appropriate
Reply With Quote
  #3 (permalink)  
Old 04-26-2007
Joachim Durchholz
 
Posts: n/a
Default Re: Encoding

lark schrieb:
>
> ALTER TABLE table_XXX CONVERT TO CHARACTER SET utf8 COLLATE
> utf8_persian_ci;
>
> replace collation and/or character set as appropriate


Wouldn't you have to alter the column definitions as well?
IIRC altering the table would only change the defaults for columns that
are added without specifying a character set and collation.

Regards,
Jo
Reply With Quote
  #4 (permalink)  
Old 04-27-2007
Willem Bogaerts
 
Posts: n/a
Default Re: Encoding

>> ALTER TABLE table_XXX CONVERT TO CHARACTER SET utf8 COLLATE
>> utf8_persian_ci;

>
> Wouldn't you have to alter the column definitions as well?
> IIRC altering the table would only change the defaults for columns that
> are added without specifying a character set and collation.


That is exactly what the above statement does. If you only want to
change the default, use something like:
ALTER TABLE table_XXX CHARACTER SET=utf8;

--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0