Specifying Character Set and Collation for Clusters
On this page
Setting Character Set and Collation Engine Variables
Specify the character set for the cluster by setting the character_ engine variable.
Specify the collation for the cluster by setting one of the collation_, collation_, and collation_ engine variables.
Important
Although these variables are session variables, these variables must be set globally to avoid undesired behavior.
character_ set_ server
Controls the default character set of the cluster.utf8mb4, utf8, or binary.
If character_ is set to a value that is different from its previous value, the associated collation variables collation_, collation_, and collation_ are set to that character set’s default collation.
collation_ connection, collation_ database, and collation_ server
Controls the default collation of the cluster.
When any of the collation_, collation_, and collation_, variables are set, the other two variables are set to the same value and the collation is applied to the nodes.
In addition, when any of these three variables is set, the variable character_ is set to a value that corresponds to the collation.
Set character_ set_ server
To set the character_ variable cluster-wide, use the following instructions.
Using a SingleStore client, run SET CLUSTER (the equivalent of SET GLOBAL) to set the character_ variable across the cluster.
SET CLUSTER character_set_server = 'utf8';
Query OK, 0 rows affected (0.03 sec)If the character_SET CLUSTER (or its equivalent SET GLOBAL) or SET AGGREGATOR, additionally run FLUSH CONNECTION POOLS on every aggregator node and restart the SQL session for the new value to take effect.
SingleStore offers commands to set engine variables cluster-wide, on all aggregator nodes, or on leaf nodes.
Set collation_ connection, collation_ database, and collation_ server
To set the collation variables cluster-wide, use the following instructions.
Using a SingleStore client, run SET CLUSTER (the equivalent of SET GLOBAL) to set the collation variable across the cluster.
SET CLUSTER collation_server = 'utf8_general_ci';
Query OK, 0 rows affected (0.03 sec)If a collation variable is set using SET CLUSTER (or its equivalent SET GLOBAL) or SET AGGREGATOR, additionally run FLUSH CONNECTION POOLS on every aggregator node and restart the SQL session for the new value to take effect.
SingleStore offers commands to set engine variables cluster-wide, on all aggregator nodes, or on leaf nodes.
Warning
The following SingleStore engine variables exist for backwards compatibility with MySQL and are non-operational in SingleStore.
-
character_set_ client -
character_set_ connection -
character_set_ database -
character_set_ filesystem -
character_set_ results -
character_set_ system -
character_sets_ dir
Reading Character Set and Collation Engine Variables
To retrieve values of the character set or the collation in current use, use the @@ selector with the required variable in a SELECT statement.
SELECT @@collation_server;
+--------------------+
| @@collation_server |
+--------------------+
| utf8mb4_general_ci |
+--------------------+
1 row in set (0.00 sec)Collation Example
The following example shows that utf8_ collation is case-insensitive.
SET collation_connection = 'utf8_general_ci';SELECT 'A' = 'a';
+-----------+
|'A' = 'a' |
+-----------+
| 1 |
+-----------+The following example shows that utf8_ collation is case-sensitive.
SET collation_connection = 'utf8_bin';SELECT 'A' = 'a';
+-----------+
|'A' = 'a' |
+-----------+
| 0 |
+-----------+Important
Among the collations supported for the utf8mb4 character set, SingleStore recommends utf8mb4_ for accurate comparison and sorting of characters, especially when using characters from non-English international languages.utf8mb4_ improves the performance of comparing and sorting operations, the results may not be precise when using certain language characters.
Last modified: