【问题标题】:List tables of sqlite database in chrome extension?在 chrome 扩展中列出 sqlite 数据库的表?
【发布时间】:2021-01-26 23:37:37
【问题描述】:

我在 chrome 中使用 sqlite manager 扩展来使用 sqlite 数据库。我有一个 sqlite 数据库。这个扩展与 select delete alter 命令一起工作正常。但问题是我无法列出数据库表。有什么办法这样做?

【问题讨论】:

  • 您应该在发布问题之前搜索 SO。这个问题已经被问过并回答了很多次。两个例子:linklink

标签: android-sqlite


【解决方案1】:

您还没有说明您正在为 SO 成员运行什么扩展程序以便能够提供明确的帮助。

话虽如此,如果您说可以运行 SELECT 查询,请尝试:

SELECT * FROM sqlite_master WHERE type='table'

如果您想要只需要表名,而不需要架构详细信息,请尝试:

SELECT name  FROM sqlite_master WHERE type='table';

示例,包括创建表

/* Create 3  table */
CREATE TABLE Your_First_Table (Id integer PRIMARY KEY, Address text);
CREATE TABLE Your_Second_Table (Id integer PRIMARY KEY, Price text);
CREATE TABLE Your_third_Table (Id integer PRIMARY KEY, Stats text);

/*Get table names and schema details */
SELECT * FROM sqlite_master WHERE type='table';

/*Get table names */
SELECT name  FROM sqlite_master WHERE type='table';

第一个选择的输出:

table|Your_First_Table|Your_First_Table|2|CREATE TABLE Your_First_Table (Id integer PRIMARY KEY, Address text)
table|Your_Second_Table|Your_Second_Table|3|CREATE TABLE Your_Second_Table (Id integer PRIMARY KEY, Price text)
table|Your_third_Table|Your_third_Table|4|CREATE TABLE Your_third_Table (Id integer PRIMARY KEY, Stats text)

第二次选择的输出:

Your_First_Table
Your_Second_Table
Your_third_Table

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    • 2016-06-09
    • 2012-01-06
    • 2013-02-10
    • 2023-03-13
    • 2012-12-02
    相关资源
    最近更新 更多