Sqlite get the name of the attached database

How to get the name of an Attached Database in SQLite?

I tried to watch:

SELECT name FROM sqlite_master

but there is no information about attached databases.

I attach the databases using the command:

ATTACH DATABASE <fileName> AS <DBName>

It would be nice to get a list of attached FileNames or DBNames names.

I am trying to check if the database is bound correctly without knowing its schemas in advance.

+6
source share
2 answers

Are you looking for this?

 PRAGMA database_list; 

PRAGMA database_list;
This pragma acts as a query to return one row for each database attached to the current database connection. . The second column is "main" for the main database file, "temp" for the database file used to store TEMP objects or the ATTACHed database name for other database files. The third column is the name of the database file or an empty string if the database is not associated with a file.

+8
source

You can use the .database command.

+4
source

Source: https://habr.com/ru/post/951088/


All Articles