MySQL中如何修改表的名字?修改表名?

database

操作过程

mysql> create table ts01 like ti_o_sms;       #创建表结构.这样的建表方式,不仅仅是表的结构,连带着索引也会同时创建.

Query OK, 0 rows affected (0.02 sec)

mysql> alter table ts01 rename to ts01_new; #修改表名的语法:alter table rename to/as new_tablename;

Query OK, 0 rows affected (0.00 sec)

mysql> show tables;

+--------------------+

| Tables_in_mytest |

+--------------------+

| sms_send_blacklist |

| td_b_sendobject |

| ti_o_sms |

| ts01_new |

+--------------------+

rows in set (0.00 sec)

或者

mysql> alter table ts01_new rename AS ts02;

Query OK, 0 rows affected (0.03 sec)

mysql> show tables;

+--------------------+

| Tables_in_mytest |

+--------------------+

| sms_send_blacklist |

| td_b_sendobject |

| ti_o_sms |

| ts02 |

+--------------------+

rows in set (0.00 sec

备注:表名已经成功的进行修改。

官方文档修改表名的语法

mysql> help alter table

Name: "ALTER TABLE"

Description:

Syntax:

ALTER TABLE tbl_name

[alter_specification [, alter_specification] ...]

[partition_options]

alter_specification:

table_options

.......| RENAME [TO|AS] new_tbl_name

.......

 

以上是 MySQL中如何修改表的名字?修改表名? 的全部内容, 来源链接: utcz.com/z/533449.html

回到顶部