Raj Janorkar
Raj Janorkar

Reputation: 77

Confusion with utf8_general_ci & utf8_unicode_ci

Mysql server collation is utf8_general_ci in my.cnf

I am using utf8_general_ci collation for database, now i have created few tables with utf8_unicode_ci collation in same database.

Now i would like to use utf8_unicode_ci for server/database/tables/fields. In order to do that first i need to change collation for server to utf8_unicode_ci then for database, tables and fields.

My question is i already have data in tables stored using utf8_general_ci, can i just keep as it is without doing anything to data Or do i need to do any kind of conversion.

Other thing is, as you can see server level collation is utf8_general_ci but at table and field level is utf8_unicode_ci, so with my current setup when i store and retrieve data from these tables what collation mysql use?

Thank you.

Upvotes: 3

Views: 644

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 158007

"Server level" collation means nothing.
Server and database level charset (and collation) serve as mere default values for the table (and database) creation.

  • Say, if you didn't supply any collation when created a database, it will be created using server collation. But if you do - the supplied one will be used and server collation won't interfere at all.
  • If you didn't supply any collation in table definition, the table will be created using database collation. But if you do - the supplied one will be used and neither server nor database collation will affect your queries.

It's only table and field level collation that matters.

if i already have data in tables stored using utf8_general_ci, can i just keep as it is

Yes. You can have tables with any charset in your database.

Upvotes: 1

Related Questions