所以我想检查 varchar2 的格式是 4 个字母字符,然后是 3 个数字字符,例如 AABB123 或 LMNO987
到目前为止,我已经尝试过:
CONSTRAINT Code_Check check (REGEXP_LIKE(Code,'[^A-Z][^A-Z][^A-Z][^A-Z][0-9][0-9][0-9]'))
CONSTRAINT Check_Code check (Code LIKE '[^A-Z][^A-Z][^A-Z][^A-Z][0-9][0-9][0-9]'
CONSTRAINT Check_Code check (Code LIKE '[A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9]')
CONSTRAINT Check_Code check (Code regexp_LIKE '[A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9]')
CONSTRAINT Check_Code check (Code LIKE '[^A-Z]{4}[0-9]{3}')
但只是得到错误:
insert into Table1 (Code) values ('HELP555')
Error report:
SQL Error: ORA-02290: check constraint (BOB.TABLE1_CHECK_CODE) violated
02290. 00000 - "check constraint (%s.%s) violated"
*Cause: The values being inserted do not satisfy the named check
*Action: do not insert values that violate the constraint.