List Tables in Any Database

July 6, 2023 | by dbsnoop

table listing in databases
how to list tables in your databases

How to list tables in the most used databases:

Oracle

To list all tables:

SELECT tablespace_name, table_name, owner FROM dba_tables;

To list all tables for the current user:

SELECT tablespace_name, table_name, owner FROM user_tables;

To list all tables the user has access to (whether the user is the owner or not):

SELECT tablespace_name, table_name, owner FROM all_tables;

MySQL

To list all tables:


SHOW TABLES [from <nome do database>];

or

SELECT table_schema, table_name, table_type FROM information_schema.tables [WHERE table_schema = <filtro>];

DB2

To list all tables:


db2 list tables for all

To list all tables for a given schema (schema’s name):


db2 list tables for schema <nome do schema>

SQL Server

To list all tables from all catalogs and schemas:


SELECT table_catalog, table_schema, table_name, table_typeFROM information_schema.tables  [WHERE table_catalog = <filtro>];

PostgreSQL (PG)

To list all tables:


\l or \dt

To list only the tables of the current database/schema:

\dt

MongoDB

MongoDB doesn’t have such things as tables. For those new in NoSQL, the object similar to tables are collections. So, to list all collections:

use <banco_de_dados>
show collections;

Maybe you would like to list all database in your MongoDB instance:

show dbs;

 

If you found this post useful, try out our database monitoring platform. It is entirely SaaS, secure, and cost-free forever. For more information, go here.

Give it a try for 14 days, no burocracy, no credit card

Learn more about Flightdeck!

databases databases

 
 
Share

Read more