在 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
Create Domain in 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 DOMAIN
statement.
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. DOMAIN
s 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 目前都缺少此功能。DOMAIN
s 是一种将约束与创建伪用户定义类型的类型相关联的方法。那些原本会附加到 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:
如果您真的错过了域,有两种选择:
- use MariaDB
- use Sets or Enums
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.