在哪里可以更改 MySQL Workbench 数据建模工具中表的默认字符集?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18971350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:57:10  来源:igfitidea点击:

Where can I change the default character set of a table in MySQL Workbench's data modeling tool?

mysqlmysql-workbench

提问by Franck Dernoncourt

I created a database schema using MySQL Workbench's data modeling tool. When it generates the SQL CREATE statements, it generates "default character set = latin1;" for some tables, e.g.:

我使用 MySQL Workbench 的数据建模工具创建了一个数据库模式。当它生成 SQL CREATE 语句时,它生成“default character set = latin1;” 对于某些表,例如:

-- -----------------------------------------------------
-- Table `moocdb`.`resource_types`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `moocdb`.`resource_types` (
  `resource_type_id` INT(11) NOT NULL,
  `resource_type_name` VARCHAR(20) CHARACTER SET 'utf8' NOT NULL,
  PRIMARY KEY (`resource_type_id`))
ENGINE = InnoDB
default character set = latin1;

How can I change it to the schema's default character set? (I found where to change the schema's default character set, but not the table's)

如何将其更改为架构的默认字符集?(我找到了在哪里更改架构的默认字符集,而不是表格的)



As a side note:

作为旁注

Note: Since MySQL 5.5.3 you should use utf8mb4rather than utf8. They both refer to the UTF-8 encoding, but the older utf8had a MySQL-specific limitation preventing use of characters numbered above 0xFFFD.

注意:从 MySQL 5.5.3 开始,您应该使用utf8mb4而不是utf8. 它们都指的是 UTF-8 编码,但较旧的utf8有 MySQL 特定的限制,防止使用编号高于 0xFFFD 的字符。

回答by Mike Lischke

You can set the used charset/collation combination in the table editor. You have to expand the header (which is by default collapsed to save space) to be able to change it. See this screenshot:

您可以在表编辑器中设置使用的字符集/排序规则组合。您必须展开标题(默认情况下折叠以节省空间)才能更改它。看这个截图:

enter image description here

在此处输入图片说明

回答by Stephane

Thanks a lot for this topic : it saves me a lot of time (I searched the header that was just collapsed by default).

非常感谢这个主题:它为我节省了很多时间(我搜索了默认情况下刚刚折叠的标题)。

I just want to say that you can specify for the table collation the option : schema default (the first option in the collation drop list).

我只想说,您可以为表排序规则指定选项:schema default(排序规则下拉列表中的第一个选项)。

And then, you can specify too the collation for the text type fields : table default.

然后,您也可以指定文本类型字段的排序规则:表默认值。

With that, you can control the collation of your database with just the global schema collation parameter.

这样,您只需使用全局模式排序规则参数即可控制数据库的排序规则。

(my mysql workbench version : 6.1.7 revision 11891 build 1788)

(我的 mysql 工作台版本:6.1.7 修订版 11891 构建 1788)

Enjoy

享受

回答by Sathish D

Expand the database. Select the table from the tree view-> Right click and select alter table. You will get the following window shown in the screen shot. Here you can change the charset.enter image description here

展开数据库。从树视图中选择表-> 右键单击​​并选择alter table。您将在屏幕截图中看到以下窗口。在这里您可以更改字符集。在此处输入图片说明

回答by chickenninja565

To change the entire database in the work bench...

要在工作台中更改整个数据库...

In "Model Overview", under "Physical Schemata", right-click the database and select "Edit Schema...". Define the character set to the "Collation"-field. (MySQL Workbench 5.2.35)

在“模型概述”中,在“物理模式”下,右键单击数据库并选择“编辑模式...”。将字符集定义为“排序规则”字段。(MySQL 工作台 5.2.35)

Answered here: https://stackoverflow.com/a/8149026/5579664

在这里回答:https: //stackoverflow.com/a/8149026/5579664

回答by Esad Me?edovi?

When you open your model, double click (or right click and edit) on MySQL schema, and MySQL Workbench show you, settings for Charset/Collation like as figure

当您打开模型时,双击(或右键单击并编辑)MySQL 模式,MySQL Workbench 会向您显示 Charset/Collat​​ion 的设置,如图

First Case

第一种情况

Second Case

第二种情况