473,387 Members | 1,844 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,387 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 42995
"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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.