fastest way to check if table exists

This is a discussion on "fastest way to check if table exists" within the PHP Forum section. This forum, and the thread "fastest way to check if table exists are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 18th, 2008, 01:59
CloudedVision's Avatar
Nerdy Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 828
Blog Entries: 6
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via AIM to CloudedVision Send a message via MSN to CloudedVision Send a message via Skype™ to CloudedVision
fastest way to check if table exists

whats the fastest way with PHP to check if a MySQL table really exists?
__________________
echo "Take it easy, ".$CloudedVision;
.links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; }
<quote>&quot;I think it's wrong that only one company makes the game Monopoly&quot; - <name>Steven Wright</name></quote>
Last Blog Entry: Nerd Poster (Jun 2nd, 2008)
Reply With Quote

  #2 (permalink)  
Old Feb 19th, 2008, 01:44
Junior Member
Join Date: Feb 2008
Location: Glasgow
Age: 28
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: fastest way to check if table exists

How about doing: 'describe table_name;' ?

If it exists, you'll get some result.
It's better than doing a select on the table because the select may return 0 results if the table exists but is empty and/or corrupt.
Reply With Quote
  #3 (permalink)  
Old Feb 20th, 2008, 16:04
Junior Member
Join Date: Feb 2008
Location: Poreč
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: fastest way to check if table exists

Quote:
Originally Posted by CloudedVision View Post
whats the fastest way with PHP to check if a MySQL table really exists?
I don't know if it is the fastest way, but I use this SQL:

show tables like 'your_table_name'

if it returns 1 rows => then your table exists.
Reply With Quote
  #4 (permalink)  
Old Feb 20th, 2008, 16:15
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,953
Blog Entries: 7
Thanks: 7
Thanked 3 Times in 3 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: fastest way to check if table exists

Quote:
Originally Posted by puzz View Post
I don't know if it is the fastest way, but I use this SQL:

show tables like 'your_table_name'

if it returns 1 rows => then your table exists.
I think this would be the method I would use.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Check to see if a cfwindow exists BenR41 Other Programming Languages 0 Feb 25th, 2008 12:22
simple check if user exists mlecho PHP Forum 3 Aug 28th, 2007 15:48
The Best and Fastest Method For Rounded Corner Designs sinjix_media Web Page Design 1 Jun 7th, 2007 15:38
Check whether URL exists Sheepymot PHP Forum 2 Jul 24th, 2005 08:16
Fastest way to dump a table contents? u2orange Databases 6 Mar 1st, 2004 20:43


All times are GMT. The time now is 22:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43