[英]Oracle SQL Developer regex expression error
In the script file, I inserted the following code.在脚本文件中,我插入了以下代码。
drop table Test;
create table Test(
name char(2) unique not null,
constraint name_c check(
regexp_like(name, '^[A-Z]{1,2}$', 'c')
)
);
insert into Test values ('B');
The developer never budge.开发商从不让步。 It keeps on saying violating the name_c constraint and I don't understand why.
它一直说违反 name_c 约束,我不明白为什么。 The regular expression looks fine for me.
正则表达式对我来说看起来不错。
Some variants, however, succeeded, for example, dropping the dollar sign然而,一些变体成功了,例如,去掉了美元符号
drop table Test;
create table Test(
name char(2) unique not null,
constraint name_c check(
regexp_like(name, '^[A-Z]{1,2}', 'c')
)
);
insert into Test values ('B');
And I don't understand either.而且我也不明白。
Why?为什么?
Edit: This is the problem: logically the regex is right.编辑:这就是问题所在:从逻辑上讲,正则表达式是正确的。 But somehow Oracle SQL Developer doesn't budge.
但不知何故,Oracle SQL Developer 并没有让步。
如果您以 1 或 2 个大写字母开头,并且接下来的内容无关紧要,您应该这样做:
^[A-Z]{1,2}.*
.* mean 1 or more character exept \n (nex line)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.