2
因此,我想檢查varchar2的格式是4個字母字符,然後是3個數字字符,例如AABB123或LMNO987Oracle:檢查varchar2中的字母和數字字符的約束條件
到目前爲止,我已經試過:
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.