There are different command line options that can be used to tell dt where to find the databas (es) in different ways. But be aware that you should ensure to access the db only with one version of dt, I the database gets upgraded by newer versions and is then no longer usable by older versions.
I don’t know about Windows, but in Linux, you can use darktable --library <library file>, where <library file> is the location of library.db. I would think you’d have a similar option in Windows - you can view the available command-line options by typing darktable --help or darktable /? or darktable -h (depending on the style of the arguments - I’m not sure the way darktable is built for Windows).
Alright I can’t figure out how to actually get the help to display (none of the options I provided actually worked), but --library works (I think). Let me run a couple of things and confirm that.
[Edit] Cool. Yup, --library works as I described. But none of the ways to get help actually worked (at least when I tried them)…
And also the User Manual is extremely useful if you search for answers:
Ansewring your original question: database file is located in the configuration directory by default.
Also the command line works just on other platforms, just every output is redirected to the log file , even if you start darktable with --help parameter - That’s not very fortunate, and we might change that soon to be more user friendly.
And the --library command line switch is also working on Windows. I have created a separate “catalog” and I can start darktable by "C:\Program Files\darktable\bin\darktable.exe" --library C:\Users\[username]\AppData\Local\darktable\catalog1.db just fine either from the command line or creating a new shortcut at the Start Menu. If the database does not exist, darktable will create a new empty database (library) for you.
Please note that the database does not contain any previews of images. So the occupied space of library.db might be not that much*. lighttable previews in different sizes are stored in a harddisk cache. This cache seems to be on Windows in C:\Users\[Username]\AppData\Local\Microsoft\Windows\INetCache\darktable\mipmaps-*. This needs much more space if you have a lot of images.
There is a second database data.db, which stores presets, tags and styles. If you plan to work on different systems you maybe want to have same presets, tags and styles there as well.
*check this on my Debian/Linux home:
library.db contains 16k images and has a size of ~79 M.
mipmaps-* folder has a size of 871 M whereby most folders only contain 10k preview images. I don’t want to run darktable-generate-cache to update all previews as it would may take quite some time.
Not only is the actual library file relatively small, it also contains absolute paths to the images. So using the same library file on different computers only works when both have the same drive letter assigned to the external disk.
About showing output in cmd.exe, like --help, that is hardly possible on Windows due to the brain dead way Microsoft did things.
Starting darktable with "C:\Program Files\darktable\bin\darktable.exe" --library d:\tmp\dt.db at the windows command prompt (cmd.exe) creates a new database for me in d:\tmp\ as @peterbud already mentioned.
However, there is no logging output shown at the command prompt. So if you start darktable like: "C:\Program Files\darktable\bin\darktable.exe" --help to see some documentation about startoptions nothing happens. That’s what does not work, because the output is written to some log file on disk. E.g. to see the output/startoptions you have to look at this log file in the manual.
Multiple of this options can be used at the same time to invoke darktable. On windows you can create batch files or use shortcuts to do this. Inside this you can place commands like "C:\Program Files\darktable\bin\darktable.exe" --library [usbdrive letter]:\dt.db --cachedir [usbdrive letter]:\cache to start darktable with the two options --library and --cachedirat the same time.
This would use an existing or if it does not exist create a new database called dt.db and put all created previews and other stuff the needs caching in the directory cache. If it is only is only a onliner like this you can use an icon/shortcut and put this in the “field execute” or so (I have no English Windows version so this field might have a different name).
The batch file or the shortcut can resist on your external drive and can be started by double-click. The only problem is the drive letter as @houz mentioned. It needs to be the same every time. I don’t know if it possible to ensure that the same drive letter gets assigned with commands inside a batch file.