8

Sometimes I use SQLite database but it's quite common that I don't know anything about its structure.

I need to retrieve all metadata like the name of a database or table, the data type of a column, primary keys, foreign keys, or access privileges.

MSSQL has information_schema for this purpose but is there something similar for SQLite?

asked Apr 5, 2017 at 20:29
1
  • 2
    Check SQLite Pragmas, and SELECT * FROM sqlite_master ; Commented Apr 5, 2017 at 20:52

1 Answer 1

9

The equivalent of, for instance, MySQL describe t1; is

PRAGMA TABLE_INFO(t1);

and

SELECT * FROM sqlite_master WHERE tbl_name = 't1';

is also useful. Most of the time, however, I simply use

.schema t1 

which outputs the SQL definition of the table or view, even with the original comments (exactly the same as SELECT sql FROM sqlite_master WHERE..., with less typing. .sch works too.)

answered Apr 5, 2017 at 21:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.