How can I enter data using non English (Bangla) language into this database table ?
Asked
Active
Viewed 3,458 times
5
-
You need to change the collation of your table to a UTF-8 flavor which supports Bangla. – Tim Biegeleisen Jul 24 '16 at 11:48
-
@TimBiegeleisen - utf8 is a "character set"; it supports Bangla. The "collation" does not matter. – Rick James Aug 18 '16 at 17:56
-
@RickJames You might want to comment on the answer below, but point taken. – Tim Biegeleisen Aug 18 '16 at 18:04
1 Answers
6
As pointed out by @Tim you need to change the collation
of your table/database/column to UTF-8
. First check the collation of your database/table/column
.
CHECK COLLATION:
How to check the collation of DATABASE:
SELECT
default_character_set_name
FROM
information_schema.SCHEMATA
WHERE
schema_name = "YOUR_DATABASE_NAME";
How to check the collation of TABLE:
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 = "YOUR_DATABASE_NAME"
AND T.table_name = "YOUR_TABLE_NAME";
How to check the collation of a COLUMN:
SELECT
character_set_name
FROM
information_schema.`COLUMNS`
WHERE
table_schema = "YOUR_DATABASE_NAME"
AND table_name = "YOUR_TABLE_NAME"
AND column_name = "YOUR_COLUMN_NAME";
Change COLLATION:
How to change database collation:
ALTER DATABASE YOUR_DATABASE_NAME CHARACTER SET utf8 COLLATE utf8_unicode_ci;
How to change table collation:
ALTER TABLE YOUR_TABLE_NAME CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
How to change column collation:
ALTER TABLE YOUR_TABLE_NAME MODIFY YOUR_COLUMN_NAME VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Example:
DROP TABLE IF EXISTS `sample_table`;
CREATE TABLE `sample_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`language` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO sample_table(name,language) VALUES('Ed Sheeran','English');
INSERT INTO sample_table(name,language) VALUES('আয়েশা খাতুন সুজানা','আমার সোনার বাংলা');
Look, the CHARSET
used in the table definition is utf8
. So, you can store unicode characters
in the table.
Check whether the data inserted correctly or not.
SELECT * FROM sample_table
;
Result:
| id | name | language |
|----|--------------------|------------------|
| 1 | Ed Sheeran | English |
| 2 | আয়েশা খাতুন সুজানা | আমার সোনার বাংলা |

1000111
- 13,169
- 2
- 28
- 37
-
Thank you so much for helping me with details , but still not showing – Ayesha Khatun Sujana Jul 25 '16 at 03:15
-
I guess this issue is not in the `MySQL` side. May be you need to change the font from netbeans settings. Please check this [**POST**](http://stackoverflow.com/questions/7219249/netbeans-console-does-not-display-bangla-unicode-characters) – 1000111 Jul 25 '16 at 06:25
-
-
I tested it in my ide. It's working here. Actually I simulated ur problem and then got out of it. May be u r missing something. – 1000111 Jul 30 '16 at 17:19
-
-
Rather than those 3 queries up front, simply do `SHOW CREATE TABLE`. – Rick James Aug 18 '16 at 17:56
-
-
Netbeans settings can be found in this [**post**](http://stackoverflow.com/questions/7219249/netbeans-console-does-not-display-bangla-unicode-characters). And I just wanted to mention the things specifically. @RickJames – 1000111 Aug 18 '16 at 18:01
-
Please see the tip on using `SELECT HEX...` in http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored -- Does `ধন্যবাদ` show hex `E0A6A7 E0A6A8 E0A78D E0A6AF E0A6AC E0A6BE E0A6A6`? That is correct utf8 encoding. (Each Bengali character is hex `E0Axxx`.) – Rick James Aug 18 '16 at 18:01
-
-
@AyeshaKhatunSujana -- several of my comments are aimed more at you than at Tim. In particular, let's see the HEX. – Rick James Aug 18 '16 at 18:07