• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3910
  • Last Modified:

Disabling constraints in PostgreSQL?

We are converting a data import application from Oracle to PostgreSQL and are having some issues with functionality in Oracle that's missing in PostgreSQL.

In Oracle, we do the following simple bit to disable constraints: ALTER TABLE $table DISABLE CONSTRAINT $constraint
But in PostgreSQL, we can find no functional equivalent.

Ideas?

You can drop constraints and re-add them of course, but this is very inefficient.
0
kcorbinakc
Asked:
kcorbinakc
1 Solution
 
rstaveleyCommented:
As far as I can gather, you can disable constraint triggers only, which isn't much help to you. Wait for confirmation from a real PostgreSQL expert, though 8-)
0
 
earth man2Commented:
alter table x DROP CONSTRAINT yyyy;

alter table x ADD CONSTRAINT ...
0
 
kcorbinakcAuthor Commented:
We did get confirmation from our PostgreSQL provider that that is the only way to disable constraints.  Here's our syntax:
UPDATE pg_class SET reltriggers = 0 WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = ?)

Thanks for the input.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now