What SQL may be used to list the tables, and also the rows within individuals tables, inside a SQLite database file once i have ATTACHed it around the sqlite3 command line tool?

It seems you have to feel the *sqlite_master* table, such as this:

Choose * FROM dbname.sqlite_master WHERE type='table'

After which by hand undergo each table having a Choose or similar to check out the rows.

The .DUMP and .SCHEMA instructions does not seem to begin to see the database whatsoever.

.tables

Can place the tables inside your database

.schema tablename

can place the way the table looks

along with a

Choose * from tablename

prints the whole table..

To exhibit all tables, use

Choose title FROM sqlite_master WHERE type = "table"

To exhibit all rows, I suppose you are able to iterate through all tables and merely perform a Choose * on each one of these. But perhaps a DUMP is exactly what you are after?

There's an order readily available for this around the sqlite command line.

.tables ?PATTERN?      List names of tables matching a LIKE pattern

Which converts towards the following SQL

Choose title FROM sqlite_master

WHERE key in ('table','view') AND title Nothing Like 'sqlite_%'

UNION ALL

Choose title FROM sqlite_temp_master

WHERE key in ('table','view')

ORDER BY 1

The .tables, and .schema "assistant" functions don't consider ATTACHed databases: they simply query the SQLITE_MASTER table for that "primary" database. Consequently, should you used

ATTACH some_file.db AS my_db

then you must do

Choose title FROM my_db.sqlite_master WHERE type='table'

Observe that temporary tables do not show track of .tables either: you need to list sqlite_temp_master for your:

Choose title FROM sqlite_temp_master WHERE type='table'

Try PRAGMA table_info(table-title): http://world wide web.sqlite.org/pragma.html#schema

The simplest method of doing this really is to spread out the database directly and employ the .dump command, instead of affixing it after invoking the sqlite3 spend tool

So... (assume your o/s command line prompt is $) rather than

$sqlite3

sqlite3> ATTACH database.sqlite as "attached"

out of your o/s command line, open the database directly

$sqlite3 database.sqlite

sqlite3> .dump

To list out the tables you may also do:

Choose title FROM sqlite_master WHERE type='table'

The ".schema" commando can place available tables as well as their rows, by showing the statement accustomed to create stated tables:


sqlite> create table_a (id int, a int, b int)

sqlite> .schema table_a

CREATE TABLE table_a (id int, a int, b int)

choose * from table table_title

Use .assistance to look for available instructions.

.table

This could show all tables beneath your current database.