473,503 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check if table is exist or not

190 New Member
May this question exist....But i confused...I want to check whether the table is exist or not ....


Like i run a project , on that project i create a temp tables while run time.... on that i want to chech a table is exist or not...

if employee table is exist

exit;
else
create table employee
Sep 6 '08 #1
3 4238
r035198x
13,262 MVP
Check the refmanual for the create table syntax and read about the IF NOT EXISTS clause.
Sep 8 '08 #2
maheswaran
190 New Member
tnx,

but this one will gove more easiest way (i hope)...
Expand|Select|Wrap|Line Numbers
  1. if(!(mysql_query("select * from table")))
  2. {
  3. echo "table not found";
  4. }
  5. else
  6. {
  7. echo "table found";
  8. }
  9.  
Sep 8 '08 #3
Atli
5,058 Recognized Expert Expert
That is an extremely wasteful method. You would in fact be fetching ALL the data from that table, just to see if it exists.

A far better way would be to use the SHOW TABLES command, like:
Expand|Select|Wrap|Line Numbers
  1. SHOW TABLES LIKE 'myTableName';
  2.  
Which would return an empty set if the table doesn't exists, or a single row if it does.

P.S.
Use [code] tags when posting code examples.
Please read the Posting Guidelines before posting.

Thank you.
MODERATOR
Sep 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3420
by: Roger | last post by:
How can I check if a field already exist in a table? If it doesn't exist I want to add it with ALTER TABLE ADD...
2
17879
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...
2
3428
by: John M | last post by:
Hi, I want to create a link to another database table. I've succeeded in doing this, and avoided creating the the link over and over again by putting in the error statement something to the...
2
1583
by: zjut | last post by:
In c#, Microsoft sql 2000, the name of db is "tc",and i want to check the table "csharp" is exist or not . if it isnot exist, create it.! ====================================== SqlCommand cmd =...
5
3074
by: Mike Charney | last post by:
I have an Access data project. In this project I have a form that when Access starts is loaded and this form has VBA code attached to it. One of the first things I need to do is check if a table...
5
1669
by: micklee74 | last post by:
hi in my code, i use dict(a) to make to "a" into a dictionary , "a" comes from user input, so my program does not know in the first place. Then say , it becomes a = { '-A' : 'value1' , '-B' :...
2
6922
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...
14
2109
by: Dan | last post by:
Hello, we have an intranet application using Windows Integrated Authentification. When an user starts the application, he gets a form for inputting data. The first time he does that, the...
0
1359
by: lgxdo | last post by:
hi all, I have one question like that: I have one customer table: customerID, name,address,phone,zip....... I must check the customer in this table or not before insert it. The records of the...
0
7205
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
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.