List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:November 21 2008 6:00am
Subject:Re: How to determine if temporary table exists
View as plain text  
In the last episode (Nov 20), mos said:
> At 08:02 PM 11/20/2008, you wrote:
> >Try drop table if exists Tablex;
> 
> Ahhh, I don't necessarily want to drop the table if it already
> exists. :) If the table already exists then I'll add new rows to it
> (and keep the existing rows). If the table doesn't exist, then I'll
> create it.
> 
> I suppose could count the rows in Tablex and it would throw an
> exception if the table did not exist . But I really didn't want to
> resort to trapping an exception in my program. I thought there should
> be an easy way using SQL to determine if a temporary table exists or
> not.

Why not "CREATE TEMPORARY TABLE IF NOT EXISTS ..."?  If you really need
to know whether the table existed before or not, that command will
return a warning if it was there already.

http://dev.mysql.com/doc/refman/5.0/en/create-table.html

-- 
	Dan Nelson
	dnelson@stripped
Thread
How to determine if temporary table existsmos21 Nov
  • Re: How to determine if temporary table existsMoon's Father21 Nov
    • Re: How to determine if temporary table existsmos21 Nov
      • Re: How to determine if temporary table existsDan Nelson21 Nov
        • Re: How to determine if temporary table existsmos21 Nov
  • Looking at the MySQL binlog and pulling the queries onto one lineAndrew Braithwaite21 Nov