Computer >> Computer tutorials >  >> Programming >> MySQL

How can we check the default character sets of a particular MySQL database?


Following is the query to check default character set of the particular MySQL database −

mysql> SELECT SCHEMA_NAME 'DatabaseName', default_character_set_name 'Charset' FROM information_schema.SCHEMATA where schema_name = 'db_name';

Example

For example, the query below will return the default character set of a database named ‘Sample’ −

mysql> SELECT SCHEMA_NAME 'DatabaseName', default_character_set_name 'Charset' FROM information_schema.SCHEMATA where schema_name = 'Sample';
+----------------+---------+
| DatabaseName   | Charset |
+----------------+---------+
| Sample         | latin1  |
+----------------+---------+
1 row in set (0.00 sec)