如何使用非英语(孟加拉语)语言将数据输入到此数据库表中?

2022-01-02 00:00:00 nlp sql database mysql netbeans

如何使用非英语(孟加拉语)语言将数据输入到此数据库表中?

How can I enter data using non English (Bangla) language into this database table ?

推荐答案

正如@Tim 所指出的,您需要将表/数据库/列的 collat​​ion 更改为 UTF-8.首先检查您的database/table/column 的排序规则.

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.

检查整理:

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

<小时>

更改排序规则:

如何更改数据库排序规则:

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 字符.

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;

结果:

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

相关文章