SQLite Forum

attach-stmt syntax documentation ?
Login

attach-stmt syntax documentation ?

(1) By Bob C (rchapman) on 2020-06-07 21:09:58

In the documentation for <b>attach-stmt</b> (<i>syntax/attach-stmt.html</i>) and <nobr><b>ATTACH DATABASE</b></nobr> (<i>lang_attach.html</i>)  the statement is shown as:
<nobr><b>ATTACH DATABASE <i>expr</i> AS schema-name</b></nobr>
with a link to the documentation for <b><i>expr</i></b> (<i>syntax/expr.html</i>).
It may be an artifact of my ignorance but I don't understand how the syntax diagram for <b><i>expr</i></b> describes a path to the database file that is being attached.

(2) By Stephan Beal (stephan) on 2020-06-07 21:36:49 in reply to 1 [link]

> I don't understand how the syntax diagram for expr describes a path to the database file that is being attached. 

The expression may be arbitrarily complex, so long as it resolves to a value suitable for use as a file name. As a trivial example:


```
attach 'a' || '.db' as foo
```

(3.1) By Bob C (rchapman) on 2020-06-08 13:41:17 edited from 3.0 in reply to 2 [link]

Aha!

  . . . so long as it resolves to a value suitable for use as a file name.

That stipulation dispels my confusion. I guess it should have been obvious? Thanks for the explanation. Sorry for the noise! ;)