使用列子选项卡显示和编辑表的所有列信息。使用此子选项卡,您可以添加、删除和更改列。
您还可以使用“列”子选项卡更改列属性,例如名称、数据类型和默认值。下图显示了 列子选项卡的示例。
右键单击列下方的一行Column Name
以打开包含以下项目的弹出菜单:
上移:将选定的列向上移动。
下移:将选定的列向下移动。
复制:复制模型的列。
剪切:复制然后删除模型的列。
粘贴:粘贴列。如果已存在具有相同名称的列,则将
_copy1
附加到列名。删除选定的列:通过右键单击并按下 Shift键来选择多个连续的列。使用Control 键选择分隔的列。
刷新:更新列子选项卡中的所有信息。
清除默认值:清除分配的默认值。
默认 NULL:将列默认值设置为
NULL
。默认 0:将列默认值设置为
0
。默认 CURRENT_TIMESTAMP:可用于
TIMESTAMP
数据类型。默认 CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP:可用于
TIMESTAMP
数据类型。
要添加列,请单击Column Name
空行中的字段并输入适当的值。从数据类型列表中选择数据类型。根据后面的列属性列表,根据需要选择列属性复选框。有关每个项目的描述,请参阅
CREATE TABLE。
PK:主键
NN:不为空
昆士兰大学:唯一指数
BIN:二进制
UN : 未签名
采埃孚: ZEROFILL
人工智能:自动递增
-
G:生成的列
此选项从 MySQL Server 5.7 开始可用。
要更改列的名称、数据类型、默认值或注释,请双击该值进行编辑。
您还可以向该Column
Comment
字段添加列注释。也可以使用“列详细信息”面板中的列表来设置列排序规则。
To the left of the column name is an icon that indicates whether
the column is a member of the primary key. If the icon is a small
key, that column belongs to the primary key, otherwise the icon is
a blue diamond or a white diamond. A blue diamond indicates the
column has NN set. To add or remove a column
from the primary key, double-click the icon. You can also add a
primary key by checking the PRIMARY KEY
check
box in the Column Details
section of the table
editor.
If you wish to create a composite primary key you can select multiple columns and check the PK check box. However, there is an additional step that is required, you must click the Indexes tab, then in the Index Columns panel you must set the desired order of the primary keys.
When entering default values, in the case of
CHAR
and VARCHAR
data
types MySQL Workbench will attempt to automatically add quotation
marks, if the user does not start their entry with one. For
other data types the user must manage quoting if required, as it
will not be handled automatically by MySQL Workbench.
Care must be taken when entering a default value for
ENUM
columns because a non-numeric default
will not be automatically quoted. You must manually add single
quote characters for the default value. Note that MySQL Workbench
will not prevent you from
entering the default value without the single quotation marks.
If a non-numeric default value is entered without quotation
marks, this will lead to errors. For example, if the model is
reverse engineered, the script will contain unquoted default
values for ENUM
columns and will fail if an
attempt is made to run the script on MySQL Server.
将这些数据类型输入 MySQL Workbench 时,ENUM、BIT 和 SET 必须至少包含一个值。