Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie question: How to check for a tables existence in a smart (fast) way ??
Jørgen Haukland wrote:
>
> 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
SELECT DISTINCTROW MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE MSysObjects.Type=1 AND MSysObjects.Name = [name to check for]
If it does not return anything than you don't have such a table. Note that you might want to check for a query with that name as well:
SELECT DISTINCTROW MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE MSysObjects.Type=5 AND MSysObjects.Name = [name to check for]
Access does not allow table and query have the same name. So you might kill a query by creating a table and seting warnings to off.
Max. Received on Thu Jan 08 1998 - 00:00:00 CST