Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL: How to check if a table exists or not?
Sandra Jones <sfjones_at_bellsouth.net> wrote in article
<3415F817.7CDF_at_bellsouth.net>...
>
> greg teets wrote:
> >
> > On Wed, 27 Aug 1997 15:43:33 -0300, "Michael A. Casillas"
> > <casillas_at_icepr.com> wrote:
> >
> > You can select against USER_TABLES
> >
As far as I know, USER_TABLES would only show the tables which are own by the same user who is currently connected, so this may not work for systems where multiple user id's are used to connect and access tables owned by another user id.
But if you are using PL/SQL you can do a SELECT statement on the table (e.g. SELECT 'z' from TABLE1) and then catch the exception. If SQLCODE= -904 in the exception (the code for "TABLE DOES NOT EXIST") then you can take appropriate action.
BEGIN
SELECT 'x'
into x
from table1
where rownum = 1;
... ... ...
if SQLCODE = -904 then -- do whatever action here end if;
![]() |
![]() |