Oracle使用regexp_like进行约束

时间:2016-03-27 19:19:47

标签: regex oracle constraints

我需要在表格中创建约束。我需要一个只有字母(A ... Z)和括号,&符号,管道和空格('(',')','&','|','')的字段。

我尝试了以下但不起作用:

ALTER TABLE SCPOMGR.U_CLUSTER ADD 
CONSTRAINT U_CLUSTER_CHK_EQUATION
CHECK (regexp_like (equation, '[A-z]|[chr(124)]|[chr(38)]|[chr(40)]|[chr(41)]|[chr(32)]'))
ENABLE
VALIDATE

2 个答案:

答案 0 :(得分:0)

尝试以下正则表达式:^[A-Za-z()&| ).]*$

有关详情:https://regex101.com/r/uH1yL9/1

[A-z][A-Za-z]

不同

答案 1 :(得分:0)

未经测试您可以尝试一下

let array = [1, 2, 3, 4]
let slice = array[1 ..< 3]

print(slice) // [2, 3]
print(slice.startIndex) // 1
print(slice.endIndex)   // 3

print(slice[1])         // 2 (the first element of the slice)
print(slice[0])         // fatal error: Index out of bounds