

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How can we change the name of a MySQL table?
- How can I change the default sort order of MySQL tables?
- How can I change the storage engine of a MySQL table?
- How can we change the default MySQL database to the given database?
- How to change Table Engine in MySQL?
- How to change the transparency/opaqueness of a Matplotlib Table?
- Change tinyint default value to 1 in MySQL?
- How to change the default configuration in Git?
- Set column charset in MySQL?
- How to change the column position of MySQL table without losing column data?
- How to change format of dates in a table column with a MySQL query?
- With JavaScript how to change the width of a table border?
- How to change the date in a table with date records with MySQL?
- How can I change the value of an instance of a row in MySQL table?
- How can I change the name of an existing column from a MySQL table?
Advertisements