How to list the tables in a SQLite database file that was opened with ATTACH?

前端 未结 17 2450
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 11:33

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

17条回答
  •  遥遥无期
    2020-11-22 12:07

    .da to see all databases - one called 'main'

    tables of this database can be seen by

    SELECT distinct tbl_name from sqlite_master order by 1;

    The attached databases need prefixes you chose with AS in the statement ATTACH e.g. aa (, bb, cc...) so:

    SELECT distinct tbl_name from aa.sqlite_master order by 1;

    Note that here you get the views as well. To exclude these add where type = 'table' before ' order'

提交回复
热议问题