在 MySQL 中创建域

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1693991/
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 14:27:11  来源:igfitidea点击:

Create Domain in MySQL

mysql

提问by Wilson

Please help me to create domain in MySQL. I have tried to run the followoing statement in MySQL but got syntax error:

请帮我在 MySQL 中创建域。我试图在 MySQL 中运行以下语句,但出现语法错误:

create domain age as int(2); 

回答by Phil Ross

MySQL doesn't support user-defined domains, so it is not possible to run a CREATE DOMAINstatement.

MySQL 不支持用户定义域,因此无法运行CREATE DOMAIN语句。

回答by mRt

Your syntax is not ok. I don't think that CREATE DOMAIN is supported by MySQL.

你的语法不行。我认为 MySQL 不支持 CREATE DOMAIN。

回答by Evan Carroll

Both MySQL and MariaDB currently lack this feature. DOMAINs are a method of associating a constraint with a type creating a pseudo-user defined type. Those constraints that will otherwise be attached to the DOMAIN will have to be placed on everything that uses that type, and managed there.

MySQL 和 MariaDB 目前都缺少此功能。DOMAINs 是一种将约束与创建伪用户定义类型的类型相关联的方法。那些原本会附加到 DOMAIN 的约束必须放在使用该类型的所有内容上,并在那里进行管理。

I opened a feature request SQL Standard DOMAIN functionality, MDEV-16377

我打开了一个功能请求 SQL Standard DOMAIN 功能,MDEV-16377

For more information, see

有关更多信息,请参阅

回答by jpfreire

There are 2 options if you really miss domains:

如果您真的错过了域,有两种选择:

  1. use MariaDB
  2. use Sets or Enums
  3. in MySqlWorkbench create User Defined Types

    They are just alias to already existing types, but if you're using MySqlWorkbench you can define new types and reuse in you're models.

  1. 使用MariaDB
  2. 使用集合或枚举
  3. 在 MySqlWorkbench 中创建用户定义的类型

    它们只是现有类型的别名,但如果您使用 MySqlWorkbench,您可以定义新类型并在模型中重用。