我需要domain在 PostgreSQL 中创建一个价格。价格必须是NUMERIC(9,2)9 为精度,2 为小数位数。尝试创建域时获取:
ERROR: operator does not exist: numeric ~* unknown
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
询问:
CREATE DOMAIN d_price AS NUMERIC(9, 2) NOT NULL
CONSTRAINT Product_price_can_contain_only_double_precision_value
CHECK(VALUE ~*'^(([[:digit:]])+\.([[:digit:]]){2})$');
Run Code Online (Sandbox Code Playgroud)