违反了Oracle生日专栏正则表达式约束

问题描述 投票:0回答:1

我希望数据库中的所有日期都采用以下yyyy-mm-dd日期格式。例如,“ 2020-05-28”。但这似乎不起作用,就像我想在将包含生日列的User表中插入一个日期时那样。

这是我的生日列约束:

birthday DATE NOT NULL CHECK (REGEXP_LIKE(birthday , '\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])*')),

[尝试插入时出现以下错误:'2020-05-28'或其他任何日期:

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.
sql oracle date oracle-sqldeveloper
1个回答
1
投票

您错误地解释了DATE数据类型的概念。可能是您混合了日期的显示格式

© www.soinside.com 2019 - 2024. All rights reserved.