Amar Singh
Amar Singh

Reputation: 13

Explore Oracle Database using SQL Developer

I'm in a project which requires me to query a database and generate ad-hoc reports with the columns specified by the user.

When I was working with DB2 on a different database with little documentation about the tables and columns available I could also use queries like the ones mentioned below to get what I was looking for

select * from syscat.procedures where procschema like 'ABCD' and text like '%your text%';
select * from syscat.columns where tabschema like 'ABCD' and colname like '%yourtext%';

In my new project, I'll be working with Oracle on a different database and this time I have no document which could tell me what information is in which column. Also, there is nobody in this project who could assist me with this.

Are there any such queries in Oracle like the ones I mentioned above from DB2 which could help me find what I need from the database?

Upvotes: 1

Views: 168

Answers (1)

thatjeffsmith
thatjeffsmith

Reputation: 22412

Welcome to Oracle!

Since you tagged SQL Developer, I'll show you how to do what you want to do there.

But first, views of interest to you:

  • ALL_TAB_COLUMNS
  • ALL_SOURCE

But, to use the GUI to search these views...

You can use the reports to learn our data dictionary.

enter image description here

A couple of different ways you could go, but here's an example, the Columns report.

enter image description here

As you're browsing around, you can observe the statements panel in the Log section. So you can see that we're querying

enter image description here

By looking at the query that runs for this report, you can see we're hitting the following data dictionary views:

snippet of the SQL:

      owner         sdev_link_owner,
       table_name    sdev_link_name,
       'TABLE' sdev_link_type
   from sys.dba_tab_columns
  where (:owner is null
     or instr(
     owner,

DBA_TAB_COLUMNS (Oracle Docs)

You'll note that there is both a DBA_TAB_COLUMNS and a ALL_TAB_COLUMNS. Only a 'superuser' can query the DBA_ views. Anyone can look into ALL_ views, but you'll only be able to see the objects your database privileges grant access to.

There are also USER_ views - they show just the things you need to know about the schema for the user you are logged in as. In Oracle, schema and user are basically the same thing.

So, try the reports, answer your questions. Inspect the SQL we're using, learn the data dictionary.

You can also use our Search Feature - it's built for finding stuff in the database.

Good luck on your Oracle journey!

Upvotes: 2

Related Questions