[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3846
  • 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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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