List:General Discussion« Previous MessageNext Message »
From:Timothy Chi Date:October 4 1999 5:44pm
Subject:checking existance of tables/cols/keys with MySQL
View as plain text  
Does anyone know how to check for the existance of a specific table, column,
and/or keys within MySQL? 

For instance, I need to run an ALTER TABLE command to change a column name,
but only want to do this if it hasn't been done already.

In MS SQL Server 7, I would do something like:

if exists (select * from sysobjects where id =
object_id(N'[dbo].[system_registry]') and OBJECTPROPERTY(id, N'IsUserTable')
= 1)
alter table  system_registry .... 
go

I not only need to check columns names, but if various primary keys have
been established (and if not, create them).

Thanks in advance,

--Tim
tchi@stripped
Thread
checking existance of tables/cols/keys with MySQLTimothy Chi4 Oct
  • Re: checking existance of tables/cols/keys with MySQLsinisa5 Oct