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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie question: How to check for a tables existence in a smart (fast) way ??

Re: Newbie question: How to check for a tables existence in a smart (fast) way ??

From: Bill MacLean <NSbmaclean_at_worldnet.att.net>
Date: 1998/01/09
Message-ID: <694aud$k9v@mtinsc05.worldnet.att.net>#1/1

I see your post was sent to multiple groups, so you will get somewhat different answers, depending on if an Oracle person or a SQL Server person writes to you.

The generic, engine independent answer is that relational databases have system tables, sometimes referred to as "catalog" or "dictionary" tables. These tables contain metadata about the rest of the database, including info on what other tables exist, what columns exists, who owns the tables, what constraints and relationships exist, etc. Anything you want to know about the structure of the database is represented as rows of data somewhere in the dictionary tables. Most vendors create SQL views (virtual tables) of these dictionary tables that are pretty easy to query

In Oracle, you could check for the existence of MAYBE_TABLE as follows:

SELECT count(*)
FROM tabs
WHERE table_name = 'MAYBE_TABLE';

If this statement returns a number greater than 0, the table exists. There are other dictionary tables and views that you could query to get the answer you need, but tabs is the view that comes to mind immediately.

Thanks,

Bill MacLean

Jørgen Haukland <jorgen.hauikland_at_fou.telenor.no> wrote in article <6935n9$nrp_at_info.telenor.no>...
> Hey !
>
> I'm working on an application and need to create some tables if they
 don't
> already exists - sometimes they do. I've tried to find a smart SQL
 statement
> but i end up with something that lists smaller or larger parts of the
 table.
> This is no good solution because this table can occasionally be quite
 large
> (50 - 60 MB). I need a statement that don't do any searching in the
 table,
> just sees if it's there.
>
> Any suggestions ??
>
> Private e-mails are welcome as long as they also are submitted to the
 group.
>
> Joergen Haukland
> NORWAY
>
> e-mail: jorgen.haukland_at_fou.telenor.no
>
>
>
Received on Fri Jan 09 1998 - 00:00:00 CST

Original text of this message

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