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

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

问题描述

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

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"函数不会查看已连接的数据库:它们只是在SQLITE_MASTER表中查询"main "数据库.因此,如果您使用

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天全站免登陆