Question

On a db oracle we have system tables created by oracle and our tables created by us. I want to see our tables on postgresql I use

\d

on mysql

show tables;

And on oracle for a similar output?

Was it helpful?

Solution

To list all tables owned by the current user, type:

select tablespace_name, table_name from user_tables;

To list all tables in a database:

select tablespace_name, table_name from dba_tables;

To list all tables accessible to the current user, type:

select tablespace_name, table_name from all_tables;

You can find more info about views all_tables, user_tables, and dba_tables in Oracle Documentation. To describe a table, type:

desc <table_name>

SHOW TABLES displays all of the tables in the current schema.

If IN schemaName is specified, the tables in the given schema are displayed.

show tables;

OTHER TIPS

You could do this:

select owner,
       table_name
from dba_tables
where owner not in ('SYS',
                    'SYSTEM')
order by owner,
         table_name
;

But there is no guarantee someone hasn't (foolishly) created tables under SYS or SYSTEM schemas. That aside, there are several other schemas that are created with the database, and the list may vary with the installation/creation options chosen.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top