boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rename table name on database

 
Post new topic   Reply to topic    boardom Forum Index -> PHP help
View previous topic :: View next topic  
Author Message
deddy



Joined: 28 Apr 2003
Posts: 5

PostPosted: Wed May 21, 2003 2:28 am    Post subject: Rename table name on database Reply with quote

uhm.... maybe this topic is near to MySQL problem..
but i really needing help for this

can we rename table name on database?

first I used table "post" for b2post, "comment" for b2comment, ect...
and i want to rename "post" "comment" ect... Can I?
thanks be4
Back to top
View user's profile Send private message Visit poster's website
lcf



Joined: 05 May 2003
Posts: 92
Location: Malaysia

PostPosted: Wed May 21, 2003 5:07 am    Post subject: Reply with quote

Here you are, from MySQL documentation Smile

Quote:
6.5.5 RENAME TABLE Syntax

RENAME TABLE tbl_name TO new_tbl_name[, tbl_name2 TO new_tbl_name2,...]

The rename is done atomically, which means that no other thread can access any of the tables while the rename is running. This makes it possible to replace a table with an empty one:

CREATE TABLE new_table (...);
RENAME TABLE old_table TO backup_table, new_table TO old_table;

The rename is done from left to right, which means that if you want to swap two tables names, you have to:

RENAME TABLE old_table TO backup_table,
new_table TO old_table,
backup_table TO new_table;

As long as two databases are on the same disk you can also rename from one database to another:

RENAME TABLE current_db.tbl_name TO other_db.tbl_name;

When you execute RENAME, you can't have any locked tables or active transactions. You must also have the ALTER and DROP privileges on the original table, and the CREATE and INSERT privileges on the new table.

If MySQL encounters any errors in a multiple-table rename, it will do a reverse rename for all renamed tables to get everything back to the original state.

RENAME TABLE was added in MySQL 3.23.23.


_________________
LcF
http://weblog.lcfwebsite.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> PHP help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group