sql-server - INSERT 语句与 CHECK 约束冲突(插入表问题)
问题描述
我正在处理数据库并为电话号码设置了检查约束。但是我在输入电话号码时遇到问题。
我尝试插入不带“”的电话号码,但仍然无效
create table CustomerDetails.Clients (
Client_ID int primary key identity (100, 10),
Company_Name varchar (35) not null,
Contact_Person char (35) not null,
City char (20) not null,
State char (20) not null,
Zip int not null,
Country char (45) not null,
Phone varchar (30) not null
CONSTRAINT chk_Phone CHECK
(Phone like '[0-9][0-9]-[0-9] [0-9][0-9]-[0-9] [0-9][0-9][0-9]-[0-9][0-9] [0-9]-[0-9] [0-9] [0-9]')
);
insert into CustomerDetails.Clients values ('Bazz Beauty Home', 'Felix Jhean',
'Ohio', 'Cincinnati', '350056', 'United States', '34-453-5458-698-978')
解决方案
34-453-5458-698-978
is 19 characters long, but your phone number column is varchar(18)
. You should increase the length of your Phone column.
推荐阅读
- c# - 在 Access-Control-Allow-Origin 标头中找不到 Origin [domain]。ASP .net 核心 API mvc
- javascript - 函数内部的变量在 jquery 中不可用,但在没有函数的情况下可用
- c# - How to copy listview data to other form's listview c#
- docker - 在没有“权限”的 K8s Pod 中启动新的 K8s Pod
- javascript - 如何检查请求是否使用 JavaScript (Mocha) 发送
- java - 建议不会跨模块编织到类文件中
- android - recyclerview 中的可扩展项目未在最后一个项目中扩展
- sql - 仅插入一条记录,它在没有任何数据的数据库中不存在
- javascript - 渲染 Vuex 时出错
- node.js - npm 安装后 100% 的 CPU 使用率