mysql - 创建表时未创建检查约束

标签 mysql constraints mysql-workbench

我使用以下查询创建了一个表。我创建了一个检查约束以确保用户插入电话号码或传真号码。

Create table Suppliers
(SupplierId int(10) not null auto_increment primary key,
CompanyName varchar(100) not null,
ContactName varchar(50) null,
ContactTitle varchar(50) null,
Address varchar(100) not null,
City varchar(50) not null,
Region varchar(50) not null,
PostalCode char(10) not null,
Country varchar(50) not null,
Phone varchar(15) null,
Fax varchar(15) null,
HomePage varchar(150) null,
constraint c_phone_fax check(Phone is not null or fax is not null)
);

但是,检查约束并未创建。有解决办法吗?

最佳答案

命令中表名的“s”大写:

alter table Suppliers drop constraint c_phone_fax

了解有关 MySQL 的更多信息 identifier case sensitivity .

关于mysql - 创建表时未创建检查约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48709339/

相关文章:

php - 使用 group by , count , group by , alias 执行高级 sql 查询

mysql - RELOAD 权限以刷新主机

oracle - oracle 有没有办法禁用/启用未命名约束?

ios - Scrollview 通过打破约束来工作

mysql 5.7如何将json数组提取到多列?

mysql - 如何在工作台中正确创建触发器?

php - 使用 json 在数据库上插入多个复选框

mysql - 数据的并集和交集

javascript - 从 db 调用返回对象

ios - 不同设备间的约束不一致