Collation options for new MySQL schemas and tables created in MySQL for Excel
By Javier Treviño on Aug 07, 2014
In this blog post we are going to talk about one of the features included since MySQL for Excel 1.3.0, you can install the latest GA or maintenance version using the MySQL Installer or optionally you can download directly any GA or non-GA version from the MySQL Developer Zone.
MySQL for Excel has always let you create new schemas and tables in a MySQL database, in versions lower than 1.3.0 these were created with the default character set and collation defined in the MySQL server. Starting with version 1.3.0 we introduced several features regarding collations:
- New drop-downs were added that let you to override the default collation for new MySQL schemas and tables.
- Default collations for each schema can be shownin the schemas list below the schema names.
- The SQL queries for schemas creation can be previewed or displayed (depending on its global setting).
Empty MySQL schemas can be created from MySQL for Excel using the Create New Schema action label found at the schema selection panel, where you normally would open a schema to display its database objects.
When creating a schema you will be able to override the default collation configured for the MySQL server you are connected to. A new Collation drop-down will display when expanded a list of all available collations, its default value is Server Default meaning the schema will be created using the default server collation.
Another nice addition is that you can preview the SQL query generated for a new schema creation if the Preview SQL statements before they are sent to the server global option is selected. (If you are not familiar with that feature you can read the following blog post that fully covers it: SQL queries preview before sent to server in MySQL for Excel.)
So for example if the koi8r_general_ci collation is selected for the new_schema...
and the Preview SQL statements before they are sent to the server global option is selected, when clicking OK the generated SQL query will be displayed and it will contain the specified collation (and its corresponding character set).
A new option was also added so you can display the collation of each of the schemas listed in the schema selection panel. If you right-click the schemas list a context-menu will be displayed, within it you will see the Display Schema Collations new option. Notice that it is disabled by default, so only the schema names are displayed.
If you enable Display Schema Collations by clicking on it, each schema collation will be displayed below its corresponding schema name. The setting is saved and remembered, so if you close Excel and open it later, MySQL for Excel will display schema collations depending on how the option was previously set.
Collations can now also be set for new MySQL tables created through the Export Data feature. (If you are not familiar with exporting Excel data to MySQL you can read the following blog post containing detailed information about it: How To - Guide to exporting data from Excel to a new MySQL table.)
At the Export Data dialog a Collation drop-down (similar to the one in the New Schema dialog) is displayed below the table Name field. Its default value is Schema Default, meaning the table will be created with the same collation defined in its parent schema.
You can override the default collation by selecting any other collation from the Collation drop-down list.
As we mentioned above, if the Preview SQL statements before they are sent to the server global option is selected, the generated SQL query will be displayed before the export operation takes place and it will contain the specified collation. So take the following screenshot as an example, in it we choose the latin1_spanish_ci collation for the city table we want to create.
When clicking Export Data, the generated SQL query will contain the statements related to setting the specified collation along with its corresponding character set.
This feature is very important when the data being handled requires a specific character enconding or when working with databases with different collations. We hope you give this and the other new features in the 1.3.x version family a try!
Remember that your feedback is very important for us, so drop us a message and follow us:
- MySQL on Windows (this) Blog: https://blogs.oracle.com/MySqlOnWindows/
- MySQL for Excel forum: http://forums.mysql.com/list.php?172
- Facebook: http://www.facebook.com/mysql
- YouTube channel: https://www.youtube.com/user/MySQLChannel