title: Escape table name of attached database in SQLite?
body: <p>According to <a href="https://stackoverflow.com/questions/34884362/escape-table-name-in-sqlite">this answer</a>, you can escape a table name by putting double-quotes around it.  The <a href="https://www.sqlite.org/lang_keywords.html" rel="nofollow">SQLite documentation</a> further states that brackets and back-ticks are also possible for compatibility with other systems.</p>
  
  <p>This works on tables from the current database, however, when I try to do this on an attached database I get an error:</p>
  
  <pre><code>ATTACH db2 AS x; SELECT * FROM "x.table1";
  </code></pre>
  
  <p>yields the error:</p>
  
  <pre><code>no such table: x.table1
  </code></pre>
  
  <p>If I remove the "x." and run the query directly on database db2, it works.</p>
  
  <p>So how do I escape the table name when it is part of an attached database?</p>
  
  <p>I have tried the brackets and backticks, and I have also tried quoting only the table name and not the "x." part, e.g. all of the following:</p>
  
  <pre><code>ATTACH db2 AS x; SELECT * FROM `x.table1`;
  ATTACH db2 AS x; SELECT * FROM [x.table1];
  ATTACH db2 AS x; SELECT * FROM x."table1";
  ATTACH db2 AS x; SELECT * FROM x.`table1`;
  ATTACH db2 AS x; SELECT * FROM x.[table1];
  </code></pre>
  
  <p>None of these work.</p>