
- 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 to change the default charset of a MySQL table?
To change the default charset of a MySQL table, you can use the below syntax. The syntax is as follows −
alter table yourTableName convert to character set yourCharsetName;
Let us create a table and apply the above syntax to change the default charset. The query to create a table −
mysql> create table CharsetDemo -> ( -> Id int, -> Name varchar(200), -> Age int -> ); Query OK, 0 rows affected (0.73 sec)
Now you can change the charset of a table. The following is the query to set the charset, which in turn will change the default charset.
mysql> alter table CharsetDemo convert to character set latin7 ; Query OK, 0 rows affected (1.59 sec) Records: 0 Duplicates: 0 Warnings: 0
Now you can check that the charset has been changed or not with the help of SHOW CREATE command.
The query is as follows −
mysql> show create table CharsetDemo;
Here is the output −
+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | CharsetDemo | CREATE TABLE `charsetdemo` (`Id` int(11) DEFAULT NULL,`Name` varchar(200) DEFAULT NULL,`Age` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin7 | +-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
Look at the above output, the charset have been changed to latin7.
- Related Articles
- How can I change the default sort order of MySQL tables?
- How can we change the name of a MySQL table?
- How can we change the default MySQL database to the given database?
- How to change Table Engine in MySQL?
- How can I change the storage engine of a MySQL table?
- Change tinyint default value to 1 in MySQL?
- How to Change the Default Home Directory of a User on Linux?
- Determine what a MySQL DB’s charset is set to
- How to change the default configuration in Git?
- How to change format of dates in a table column with a MySQL query?
- Set column charset in MySQL?
- How to change the date in a table with date records with MySQL?
- How to change the column position of MySQL table without losing column data?
- Creating a Table in MySQL to set current date as default
- Change MySQL default character set to UTF-8 in my.cnf?

Advertisements