How to View a Table’s Structure – Sqlite3

Just a quick post on how to view a table’s structure in SQLite3. Again, not something I’ve broken yet – more something I seem to keep forgetting. Simply start Sqlite:
chris@chris-VirtualBox:~/site$ sqlite3 -line db/development.sqlite3
SQLite version 3.7.4
Enter “.help” for instructions
Enter SQL statements terminated with a “;”

Then enter the following: – substituting orders for whatever your table name happens to be:
sqlite> pragma table_info(orders);
cid = 0
name = id
type = INTEGER
notnull = 1
dflt_value =
pk = 1

cid = 1
name = user_id
type = integer
notnull = 0
dflt_value =
pk = 0

cid = 3
name = created_at
type = datetime
notnull = 0
dflt_value =
pk = 0

Good Luck!
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s