title: HSQLDB. Error with adding a foreign key after creating the table.
body: <p>I need to add a foreign key in the tables after creation their.</p>
  
  <p>I use this request: <code>ALTER TABLE lessons ADD FOREIGN KEY (id_teacher) REFERENCES teachers (id);</code></p>
  
  <p>After it executed, I get error: <code>java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: PUBLIC.LESSONS</code></p>
  
  <p>How can I fix it?</p>
  
  <p>Sending a query: <code>Statement statement = connection.createStatement();
          statement.execute(request);</code></p>
  
  <p>The entire query:
  </p>
  
  <pre><code>CREATE TABLE lessons (
  id int IDENTITY, 
  lesson_name varchar(50) NOT NULL, 
  id_teacher int NOT NULL,
  id_group int NOT NULL
  );
  
  CREATE TABLE teachers (
  id int IDENTITY,
  teacher_name varchar(50) NOT NULL,
  id_lesson int NOT NULL,
  id_group int NOT NULL
  );
  
  
  CREATE TABLE groups (
  id int IDENTITY,
  group_name varchar(50) NOT NULL,
  id_lesson int NOT NULL,
  id_curator int NOT NULL
  );
  
  ALTER TABLE lessons 
  ADD FOREIGN KEY (id_teacher) REFERENCES teachers (id) 
  ADD FOREIGN KEY (id_group) REFERENCES groups (id);
  
  ALTER TABLE teachers 
  ADD FOREIGN KEY (id_lesson) REFERENCES lessons (id) 
  ADD FOREIGN KEY (id_group) REFERENCES groups (id);
  
  ALTER TABLE groups 
  ADD FOREIGN KEY (id_lesson) REFERENCES lessons (id) 
  ADD FOREIGN KEY (id_curator) REFERENCES teachers (id);
  </code></pre>