如何使用非英语(Bangla)语言将数据输入此数据库表?

时间:2016-07-24 11:37:46

标签: mysql sql database netbeans nlp

如何使用非英语(Bangla)语言将数据输入此数据库表? enter image description here

1 个答案:

答案 0 :(得分:4)

正如@Tim所指出的,您需要将表/数据库/列的collation更改为UTF-8。首先检查database/table/column

的排序规则

检查合并:

如何检查DATABASE的整理:

SELECT
    default_character_set_name
FROM
    information_schema.SCHEMATA
WHERE
    schema_name = "YOUR_DATABASE_NAME";

如何检查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";

如何检查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";

更改COLLATION:

如何更改数据库归类:

ALTER DATABASE YOUR_DATABASE_NAME CHARACTER SET utf8 COLLATE utf8_unicode_ci;

如何更改表格排序:

ALTER TABLE YOUR_TABLE_NAME CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

如何更改列整理:

ALTER TABLE YOUR_TABLE_NAME MODIFY YOUR_COLUMN_NAME VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

示例:

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('আয়েশা খাতুন সুজানা','আমার সোনার বাংলা');

看,表定义中使用的CHARSETutf8。因此,您可以将unicode characters存储在表格中。

检查数据是否正确插入。

SELECT * FROM sample_table;

<强>结果:

| id |               name |         language |
|----|--------------------|------------------|
|  1 |         Ed Sheeran |          English |
|  2 |    আয়েশা খাতুন সুজানা |  আমার সোনার বাংলা |