In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Mysql how to exchange the names of two tables at the same time, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Mysql exchanges table names of two tables at the same time
There are two ways to rename tables, so there are also two ways to exchange two table names:
1.
Lock tables T1 write, T2 write;alter table T1 rename to T3 switch alter table T2 rename to T1 alter table T3 rename to T2 tables
2.
Rename table T1 to T3 Magi T2 to T1 Magi T2 to T3 nomenclature rename: change the table name
The rename command is used to modify the table name.
Rename command format: rename table original table name to new table name
For example, in the table MyClass the name is changed to YouClass:
Mysql > rename table MyClass to YouClass
When you execute RENAME, you cannot have any locked tables or active transactions. You must also have ALTER and DROP permissions on the original table, as well as CREATE and INSERT permissions on the new table.
If MySQL encounters any errors in multiple table renaming, it will retrograde all renamed tables, returning everything to its original state.
RENAME TABLE was added in MySQL 3.23.23.
Rename table method
You can rename a table using either the RENAME TABLE statement or the ALTER TABLE statement. The basic syntax is as follows:
# RENAME TABLE syntax: RENAME TABLE tbl_name TO new_tbl_name [, tbl_name2 TO new_tbl_name2]. # ALTER TABLE syntax: ALTER TABLE old_table RENAME new_table;# specific example: mysql > show tables +-+ | Tables_in_testdb | +-+ | tb1 | | tb2 | +-+ 2 rows in set (0.00 sec) mysql > rename table tb1 to new_tb1;Query OK, 0 rows affected (0.03 sec) mysql > alter table tb2 rename new_tb2 Query OK, 0 rows affected (0.04 sec) mysql > show tables;+-+ | Tables_in_testdb | +-+ | new_tb1 | | new_tb2 | +-+ 2 rows in set (0.00 sec) is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.