Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 889
izb Avatar asked Sep 17 '08 12:09

izb


People also ask

How do I get a list of tables in SQLite database?

If you are running the sqlite3 command-line access program you can type ". tables" to get a list of all tables. Or you can type ". schema" to see the complete database schema including all tables and indices.

How do I view the contents of a SQLite file?

Click the File menu near the top right corner of the SQLite Database Browser window that opens and select Open Database. Browse to the location of the SQLite file you wish to read and click the file. Click the "Open" button. The SQLite file contents will display.


1 Answers

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 
like image 70
Mark Janssen Avatar answered Sep 20 '22 10:09

Mark Janssen