Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: Test for a table

REPOST: Re: Test for a table

From: Daniel A. Morgan <damorgan_at_exesolutions.com>
Date: Fri, 25 Jan 2002 10:22:20 +0000
Message-ID: <2$--$%%%%--%-%$_%$@news.noc.cabal.int>


When not just use the direct approach?

SELECT COUNT(1)
FROM all_tables
WHERE table_name = ?

Or go one step better and use all_tab_columns to see if the table, and its columns, are there.

Personally I can't think of a single reason to ever test this. Just run your SQL in a block with an exception handler.

Daniel Morgan

TurkBear wrote:

> If the table is large that could take a long time; Try:
>
> select 'x' from table_name where 1=1 and rownum < 2;
>
> If it does exist, x will be returned..
> If the table does not exist, an error will result ( an ORA 942)...
> ( same as would happen in the other response)
>
> "Mark & Kristi Wagoner" <mwagoner_at_iac.net> wrote:
>
> >select count(*) from all_tables (or user_tables) where table_name='XXX';
> >
> >"Philip Morrow" <cracker_at_mymorrow.com> wrote in message
> >news:gn028.364520$oj3.71133325_at_typhoon.tampabay.rr.com...
> >> How can I test for the existance of a table using a SQL statement.
> >>
> >> Thanks
> >> Phil
> >>
> >>
> >
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> Check out our new Unlimited Server. No Download or Time Limits!
> -----== Over 80,000 Newsgroups - 19 Different Servers! ==-----

This message was cancelled from within The Unacanceller's glorious new software, Lotus 1-2-3 For Rogue Cancellers. Received on Fri Jan 25 2002 - 04:22:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US