请哪位帮我写写这个检查约束。谢了。 请哪位帮我写写这个检查约束。谢了。我自己试着写了很久都不是很好。。类型,char(6)可以为null可以为 6个空格可以为[0-1][0-9][0-9][:][0-5][0-9]谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 create table tb(col char(6))goalter table tb add constraint chk_tb check(col=' ' or col like '[0-1][0-9][0-9][:][0-5][0-9]')go if object_id('[tb]') is not null drop table [tb] go create table [tb]([col] char(6),check(col like '[0-1][0-9][0-9][:][0-5][0-9]' or col is null or col like '[ ][ ][ ][ ][ ][ ]'))/*可以为null 可以为 6个空格 可以为[0-1][0-9][0-9][:][0-5][0-9] */insert tb select '123456'/*消息 547,级别 16,状态 0,第 1 行INSERT 语句与 CHECK 约束"CK__tb__col__110B679F"冲突。该冲突发生于数据库"test1",表"dbo.tb", column 'col'。语句已终止。*/insert tb select ' '/*(1 行受影响)*/insert tb select NULL/*(1 行受影响)*/ ALTER table LI add constraint c_LI CHECK(COL1 LIKE '[0-1][0-9][0-9][:][0-5][0-9]') SQL Server pubs数据库:查询雇员最多的职位 telnet可以连接,但是企业管理器连接不上去!! 有朋友让我帮忙写一个进销存程序,请教数据库的设计问题 诡异的 provider: 命名管道提供程序, error:40 - 无法打开到 SQL Server 的连接 《求助SQL交叉表的查询语句》 高难度查询,求解,99分! 请教:该如何更新这个表。 求Transact_SQL写法(在线)???(如何判断字段在表中存在...) 如果将sql2000数据库中的 email 字段内容 导入txt文件 格式如下: 导入问题 一个简单的设计问题 多条件A表减B表
go
alter table tb
add constraint chk_tb check(col=' ' or col like '[0-1][0-9][0-9][:][0-5][0-9]')
go
go
create table [tb]([col] char(6),check(col like '[0-1][0-9][0-9][:][0-5][0-9]' or col is null or col like '[ ][ ][ ][ ][ ][ ]'))/*
可以为null
可以为 6个空格
可以为[0-1][0-9][0-9][:][0-5][0-9] */insert tb select '123456'
/*
消息 547,级别 16,状态 0,第 1 行
INSERT 语句与 CHECK 约束"CK__tb__col__110B679F"冲突。该冲突发生于数据库"test1",表"dbo.tb", column 'col'。
语句已终止。
*/
insert tb select ' '
/*
(1 行受影响)
*/
insert tb select NULL
/*
(1 行受影响)
*/