How to disable foreign key and primary key constraint temporarily in PostgreSQL?
<p>I have one table that has two fields. The structure is like this:</p>

<pre><code>CREATE TABLE raw_links
(
  value_id bigint NOT NULL,
  raw_id integer NOT NULL,
  CONSTRAINT raw_links_pk PRIMARY KEY (raw_id, dp_id),
  CONSTRAINT raw_fk FOREIGN KEY (raw_id)
      REFERENCES raw_data (raw_data_id) MATCH SIMPLE
      ON UPDATE RESTRICT ON DELETE RESTRICT
)
</code></pre>

<p>I have to delete 5 million records from this table. For that I want to disable both constraints so that deletion will be faster. After deletion I want to create both constraints. </p>