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

izb picture izb · Sep 17, 2008 · Viewed 1M times · Source

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?

Answer

Mark Janssen picture Mark Janssen · Sep 17, 2008

There are a few steps to see the tables in an SQLite database:

  1. List the tables in your database:

    .tables
    
  2. List how the table looks:

    .schema tablename
    
  3. Print the entire table:

    SELECT * FROM tablename;
    
  4. List all of the available SQLite prompt commands:

    .help