How do I query an Oracle database to display the names of all tables in it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is assuming that you have access to the
DBA_TABLESdata dictionary view. If you do not have those privileges but need them, you can request that the DBA explicitly grants you privileges on that table, or, that the DBA grants you theSELECT ANY DICTIONARYprivilege or theSELECT_CATALOG_ROLErole (either of which would allow you to query any data dictionary table). Of course, you may want to exclude certain schemas likeSYSandSYSTEMwhich have large numbers of Oracle tables that you probably don’t care about.Alternatively, if you do not have access to
DBA_TABLES, you can see all the tables that your account has access to through theALL_TABLESview:Although, that may be a subset of the tables available in the database (
ALL_TABLESshows you the information for all the tables that your user has been granted access to).If you are only concerned with the tables that you own, not those that you have access to, you could use
USER_TABLES:Since
USER_TABLESonly has information about the tables that you own, it does not have anOWNERcolumn – the owner, by definition, is you.Oracle also has a number of legacy data dictionary views–
TAB,DICT,TABS, andCATfor example– that could be used. In general, I would not suggest using these legacy views unless you absolutely need to backport your scripts to Oracle 6. Oracle has not changed these views in a long time so they often have problems with newer types of objects. For example, theTABandCATviews both show information about tables that are in the user’s recycle bin while the[DBA|ALL|USER]_TABLESviews all filter those out.CATalso shows information about materialized view logs with aTABLE_TYPEof ‘TABLE’ which is unlikely to be what you really want.DICTcombines tables and synonyms and doesn’t tell you who owns the object.