©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The COERCIBILITY SQL Function in MySQL and MariaDB - Coercibility value of the collation of the string

COERCIBILITYSyntax:COERCIBILITY(String)
Return value:INTEGER
Function type:Information function
Function Description

The COERCIBILITY() function returns the coercibility value of the collation of the "String" argument.

Coercibility defines what is converted to what in the event of a collation conflict, converting a higher coercibility expression to the collation of a lesser coercibility expression.


Coercibility  Description  Example  
0ExplicitValue using a COLLATE clause
1No sortingConcatenated strings with different collations
2ImplicitColumn value
3ConstantUSER() return value
4EnforceableLiteral string
5Low enforceabilityNumbers
6IgnorableNULL or derived from NULL

SQL Examples for the COERCIBILITY function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

SELECT COERCIBILITY('Test');
SELECT COERCIBILITY(100);

SELECT COERCIBILITY(convert(100.234 USING utf8));
SELECT COERCIBILITY(convert(100 USING utf8));
SELECT COERCIBILITY(convert('Test' USING utf32));

SELECT COERCIBILITY(convert('Test'char));
SELECT COERCIBILITY(convert('Test'nchar));  /* To National Character Set */
SELECT COERCIBILITY(convert('Test'char CHARACTER SET utf8mb4));

SELECT COERCIBILITY(null);

COERCIBILITY('Test')
int(10)
4
COERCIBILITY(100)
int(10)
5
COERCIBILITY(convert(100.234 USING utf8))
int(10)
2
COERCIBILITY(convert(100 USING utf8))
int(10)
2
COERCIBILITY(convert('Test' USING utf32))
int(10)
2
COERCIBILITY(convert('Test', char))
int(10)
2
COERCIBILITY(convert('Test', nchar))
int(10)
2
COERCIBILITY(convert('Test', char CHARACTER SET utf8mb4))
int(10)
2
COERCIBILITY(null)
int(10)
6
The examples were created with the MyWAY SQL manager: Download

How to use the COERCIBILITY() function in MySQL and MariaDB databases

In MySQL and MariaDB, the COERCIBILITY() function can be used to determine the collation coercivity of an expression or a determine column collation by returning an integer value representing the degree of constraint used to determine how operands in an expression should be compared and implicitly converted when their collations differ. The function takes a table column, a literal value, or any valid expression as an argument.

The coercivity values ​​are assigned as follows:

0: constants and system functions = highest compulsiveness
1: collational coercibility of the result of the COALESCE function
2: Explicit collation enforceability using the COLLATE clause
3: Collation coercibility of a table column
4: Collation constraint capability of an expression
5: Implicit collation coercibility of string literals and numeric values ​​= lowest coercibility
6: NULL values ​​= are ignored

The COERCIBILITY() function is primarily used internally by the database engine to determine collation and implicit conversion behavior when processing complex queries, collation analysis, and solving collation problems. The practical use of the function in SQL queries is relatively limited, but can be useful when troubleshooting collation problems or handling complex queries with different collations and implicit conversions.
CHARSETCHRCOALESCECOERCIBILITYCOLLATIONCOMPRESSCONCAT

Further MySQL und MariaDB SQL Information functions

BENCHMARKBENCHMARK(Number, Expression)
More about BENCHMARK Function

BINLOG_GTID_POSBINLOG_GTID_POS()

CHARSETCHARSET(String)
More about CHARSET Function

COLLATIONCOLLATION(String)
More about COLLATION Function

CONNECTION_IDCONNECTION_ID()
More about CONNECTION_ID Function

CURRENT_USERCURRENT_USER()
More about CURRENT_USER Function

CURRENT_ROLECURRENT_ROLE()
More about CURRENT_ROLE Function

DATABASEDATABASE()
More about DATABASE Function

DECODE_HISTOGRAMDECODE_HISTOGRAM()

DEFAULTDEFAULT(Column)
More about DEFAULT Function

FOUND_ROWSFOUND_ROWS()
More about FOUND_ROWS Function

LAST_INSERT_IDLAST_INSERT_ID([Expression])
More about LAST_INSERT_ID Function

LAST_VALUELAST_VALUE(Expression [, Expression ...])
More about LAST_VALUE Function

ROWNUMROWNUM()

ROW_COUNTROW_COUNT()
More about ROW_COUNT Function

SCHEMASCHEMA()
More about SCHEMA Function

SESSION_USERSESSION_USER()
More about SESSION_USER Function

SYSTEM_USERSYSTEM_USER()
More about SYSTEM_USER Function

USERUSER()
More about USER Function

VERSIONVERSION()
More about VERSION Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the COERCIBILITY SQL function: mysql.com and mariadb.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer