473,322 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

to check if a table exists

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!!!
Jul 19 '05 #1
3 42993
"DottingTheNet" <do***********@hotmail.com> wrote in message
news:11**************************@posting.google.c om...
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
Jul 19 '05 #2
"Douglas Hawthorne" <do**************@yahoo.com.au> wrote in message news:<nv****************@news-server.bigpond.net.au>...
"DottingTheNet" <do***********@hotmail.com> wrote in message
news:11**************************@posting.google.c om...
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 --
Jul 19 '05 #3
do***********@hotmail.com (DottingTheNet) wrote in message news:<11**************************@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!!!

When you have proper exception handling in your code, you don't NEED
to check whether a table exists. Stop programming silly tests like
this one, and LEARN pl/sql, start UNLEARNING your bad sqlserver habits
NOW

Oracle != Sqlserver.

Sybrand Bakker
Senior Oracle DBA
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
10
by: Geoff Jones | last post by:
Hi I'm trying to drop a table by using: Dim cmd As New OleDbCommand("DROP TABLE IF EXISTS books", myconnection) cmd.ExecuteNonQuery() but I get a syntax error: "Syntax error in DROP TABLE...
2
by: RLN | last post by:
Re: Access 2003 I have code to check to see if a table exists. There are several other tables (tblQ12, tblQ13, etc) that do already exist & this code runs fine; msgbox says the value returned is...
16
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
3
by: DottingTheNet | last post by:
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...
0
by: bharathreddy | last post by:
This article will explain you how to check weather a column already exists in a table before you add the column to the table using alter command. Using the system tables...
4
by: qwedster | last post by:
Howdy folks! I am using stored procedure to see if a value exists in database table and return 0 if exists or else -1, in the following SQL queries. However how to check if a value (that is...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.