How to know whether a table is exists?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: How to know whether a table is exists?

  1. #1
    Join Date
    Sep 2001
    Posts
    99
    I want to know whether a table is exist. Should I query whick system table?
    thanks
    ocean
    ocean

  2. #2
    Join Date
    Mar 2001
    Posts
    54
    select tname from tab;

    or

    select * from tab where tname = 'TABLENAME'




  3. #3
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    As a schema owner

    Code:
       SELECT * FROM user_tables
        WHERE table_name IN ('your_table_name');

    As a DBA

    Code:
     
        SELECT * FROM dba_tables
         WHERE owner IN ('schema_owner_name')
            AND  table_name IN ('your_table_name');

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  4. #4
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Originally posted by jeyaseelan
    select tname from tab;

    or

    select * from tab where tname = 'TABLENAME'



    Use of the view "TAB" is not recommended in 8i and above

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  5. #5
    Join Date
    Feb 2001
    Location
    Atlanta, USA
    Posts
    131
    Hi

    We can check from ALL_TABLES also.

    regards
    Anandharaj
    a_anandharaj@yahoo.com

  6. #6
    Join Date
    Oct 2001
    Posts
    122

    Cool

    All_tables only shows table names to which your user has access. So this may not give you correct answer. Also,the table name may appear more then once if many users have same table name and have granted access to your user.

    User_tables only shows table names that own by your user. So you cannot check if the table name you are searching for exists at all in the database.

    If you have DBA privs consider using dba_tables.



  7. #7
    Join Date
    Sep 2001
    Posts
    99

    thank you

    I find a view named "user_catalog", I can search my owner table from that view . Who can introduce this view?
    ocean

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