Unix Technical Forum

Find all tables with a particular field

This is a discussion on Find all tables with a particular field within the Oracle Database forums, part of the Database Server Software category; --> Hello, How does one go about finding all the tables that have a particular field name? For example a ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-25-2008, 07:10 AM
Fred Wilson
 
Posts: n/a
Default Find all tables with a particular field

Hello,

How does one go about finding all the tables that have a particular
field name? For example a field name "EVENT_CODE"

I would like to find all the places in the database this is located.
Ultimately I want to further find in that field the code "0214" and
change it to "0200".

Thank you,
Fred
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-25-2008, 07:10 AM
DA Morgan
 
Posts: n/a
Default Re: Find all tables with a particular field

Fred Wilson wrote:
> Hello,
>
> How does one go about finding all the tables that have a particular
> field name? For example a field name "EVENT_CODE"
>
> I would like to find all the places in the database this is located.
> Ultimately I want to further find in that field the code "0214" and
> change it to "0200".
>
> Thank you,
> Fred


All relational databases have data dictionaries. Are you familiar with
the concept? If not then I suggest the following query:

SELECT view_name
FROM all_views
WHERE (view_name LIKE 'USER%' OR view_name LIKE 'ALL%')
ORDER BY 1;

The one you are looking for is: xxx_tab_columns.
--
Daniel Morgan
University of Washington
Puget Sound Oracle Users Group
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-25-2008, 07:10 AM
Mark D Powell
 
Posts: n/a
Default Re: Find all tables with a particular field


DA Morgan wrote:
> Fred Wilson wrote:
> > Hello,
> >
> > How does one go about finding all the tables that have a particular
> > field name? For example a field name "EVENT_CODE"
> >
> > I would like to find all the places in the database this is located.
> > Ultimately I want to further find in that field the code "0214" and
> > change it to "0200".
> >
> > Thank you,
> > Fred

>
> All relational databases have data dictionaries. Are you familiar with
> the concept? If not then I suggest the following query:
>
> SELECT view_name
> FROM all_views
> WHERE (view_name LIKE 'USER%' OR view_name LIKE 'ALL%')
> ORDER BY 1;
>
> The one you are looking for is: xxx_tab_columns.
> --
> Daniel Morgan
> University of Washington
> Puget Sound Oracle Users Group


The following short article offers a brief introduction to the Oracle
rdbms dictionary views:

How do I find information about a database object: table, index,
constraint, view, etc... in Oracle ?
http://www.jlcomp.demon.co.uk/faq/object_info.html

The view you want is all_tab_comments or the dba_ or user_ versions of
it.

You can find documentation on all the Oracle provided dictionary views
in the Oracle Reference Manual along with sections on the database
parameters and the dynamic performance views.

HTH -- Mark D Powell --

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-25-2008, 07:10 AM
DA Morgan
 
Posts: n/a
Default Re: Find all tables with a particular field

Mark D Powell wrote:
> DA Morgan wrote:
>> Fred Wilson wrote:
>>> Hello,
>>>
>>> How does one go about finding all the tables that have a particular
>>> field name? For example a field name "EVENT_CODE"
>>>
>>> I would like to find all the places in the database this is located.
>>> Ultimately I want to further find in that field the code "0214" and
>>> change it to "0200".
>>>
>>> Thank you,
>>> Fred

>> All relational databases have data dictionaries. Are you familiar with
>> the concept? If not then I suggest the following query:
>>
>> SELECT view_name
>> FROM all_views
>> WHERE (view_name LIKE 'USER%' OR view_name LIKE 'ALL%')
>> ORDER BY 1;
>>
>> The one you are looking for is: xxx_tab_columns.
>> --
>> Daniel Morgan
>> University of Washington
>> Puget Sound Oracle Users Group

>
> The following short article offers a brief introduction to the Oracle
> rdbms dictionary views:
>
> How do I find information about a database object: table, index,
> constraint, view, etc... in Oracle ?
> http://www.jlcomp.demon.co.uk/faq/object_info.html
>
> The view you want is all_tab_comments or the dba_ or user_ versions of
> it.
>
> You can find documentation on all the Oracle provided dictionary views
> in the Oracle Reference Manual along with sections on the database
> parameters and the dynamic performance views.
>
> HTH -- Mark D Powell --


I am sure it is a typo Mark but all the tables with a particular column
name are likely not going to show up in tab_comments ... rather tab_columns.

In most databases no one will put anything in tab_comments. ;-) C'est
dommage.
--
Daniel Morgan
Puget Sound Oracle Users Group
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-25-2008, 07:12 AM
Mark D Powell
 
Posts: n/a
Default Re: Find all tables with a particular field


DA Morgan wrote:
> Mark D Powell wrote:
> > DA Morgan wrote:
> >> Fred Wilson wrote:
> >>> Hello,
> >>>
> >>> How does one go about finding all the tables that have a particular
> >>> field name? For example a field name "EVENT_CODE"
> >>>
> >>> I would like to find all the places in the database this is located.
> >>> Ultimately I want to further find in that field the code "0214" and
> >>> change it to "0200".
> >>>
> >>> Thank you,
> >>> Fred
> >> All relational databases have data dictionaries. Are you familiar with
> >> the concept? If not then I suggest the following query:
> >>
> >> SELECT view_name
> >> FROM all_views
> >> WHERE (view_name LIKE 'USER%' OR view_name LIKE 'ALL%')
> >> ORDER BY 1;
> >>
> >> The one you are looking for is: xxx_tab_columns.
> >> --
> >> Daniel Morgan
> >> University of Washington
> >> Puget Sound Oracle Users Group

> >
> > The following short article offers a brief introduction to the Oracle
> > rdbms dictionary views:
> >
> > How do I find information about a database object: table, index,
> > constraint, view, etc... in Oracle ?
> > http://www.jlcomp.demon.co.uk/faq/object_info.html
> >
> > The view you want is all_tab_comments or the dba_ or user_ versions of
> > it.
> >
> > You can find documentation on all the Oracle provided dictionary views
> > in the Oracle Reference Manual along with sections on the database
> > parameters and the dynamic performance views.
> >
> > HTH -- Mark D Powell --

>
> I am sure it is a typo Mark but all the tables with a particular column
> name are likely not going to show up in tab_comments ... rather tab_columns.
>
> In most databases no one will put anything in tab_comments. ;-) C'est
> dommage.
> --
> Daniel Morgan
> Puget Sound Oracle Users Group


Yep, just finished fixing a couple of table comment statements so
naturally my fingers and brain were following different paths.

HTH -- Mark D Powell --

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-25-2008, 07:12 AM
Andy Hassall
 
Posts: n/a
Default Re: Find all tables with a particular field

On Mon, 18 Sep 2006 20:14:00 -0700, DA Morgan <damorgan@psoug.org> wrote:

>In most databases no one will put anything in tab_comments. ;-) C'est
>dommage.


I think we may actuallly agree on something here ;-) IMHO the comprehensive
use of (at least) "comment on table <table>" and "comment on column
<table.column>" should be a compulsory part of any organisation's coding
standards.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-25-2008, 07:13 AM
DA Morgan
 
Posts: n/a
Default Re: Find all tables with a particular field

Mark D Powell wrote:
> DA Morgan wrote:
>> Mark D Powell wrote:


>>> You can find documentation on all the Oracle provided dictionary views
>>> in the Oracle Reference Manual along with sections on the database
>>> parameters and the dynamic performance views.
>>>
>>> HTH -- Mark D Powell --

>> I am sure it is a typo Mark but all the tables with a particular column
>> name are likely not going to show up in tab_comments ... rather tab_columns.
>>
>> In most databases no one will put anything in tab_comments. ;-) C'est
>> dommage.
>> --
>> Daniel Morgan
>> Puget Sound Oracle Users Group

>
> Yep, just finished fixing a couple of table comment statements so
> naturally my fingers and brain were following different paths.
>
> HTH -- Mark D Powell --


Trying to earn the "good programmer" award? ;-)

You're going to make the rest of us look like what we are. :-(
--
Puget Sound Oracle Users Group
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-25-2008, 07:14 AM
Jaap W. van Dijk
 
Posts: n/a
Default Re: Find all tables with a particular field

On Mon, 18 Sep 2006 17:01:47 -0700, DA Morgan <damorgan@psoug.org>
wrote:


>The one you are looking for is: xxx_tab_columns.
>--


This view gives the columns of all tables * and views *. The OP only
wanted columns of tables so he has to eliminate the views from this
view.

Jaap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-25-2008, 07:14 AM
DA Morgan
 
Posts: n/a
Default Re: Find all tables with a particular field

Jaap W. van Dijk wrote:
> On Mon, 18 Sep 2006 17:01:47 -0700, DA Morgan <damorgan@psoug.org>
> wrote:
>
>
>> The one you are looking for is: xxx_tab_columns.
>> --

>
> This view gives the columns of all tables * and views *. The OP only
> wanted columns of tables so he has to eliminate the views from this
> view.
>
> Jaap.


"so he has to eliminate the views from this view."

We are not communicating well. I thought the OP wanted to know which
objects contained a specific column name such as:

SELECT table_name
FROM user_tab_columns
WHERE column_name = 'EMPID';
--
Daniel Morgan
Puget Sound Oracle Users Group
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-25-2008, 07:14 AM
Jaap W. van Dijk
 
Posts: n/a
Default Re: Find all tables with a particular field

On Wed, 20 Sep 2006 11:05:29 -0700, DA Morgan <damorgan@psoug.org>
wrote:

>Jaap W. van Dijk wrote:
>> On Mon, 18 Sep 2006 17:01:47 -0700, DA Morgan <damorgan@psoug.org>
>> wrote:
>>
>>
>>> The one you are looking for is: xxx_tab_columns.
>>> --

>>
>> This view gives the columns of all tables * and views *. The OP only
>> wanted columns of tables so he has to eliminate the views from this
>> view.
>>
>> Jaap.

>
>"so he has to eliminate the views from this view."
>
>We are not communicating well. I thought the OP wanted to know which
>objects contained a specific column name such as:
>
>SELECT table_name
>FROM user_tab_columns
>WHERE column_name = 'EMPID';
>--
>Daniel Morgan
>Puget Sound Oracle Users Group


Your SELECT will also find views (and clusters) with the column_name
EMPID. I thought that the OP might not know this and I wanted to warn
him, because he specifically asked for *tables* containing a column
with a certain name.

Jaap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:22 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com