Search code examples
android-sqlite

List tables of sqlite database in chrome extension?


I'm using sqlite manager extension in chrome to use sqlite database.I have a sqlite database.This extension works properly with select delete alter commands.but the problem is i can't list tables of database.is there any way to do this?.


Solution

  • You have not said what extension you are running for SO members to be able to offer definitive help.

    Having said that, if you say can run SELECT queries, try:

    SELECT * FROM sqlite_master WHERE type='table'
    

    If you want only the table name, without schema details, try:

    SELECT name  FROM sqlite_master WHERE type='table';
    

    Examples, including table creation

    /* 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';
    

    Output from 1st Select:

    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)
    

    Output from 2nd Select:

    Your_First_Table
    Your_Second_Table
    Your_third_Table