How do I get the name of the Attached databases in SQLite?
I've tried looking into:
SELECT name FROM sqlite_master
but there doesn't seem to be any information there about the attached databases.
I attach the databases with the command:
ATTACH DATABASE <fileName> AS <DBName>
It would be nice to be able to retrieve a list of the FileNames or DBNames attached.
I'm trying to verify if a database was correctly attached without knowing its schema beforehand.
You can use . database command. Aren't these dot commands like . database , .
To show all databases in the current connection, you use the . databases command. The . databases command displays at least one database with the name: main .
The ATTACH DATABASE statement adds another database file to the current database connection. Database files that were previously attached can be removed using the DETACH DATABASE command.
Are you looking for this?
PRAGMA database_list;
PRAGMA database_list;
This pragma works like a query to return one row for each database attached to the current database connection. The second column is the "main" for the main database file, "temp" for the database file used to store TEMP objects, or the name of the ATTACHed database for other database files. The third column is the name of the database file itself, or an empty string if the database is not associated with a file.
You can use .database
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With