如何列出使用 ATTACH 打开的 SQLite 数据库文件中的表? [英] How can I list the tables in a SQLite database file that was opened with ATTACH?

查看:27
本文介绍了如何列出使用 ATTACH 打开的 SQLite 数据库文件中的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么 SQL 可用于列出 SQLite 数据库文件中的表以及这些表中的行 - 一旦我使用 SQLite 3 命令行工具上的 ATTACH 命令附加了它?

What SQL can be used to list the tables, and the rows within those tables in an SQLite database file - once I have attached it with the ATTACH command on the SQLite 3 command line tool?

推荐答案

.tables.schema helper"函数不会查看 ATTACHed 数据库:他们只是查询主"数据库的 SQLITE_MASTER 表.因此,如果你使用

The .tables, and .schema "helper" functions don't look into ATTACHed databases: they just query the SQLITE_MASTER table for the "main" database. Consequently, if you used

ATTACH some_file.db AS my_db;

那么你需要做的

SELECT name FROM my_db.sqlite_master WHERE type='table';

请注意,临时表也不会与 .tables 一起显示:您必须为此列出 sqlite_temp_master:

Note that temporary tables don't show up with .tables either: you have to list sqlite_temp_master for that:

SELECT name FROM sqlite_temp_master WHERE type='table';

这篇关于如何列出使用 ATTACH 打开的 SQLite 数据库文件中的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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