创建表时是否可以使用全局变量?
我正在尝试创建一个表:
CREATE TABLE `Appointment_Status` (
`StatusID` VARCHAR(36) NOT NULL UNIQUE,
`AppointmentFulfilled` ENUM('fulfilled', 'noshow', 'cancelled')
);
是否可以在最高级别上定义这样的全局变量:
SET GLOBAL AppointmentFulfilled = ENUM('fulfilled', 'noshow', 'cancelled');
创建表时使用它?像这样:
CREATE TABLE `Appointment_Status` (
`StatusID` VARCHAR(36) NOT NULL UNIQUE,
`AppointmentFulfilled` AppointmentFulfilled
);
I'm trying to create a table:
CREATE TABLE `Appointment_Status` (
`StatusID` VARCHAR(36) NOT NULL UNIQUE,
`AppointmentFulfilled` ENUM('fulfilled', 'noshow', 'cancelled')
);
Is it possible to define a global variable like this on the very top level:
SET GLOBAL AppointmentFulfilled = ENUM('fulfilled', 'noshow', 'cancelled');
And use it when creating a table? Like this:
CREATE TABLE `Appointment_Status` (
`StatusID` VARCHAR(36) NOT NULL UNIQUE,
`AppointmentFulfilled` AppointmentFulfilled
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MySQL不支持用户定义的类型(UDTS),但是您可以将检查约束放在
timperment_status
表上,该表将在此处瞄准您的效果。例如,https://www.w3resource.com/ mysql/create-table-advance/constraint.php#cons3
MySQL does not support User Defined Types (UDTs), however you can put a CHECK constraint onto your
Appointment_Status
table that will have the effect you are aiming for here. E.g.Full details at https://www.w3resource.com/mysql/creating-table-advance/constraint.php#cons3