0
如何檢查用戶是否超過13歲並使用Postgres檢查約束?如何用Postgres檢查約束來檢查用戶是否小於13歲?
我已經試過:
birthday::date < (birthday::date - '13 years'::interval)
,由於某種原因,它不會工作。
如何檢查用戶是否超過13歲並使用Postgres檢查約束?如何用Postgres檢查約束來檢查用戶是否小於13歲?
我已經試過:
birthday::date < (birthday::date - '13 years'::interval)
,由於某種原因,它不會工作。
您需要檢查針對當前日期:
birthday::date < (now() - '13 years'::interval)
您可以用當前的日期比較的生日是這樣的:
check (birthday + '13 years'::interval <= current_date)