?
Solved

Query Oracle System Tables

Posted on 2013-11-19
1
Medium Priority
?
467 Views
Last Modified: 2013-11-24
How do I search Oracle System tables to find columns with a like statement?  Below is a query I use in SQL Server 2008R2 and I need to run the equivalent Oracle system tables for the same information in Oracle 11G.  I am trying to find schema with a like statement:


SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%LastName%'   ---column search  
ORDER BY schema_name, table_name;
0
Comment
Question by:JGH5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 2000 total points
ID: 39660891
Assuming you have DBA level permissions:

SELECT owner, table_name, column_name
FROM dba_tab_columns
WHERE column_name LIKE '%LASTNAME%'   ---column search  
ORDER BY owner, table_name; 

Open in new window


If you don't and you are connected as the owner of the table:

SELECT table_name, column_name
FROM user_tab_columns
WHERE column_name LIKE '%LASTNAME%'   ---column search  
ORDER BY table_name; 

Open in new window


(The owner column doesn't exist in the user_* views since the owner is the user you're connected as).

You could also run the first query against ALL_ instead of DBA_ - that will search all the tables that the currently connected user has access to.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question