我需要创建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.
QUERY:
CREATE DOMAIN d_price AS NUMERIC(9, 2) NOT NULL
CONSTRAINT Product_price_can_contain_only_double_precision_value
CHECK(VALUE ~*'^(([[:digit:]])+\.([[:digit:]]){2})$');
在使用字符串运算符之前,您需要将数值作为字符串,更改您的VALUE
to: CAST(VALUE AS TEXT)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)