List Tables in Any Database

junho 23, 2023 | por dbsnoop

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 <database's name>];

or


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


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 <schema's name>


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 = <filter>];


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 <database>

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.

Compartilhar:

Leia mais

pt_BR