
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How do I see what character set a MySQL database / table / column is?
To check what character set a MySQL database/ table/ column is, let us see an example: A database which has the name ‘business’ and table name is ‘student’ which is already present in the database is used.
Syntax in order to check the table character set.
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "yourDatabaseName" AND T.table_name = "yourTableName";
Applying the above syntax to display character set for table student.
mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES` T, -> information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA -> WHERE CCSA.collation_name = T.table_collation -> AND T.table_schema = "business" -> AND T.table_name = "student";
The following is the output.
+--------------------+ | CHARACTER_SET_NAME | +--------------------+ | utf8mb4 | +--------------------+ 1 row in set (0.13 sec)
To find character set for database, here is the syntax.
SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "yourDatabaseName";
Applying the above syntax in order to see the character set for database.
mysql> SELECT default_character_set_name FROM information_schema.SCHEMATA -> WHERE schema_name = "business";
The following is the output.
+----------------------------+ | DEFAULT_CHARACTER_SET_NAME | +----------------------------+ | utf8mb4 | +----------------------------+ 1 row in set (0.00 sec)
To find the character set for column.
SELECT character_set_name FROM information_schema.`COLUMNS` WHERE table_schema = "yourDatabaseName" AND table_name = "yourTableName" AND column_name = "yourColumnName";
Applying the above syntax in order to see what character set is for column name ‘Name’ for the “student” table and “business” database.
mysql> SELECT character_set_name FROM information_schema.`COLUMNS` -> WHERE table_schema = "business" -> AND table_name = "student" -> AND column_name = "Name";
The following is the output.
+--------------------+ | CHARACTER_SET_NAME | +--------------------+ | utf8mb4 | +--------------------+ 1 row in set (0.00 sec)
- Related Articles
- How do I see all foreign keys to a table column?
- How do I alter a MySQL table column defaults?
- How do I see what a MySQL view is made of?
- How can I check the character set of all the tables along with column names in a particular MySQL database?
- How do I show the schema of a table in a MySQL database?
- How do I remove a MySQL database?
- How do I set the default value for a column in MySQL?
- How do I INSERT INTO from one MySQL table into another table and set the value of one column?
- How do I find out the default server character set in MySQL?
- Display MySQL Database, Table, and Column Information
- How do I alter table column datatype on more than 1 column at a time in MySql?
- While connecting to one MySQL database, how can I see the list of tables of other MySQL database?
- How do I check to see if a value is an integer in MySQL?
- How can I see the CREATE TABLE statement of an existing MySQL table?
- How can I count unique records from a column in MySQL database?

Advertisements