早教吧 育儿知识 作业答案 考试题库 百科 知识分享

sql中,要求只能是8位字符,前两位是0,3~4位为数字,第五位为下划线,6~8位为字母,怎么写check约束条件!

题目详情
sql中,要求只能是8位字符,前两位是0,3~4位为数字,第五位为下划线,6~8位为字母,怎么写check约束条件!
▼优质解答
答案和解析
可以这样写alter table table1 add constraint chk_col check(len(col1)= 8 and left(col1,2) = '00' and substring(col1,3,1) like '[1-9]' and substring(col1,4,1) like '[1-9]' and substring(col1,5,1) = '_' a...