域类型
最近更新时间: 2025-02-18 16:02:00
postgres=# CREATE DOMAIN xb AS TEXT CHECK
postgres-# (
postgres(# VALUE = '男'
postgres(# OR VALUE ='女'
postgres(# OR VALUE = ''
postgres(# );
CREATE DOMAIN
postgres=#
postgres=# CREATE OR REPLACE FUNCTION f4 (a_xb public.xb) RETURNS VOID AS
postgres-# $$
postgres$# BEGIN
postgres$# RAISE NOTICE 'a_xb = %',a_xb;
postgres$# END;
postgres$# $$
postgres-# LANGUAGE PLPGSQL;
CREATE FUNCTION
postgres=#
postgres=# SELECT * FROM f4('男');
NOTICE: a_xb = 男
f4
----
(1 行记录)
postgres=# SELECT * FROM f4('她');
ERROR: value for domain xb violates check constraint "xb_check"
postgres=#
#域类型输入参数值时会检查是否违反规则