💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
rename 1、Rename table语句用来重命名一个或多个表名 `RENAME TABLE old_table TO new_table;` 当想让两个表名相互调换时,可以执行语句 ~~~ RENAME TABLE old_table TO tmp_table, new_table TO old_table, tmp_table TO new_table; ~~~ Rename table能将表中的数据,索引,主键定义都自动转换到新表下,但视图和对原表分配的权限不能自动转换到新表,需要手动执行 ~~~ mysql> rename table students to students_test; Query OK, 0 rows affected (0.03 sec) mysql> show create table students_test; +---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | students_test | CREATE TABLE `students_test` ( `sid` int(11) DEFAULT NULL, `sname` varchar(20) DEFAULT NULL, `sex` int(11) DEFAULT NULL, UNIQUE KEY `idx_st_sid` (`sid`), KEY `idx_st_union` (`sname`,`sex`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | mysql> select * from v_students_female; ##原有视图查询失败 ERROR 1356 (HY000): View 'test.v_students_female' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them ~~~