title: How to add "on delete cascade" constraints?
body: <p>In PostgreSQL 8 is it possible to add <code>ON DELETE CASCADES</code> to the both foreign keys in the following table without dropping the latter?</p>
  
  <pre><code># \d scores
          Table "public.scores"
   Column  |         Type          | Modifiers
  ---------+-----------------------+-----------
   id      | character varying(32) |
   gid     | integer               |
   money   | integer               | not null
   quit    | boolean               |
   last_ip | inet                  |
  Foreign-key constraints:
     "scores_gid_fkey" FOREIGN KEY (gid) REFERENCES games(gid)
     "scores_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
  </code></pre>
  
  <p>Both referenced tables are below - here:</p>
  
  <pre><code># \d games
                                       Table "public.games"
    Column  |            Type             |                        Modifiers
  ----------+-----------------------------+----------------------------------------------------------
   gid      | integer                     | not null default nextval('games_gid_seq'::regclass)
   rounds   | integer                     | not null
   finished | timestamp without time zone | default now()
  Indexes:
      "games_pkey" PRIMARY KEY, btree (gid)
  Referenced by:
      TABLE "scores" CONSTRAINT "scores_gid_fkey" FOREIGN KEY (gid) REFERENCES games(gid)
  </code></pre>
  
  <p>And here:</p>
  
  <pre><code># \d users
                  Table "public.users"
     Column   |            Type             |   Modifiers
  ------------+-----------------------------+---------------
   id         | character varying(32)       | not null
   first_name | character varying(64)       |
   last_name  | character varying(64)       |
   female     | boolean                     |
   avatar     | character varying(128)      |
   city       | character varying(64)       |
   login      | timestamp without time zone | default now()
   last_ip    | inet                        |
   logout     | timestamp without time zone |
   vip        | timestamp without time zone |
   mail       | character varying(254)      |
  Indexes:
      "users_pkey" PRIMARY KEY, btree (id)
  Referenced by:
      TABLE "cards" CONSTRAINT "cards_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "catch" CONSTRAINT "catch_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "chat" CONSTRAINT "chat_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "game" CONSTRAINT "game_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "hand" CONSTRAINT "hand_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "luck" CONSTRAINT "luck_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "match" CONSTRAINT "match_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "misere" CONSTRAINT "misere_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "money" CONSTRAINT "money_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "pass" CONSTRAINT "pass_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "payment" CONSTRAINT "payment_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "rep" CONSTRAINT "rep_author_fkey" FOREIGN KEY (author) REFERENCES users(id)
      TABLE "rep" CONSTRAINT "rep_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "scores" CONSTRAINT "scores_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
      TABLE "status" CONSTRAINT "status_id_fkey" FOREIGN KEY (id) REFERENCES users(id)
  </code></pre>
  
  <p>And also I wonder if it makes sense to add 2 index'es to the former table?</p>
  
  <p><strong>UPDATE:</strong> Thank you, and also I've got the advice at the mailing list, that I could manage it in 1 statement and thus without explicitly starting a transaction:</p>
  
  <pre><code>ALTER TABLE public.scores
  DROP CONSTRAINT scores_gid_fkey,
  ADD CONSTRAINT scores_gid_fkey
     FOREIGN KEY (gid)
     REFERENCES games(gid)
     ON DELETE CASCADE;
  </code></pre>