* Tim Johnson
[...]
> > >    I would like to rename a table if it exists.
> > >
> > > The following query
> > > IF EXISTS ALTER TABLE gwcc_members RENAME gwcc_members_bak;
> > > fails.
> > >
> > > also
> > >
> > > ALTER TABLE IF EXISTS gwcc_members RENAME gwcc_members_bak;
> > > fails.
> > >
> > >
> > > 1)What is the correct syntax?
> >
> > You should check if table exists, and then rename table.
>
>  :-) Igor, I appreciate the effort, but if you read above,
>  I understand that logic but my poor attempt at syntax
>  has failed :-(.

You seem to be assuming that there exists a single command which will do
these two operations at the same time? There is no such command.

To check if a table exist, you can examine the list returned by SHOW TABLES,
or you can check if SHOW TABLES LIKE "tablename" return anything, or you can
simply assume that the table does not exist if "ALTER TABLE tablename RENAME
newname" fails.

HTH,

--
Roger


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to