Solved

Query Oracle System Tables

Posted on 2013-11-19
1
456 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
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Sql to get orphans 7 50
CREATE TABLE syntax 4 43
null value 14 56
What is the version of ojdbc6.jar 2 22
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now