PDA

查看完整版本 : How to rename a table in MySQL?


smile4u
2001-02-14, 02:40
I'd like to rename a table in my MySQL database. Please tell
me how to do it directly by using sql. You know, in ORACLE,
we can do that by "CREATE TABLE table_name AS SELECT *
FROM old_table".

Thanks

smile4u

子夜游魂
2001-02-14, 08:57
有两种方法可以实现你的要求,
第一种就是你安装一个phpMyadmin,可以使用web的方式来实现数据表的改名。
第二种就是使用sql语句,使用这条语句就可以
ALTER TABLE old_name RENAME new_name;
呵呵,似乎比oracle简单些。

two way
first:you can install phpMyadmin
secondly:you can use sql command
ALTER TABLE old_name RENAME new_name;

smile4u
2001-02-15, 06:46
Hi,
I'd like to thank you for your quick response. You
are right, we can rename the table by using that way, but I
still want to keep the old table. You know, in ORACLE,
"CREATE TABLE tb_nm AS SELECT ..." can prevent the old
table and keep it in the database. Usally, in MySQL,
I dump the table first(mysqldump) and then edit the
dumped file(just change the table name there) and import
it in my database(mysql dbname<dumped-file), but you know,
that is not a direct way with sql and there is no view
defination in MySQL so we can't redirectly get the new
name table from its view. Anyway, thank you a lot for
your help.

smile4u