CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Posts
    1

    Thumbs up Query For a table using column name

    How to find the tables that uses the specific column name in the database (oracle 9i)?
    Last edited by SVL; December 29th, 2006 at 05:46 AM.

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Query For a table using column name

    Welcome to the Forum

    Without knowing the Database that you are using, it is almost impossible to give a solution or suggest something. You need to tell us which database you are using.

    For SQL 2000, you can use
    PHP Code:
    Select 
        TABLES
    .[NAME] As TableName 
    From 
        SYSOBJECTS TABLES 
        Inner Join SYSCOLUMNS FIELDS
        On TABLES
    .ID FIELDS.ID
    Where
        FIELDS
    .[NAME] = 'MYFIELDNAME' 

  3. #3
    Join Date
    Jun 2006
    Posts
    437

    Re: Query For a table using column name

    Hi all (and happy new year)

    It's quite simple; run the query

    Code:
    SELECT TABLE_NAME
      FROM USER_TAB_COLUMNS
     WHERE COLUMN_NAME = 'MY_COLUMN'
    It extracts all tables of the schema which have the column 'MY_COLUMN'
    If you use DBA_TAB_COLUMNS instead of USER_TAB_COLUMNS, you'll find all table in any schema of the instance which have a specified column.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured