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

The CHARSET SQL Function in MySQL and MariaDB - Character set of the argument

CHARSETSyntax:CHARSET(String)
Return value:CHAR
Function type:Information function
Function Description

The CHARSET() function returns the character set of the argument "String".

The return value is the name of the character set.

If the "String" argument is not a string, it is treated as a binary string and the function returns binary.

If the value of the argument is NULL, the CHARSET() function also returns binary.

SQL Examples for the CHARSET function

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

SELECT charset('Test');
SELECT charset(100);

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

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

SELECT CHARSET(null);

charset('Test')
varchar(64) BINARY
binary
charset(100)
varchar(64) BINARY
binary
CHARSET(convert(100.234 USING utf8))
varchar(64) BINARY
utf8
CHARSET(convert(100 USING utf8))
varchar(64) BINARY
utf8
CHARSET(convert('Test' USING utf32))
varchar(64) BINARY
utf32
CHARSET(convert('Test', char))
varchar(64) BINARY
binary
CHARSET(convert('Test', nchar))
varchar(64) BINARY
utf8
CHARSET(convert('Test', char CHARACTER SET utf8mb4))
varchar(64) BINARY
utf8mb4
CHARSET(null)
varchar(64) BINARY
binary
The examples were created with the MyWAY SQL manager: Download

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

In MySQL and MariaDB the CHARSET() function is used to get the character set of a specific character string or of a given expression by having the function return the character set name as a string. The argument can be a table column name, a literal string, or any valid expression that evaluates to a string. Thus, the character set of a character string or an expression can be identified dynamically, for example in data analysis, data manipulation or when dealing with multilingual data. The function is based on the sorting and character set settings of the server, the database and the table column.
CHARCHAR_LENGTHCHARACTER_LENGTHCHARSETCHRCOALESCECOERCIBILITY

Further MySQL und MariaDB SQL Information functions

BENCHMARKBENCHMARK(Number, Expression)
More about BENCHMARK Function

BINLOG_GTID_POSBINLOG_GTID_POS()

COERCIBILITYCOERCIBILITY(String)
More about COERCIBILITY 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 CHARSET SQL function: mysql.com and mariadb.com
Updated: 2023-09-17ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer