Sql 如何在Oracle中创建自定义检查

Sql 如何在Oracle中创建自定义检查,sql,regex,oracle,check-constraints,Sql,Regex,Oracle,Check Constraints,我必须为我的项目创建一个数据库,我目前正在努力创建自定义检查。 我想对学生个人身份号码(pesel)创建自定义检查,我想它的长度为11个字符,并且只有0-9之间的数字,我还想创建邮政编码检查,使其具有以下格式:“11-111”。 我在Oracle SQL developer工作 这些是我试图添加的检查,但我在这两个检查中都有相同的错误 ALTER TABLE Address ADD CHECK (Zip_Code ~ '^[0-9]{2}-[0-9]{3}'); ALTER TABLE Stu

我必须为我的项目创建一个数据库,我目前正在努力创建自定义检查。 我想对学生个人身份号码(pesel)创建自定义检查,我想它的长度为11个字符,并且只有0-9之间的数字,我还想创建邮政编码检查,使其具有以下格式:“11-111”。 我在Oracle SQL developer工作

这些是我试图添加的检查,但我在这两个检查中都有相同的错误

ALTER TABLE Address ADD CHECK (Zip_Code ~ '^[0-9]{2}-[0-9]{3}');

ALTER TABLE Students ADD CHECK (pesel ~ '^[0-9]*$');
这是我得到的错误:

Error starting at line : 1 in command -

ALTER TABLE Adress ADD CHECK (Zip_Code ~ '^[0-9]{2}-[0-9]{3}')

Error report -

00911. 00000 -  "invalid character"

*Cause:  
  The identifier name started with an ASCII character other than a
           letter or a number. After the first character of the identifier
           name, ASCII characters are allowed including "$", "#" and "_".
           Identifiers enclosed in double quotation marks may contain any
           character other than a double quotation. Alternate quotation
           marks (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters. For all other contexts, consult the SQL Language
           Reference Manual.

*Action:  
 Check the Oracle identifier naming convention. If you are
           attempting to provide a password in the IDENTIFIED BY clause of
           a CREATE USER or ALTER USER statement, then it is recommended to
           always enclose the password in double quotation marks because
           characters other than the double quotation are then allowed.

如果模式是正确的,您将使用正则表达式,例如

ALTER TABLE Address ADD CHECK (regexp_like(address, '^[0-9]{2}-[0-9]{3}'));
Oracle像一样使用
regexp\u,而不是
~
——您在手册的哪里发现
~
用于正则表达式?