14

I can't seem to find documentation (that I understand) on how to list all tables in a database. I've tried the following:

SELECT * FROM .table;
SELECT * FROM .tab;
SELECT * FROM .db;
SELECT * FROM world.db;

None of them worked. I'm just learning SQL, so forgive my ignorance. :0)

2 Answers 2

24

Try this:

SELECT * FROM sqlite_master WHERE type='table'
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I was just about to edit my post to add SELECT * FROM world.sqlite_master WHERE type='table'; to the queries I tried. looks like I had too much info in mine.
Note that sqlite_master was renamed to sqlite_schema, though the old name remains working for backwards compatibility.
10

If you are in interactive mode, you can use this:

.tables

Another method with extra information:

.schema

https://sqlite.org/cli.html#querying_the_database_schema

Comments

Your Answer

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.