title: Postgresql: Changing Action For Foreign Key Constraint
body: <p>I have a simple table like below. </p>
  
  <pre><code>create table chemlab.rule_header (
      id           serial PRIMARY KEY,
      name         varchar(50),
      grade        varchar(20),
      class_tag    varchar(20),    --tag added to sammple if match
      parent_id    int REFERENCES chemlab.rule_header(id) DEFAULT NULL,
      unique( grade, class_tag )
  )
  </code></pre>
  
  <p>But afterwards, I found that I need to add <code>ON DELETE</code> action, the default is <code>NO ACTION</code>. I couldn't figure out how to change the action.</p>
  
  <p>Now I have to <code>DROP</code> &amp; <code>ADD</code></p>
  
  <pre><code>ALTER table chemlab.rule_header 
      DROP CONSTRAINT rule_header_parent_id_fkey ;
  ALTER TABLE rule_header  
      ADD CONSTRAINT rule_header_parent_id_fkey 
      FOREIGN KEY (parent_id) REFERENCES chemlab.rule_header(id) ON DELETE RESTRICT;
  </code></pre>
  
  <p>So what is the correct syntax to alter an action on foreign key constraint ?</p>