Problem renaming table

2003-08-14 Thread Tim Johnson
Hello All:
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?
2)Where is documentation.
I'm using ver. 3.23.41
Thanks very much.
tim
-- 
Tim Johnson [EMAIL PROTECTED]
  http://www.alaska-internet-solutions.com
  http://www.johnsons-web.com

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



Re: Problem renaming table

2003-08-14 Thread Egor Egorov
Tim Johnson [EMAIL PROTECTED] wrote:
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.

 2)Where is documentation.
 I'm using ver. 3.23.41

Documentation is included in all MySQL distributions. You can also find online 
documentation at:
http://www.mysql.com/documentation/index.html



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com




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



Re: Problem renaming table

2003-08-14 Thread Roger Baklund
* 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]



Re: Problem renaming table

2003-08-14 Thread Tim Johnson
* Egor Egorov [EMAIL PROTECTED] [030814 03:49]:
 Tim Johnson [EMAIL PROTECTED] wrote:
 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 :-(.

  2)Where is documentation.
  I'm using ver. 3.23.41
 
 Documentation is included in all MySQL distributions. You can also find online 
 documentation at:
   http://www.mysql.com/documentation/index.html
 
   Thanks again, my friend, I am aware of the existence of the
   documentation, but it is very voluminous, if someone reading
   this could point me to something more specific, I would
   appreciate it greatly.
   Regards
   ~tj~
 
 
 -- 
 For technical support contracts, goto https://order.mysql.com/?ref=ensita
 This email is sponsored by Ensita.net http://www.ensita.net/
__  ___ ___   __
   /  |/  /_ __/ __/ __ \/ /Egor Egorov
  / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
 /_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
___/   www.mysql.com
 
 
 
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

-- 
Tim Johnson [EMAIL PROTECTED]
  http://www.alaska-internet-solutions.com
  http://www.johnsons-web.com

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