At 8:16 AM -0500 10/6/99, Carsten H. Pedersen wrote:
>> toxalot@stripped writes:
>> > I see in the handbook that there is a way to see that a table exists
>> > dropping it, but how do you check if one exists before trying to
>> > Jennifer
>> IF EXISTS works with DROP and CREATE, with a later being rather
>Alternatively, you can do "select 1 from <tablename>". You either
>get a result set of one record containing a 1 or an error indicating
>the table doesn't exist.
No, you get a result set consisting of "1" for *each row* of the table
name. These queries are faster:
SELECT COUNT(*) FROM tbl_name
SELECT * FROM tbl_name WHERE 1 = 0
Also, for CREATE TABLE, the clause is IF NOT EXISTS, not IF EXISTS.
Paul DuBois, paul@stripped