How do I list the constraints of a DOMAIN?
4
votes
3
answers
4393
views
Consider the following scenario:
CREATE DOMAIN dom_zipcode AS text;
ALTER DOMAIN dom_zipcode
ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
Now, if I want to drop that constraint with
ALTER DOMAIN
, The manual says :
ALTER DOMAIN name
DROP CONSTRAINT [ IF EXISTS ] constraint_name [ RESTRICT | CASCADE ]
But how can we find constraint_name
? \dD
only shows the constraint's definition (CHECK
statement).
\dD dom_zipcode ;
List of domains
Schema | Name | Type | Modifier | Check
--------+-------------+------+----------+--------------------------------
public | dom_zipcode | text | | CHECK (char_length(VALUE) = 5)
(1 row)
I can dump the schema using pg_dump
, but I believe there must exist a more elegant way to establish this using the psql
terminal.
Asked by Adam Matan
(12079 rep)
Nov 24, 2014, 05:22 PM
Last activity: Nov 21, 2022, 11:11 AM
Last activity: Nov 21, 2022, 11:11 AM