Dans MariaDB, COLLATION() est une fonction intégrée secondaire qui renvoie le classement d'une chaîne donnée.
Nous fournissons la chaîne lorsque nous appelons la fonction.
Syntaxe
La syntaxe ressemble à ceci :
COLLATION(str)
Où str est la chaîne.
Exemple
Voici un exemple simple :
SELECT COLLATION('Maria'); Résultat :
+--------------------+
| COLLATION('Maria') |
+--------------------+
| utf8_general_ci |
+--------------------+ Et voici un autre exemple qui utilise des caractères thaïlandais :
SELECT COLLATION(_tis620'ไม้เมือง'); Résultat :
+----------------------------------------------+ | COLLATION(_tis620'ไม้เมือง') | +----------------------------------------------+ | tis620_thai_ci | +----------------------------------------------+
Type d'argument erroné
Passer un argument qui n'est pas une chaîne donne le mot binary être retourné.
SELECT COLLATION(123); Résultat :
+----------------+ | COLLATION(123) | +----------------+ | binary | +----------------+
Arguments nuls
Passer null résultats dans le mot binary être retourné.
SELECT COLLATION(null); Résultat :
+-----------------+ | COLLATION(null) | +-----------------+ | binary | +-----------------+
Argument manquant
Appel de COLLATION() sans passer d'argument génère une erreur :
SELECT COLLATION(); Résultat :
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1