sqlite获取附加数据库的名称 [英] sqlite get name of attached databases

查看:476
本文介绍了sqlite获取附加数据库的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在SQLite中获取附加数据库的名称?



我试过调查:



SELECT name FROM sqlite_master



但似乎没有关于附加数据库的任何信息。



我用命令附加数据库:



ATTACH DATABASE< fileName> ; AS< DBName>



能够检索附加的FileNames或DBNames列表会很好。

$

解决方案

我尝试验证数据库是否正确连接,

您在寻找这个吗?

  PRAGMA database_list; 




PRAGMA database_list;

此编译指示像查询一样为每个数据库返回一行
附加到当前数据库连接。
第二列是主数据库文件的
main,数据库文件的temp,使用
存储TEMP对象,或其他
数据库文件的ATTACHed数据库的名称。第三列是数据库文件
本身的名称,如果数据库没有与
文件相关联,则为空字符串。



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.

解决方案

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.

这篇关于sqlite获取附加数据库的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆