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.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Feb 18th, 2008, 01:59
CloudedVision's Avatar
Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 1,252
Blog Entries: 9
Thanks: 2
Thanked 40 Times in 40 Posts
fastest way to check if table exists

whats the fastest way with PHP to check if a MySQL table really exists?
__________________
Web Design And Development: Other Road Design | Problems with IE6?: KApp | My Blog: Only Nerds Allowed | Learning PHP? Lessons
Last Blog Entry: Hilarious Rapper (Jul 29th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Feb 20th, 2008, 16:15
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,178
Blog Entries: 7
Thanks: 27
Thanked 21 Times in 18 Posts
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.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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 18:47.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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