List:General Discussion« Previous MessageNext Message »
From:Jeff Smelser Date:October 6 2005 6:06pm
Subject:Re: Detect if table exists from within MySQL?
View as plain text  
On Thursday 06 October 2005 10:57 am, Ryan Stille wrote:
> I am converting some code from MSSQL to MySQL.  In one place I need to
> have a conditional query depending on if a table exists or not.  There
> are different versions of this application and the table only exists in
> some of them.  Here is how it was done in MSSQL:
>
> IF OBJECT_ID('cfgbiz') IS NOT NULL
>   SELECT notifyto FROM cfgbiz
> ELSE
>   SELECT '' as notifyto
>
> Is there something similar in MySQL? I am running version 4.1.x.

5.X has information_schema.. 

However...

4.1, you can show tables like '%tab%' and you will get a row back if exists.. 
WARNING, myisam will be quick, innodb will be really slow, specially if the 
tables are big.. 

Jeff

Attachment: [application/pgp-signature]
Thread
Detect if table exists from within MySQL?Ryan Stille6 Oct
  • Re: Detect if table exists from within MySQL?Peter Brawley6 Oct
  • A question about stored proceduresLeonardo Javier BelĂ©n6 Oct
    • Re: A question about stored proceduresGleb Paharenko7 Oct
  • Re: Detect if table exists from within MySQL?Jeff Smelser6 Oct
RE: Detect if table exists from within MySQL?Ryan Stille6 Oct
  • Re: Detect if table exists from within MySQL?Keith Ivey6 Oct
RE: A question about stored proceduresSujay Koduri6 Oct
RE: Detect if table exists from within MySQL?Ryan Stille6 Oct