Check constraints. - Mailing list pgsql-general

From Steve Rogerson
Subject Check constraints.
Date
Msg-id a6c7c35e-07d5-6a6c-0d60-5e3c0b439003@yewtc.demon.co.uk
Whole thread Raw
Responses Re: Check constraints.  (Paul Jungwirth <pj@illuminatedcomputing.com>)
List pgsql-general
williamI am trying to add/change a constraint programmatically, but not if it
already exists, and is the same as before.


I can so something like (may not be precise ...)

select check_clause from information_schema.check_constraints where
constraint_name = 'my-name'

but this returns that clause in a normalised format that is not compatible
with the text I am trying to compare, so I'm adding something like ...

alter table my_table  add check (my_type = any (array['GOOD' , 'BAD']))

but the check_clause from above looks like ...

(((my_type)::text = ANY (ARRAY['GOOD'::text, 'BAD'::text])))

Is there a way of getting the "normalised" version of constraint so decide if
I need to update the constraint if one already exists?

Steve




pgsql-general by date:

Previous
From: Blake McBride
Date:
Subject: Re: Must re-connect to see tables
Next
From: Ron
Date:
Subject: Re: Must re-connect to see tables