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

Home -> Community -> Usenet -> comp.databases.oracle -> Re: to check if a table exists

Re: to check if a table exists

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 12 Apr 2004 13:28:11 -0700
Message-ID: <2687bb95.0404121228.14eeabc3@posting.google.com>

"Douglas Hawthorne" <douglashawthorne_at_yahoo.com.au> wrote in message news:<nvqec.5212$ED.3499_at_news-server.bigpond.net.au>...
> "DottingTheNet" <dottingthenet_at_hotmail.com> wrote in message
> news:11bf8d5a.0404112139.78b6b18e_at_posting.google.com...
> > i promise no more silly questions after this
> >
> > but how do i check if a table exists??
> > it is my understanding that the exists can only be used in the where
> > clause of the query.
> > i just want s'thing simple like
> > if exists ('test')
> > then ---good
> > else
> > --create it
> > end if;
> > thanx in advance!!!
>
> Check out the ALL_TABLES and USER_TABLES views in the "Database Reference"
> manual.
>
> Douglas Hawthorne

Something like
begin
select table_name into v_variable from all_tables where owner = v_owner and table_name = v_table_name -- found logic here
exception
  when no_Data_found then ... execute immediate create logic end;

You can probably find a working example/stored function in the archives.

HTH -- Mark D Powell -- Received on Mon Apr 12 2004 - 15:28:11 CDT

Original text of this message

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