title: SQL ALTER TABLE ON DELETE CASCADE
body: <p>I have the following tables: </p>
  
  <pre><code>CREATE TABLE BOOK_AUTHORS
  (Book_id CHAR(20) NOT NULL,
  AuthorName VARCHAR(30) NOT NULL,
  PRIMARY KEY (Book_id, AuthorName),
  FOREIGN KEY (Book_id) REFERENCES BOOK (Book_id));
  
  CREATE TABLE BOOK_COPIES
  (Book_id CHAR(20) NOT NULL,
  Branch_id CHAR(20) NOT NULL,
  No_of_copies NUMBER,
  PRIMARY KEY (Book_id, Branch_id),
  FOREIGN KEY (Book_id) REFERENCES BOOK (Book_id),
  FOREIGN KEY (Branch_id) REFERENCES LIBRARY_BRANCH (Branch_id));
  </code></pre>
  
  <p>I want to add <code>ON DELETE CASCADE</code> constraints to the both of them:</p>
  
  <p>The first time I tried it said it worked. That file looks like:</p>
  
  <pre><code>ALTER TABLE "BOOK_AUTHORS"
  ADD CONSTRAINT "fk_test"
  FOREIGN KEY ("Book_id")
  REFERENCES "BOOK" ("Book_id")
  ON DELETE CASCADE;
  </code></pre>
  
  <p>Then I went through and made two separate tables for the two foreign keys in the second table:</p>
  
  <pre><code>ALTER TABLE "BOOK_COPIES"
  ADD CONSTRAINT "fk_test1"
  FOREIGN KEY ("Book_id")
  REFERENCES "BOOK" ("Book_id")
  ON DELETE CASCADE;
  
  ALTER TABLE "BOOK_COPIES"
  ADD CONSTRAINT "fk_test2"
  FOREIGN KEY ("Branch_id")
  REFERENCES "LIBRARY_BRANCH" ("Branch_id")
  ON DELETE CASCADE;
  </code></pre>
  
  <p>However, upon doing so I got the errors </p>
  
  <blockquote>
    <p>"Book_id" invalid identifier</p>
  </blockquote>
  
  <p>and then</p>
  
  <blockquote>
    <p>"Branch_id" invalid identifier</p>
  </blockquote>
  
  <p>I don't know what I did wrong. I then went back and did the first alter table again (the one that I originally thought worked) and it gave me the same error message (<code>"Book_id" invalid identifier</code>). Can someone help me add these constraints? I also have five other tables to add these constraints to.</p>