When working on craur's pdo functionalities, I wanted to know all tables in a specific pdo database.
If you are using mysql, you can use
SHOW TABLES;
to retrieve a list of all available tables in the current database.
But this does not work in postgres nor in sqlite.
In sqlite you can retrieve the table names with the following query:
SELECT name FROM sqlite_master WHERE type = 'table'
If you want to find all tables in a way, which works in postgresql and mysql, you can use the following query:
SELECT DISTINCT table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'yourdatabasename'
The information_schema
table has a lot more information (e.g. the column definitions etc.)