Home > Database > Mysql Tutorial > body text

How can we change the name of a MySQL table?

WBOY
Release: 2023-09-02 11:57:03
forward
1250 people have browsed it

我们如何更改 MySQL 表的名称?

The RENAME command is used to change the name of a MySQL table. Its syntax is as follows -

RENAME table old_tablename to new_tablename2;
Copy after login

Example

In the following example, we have renamed the table "testing" to "test".

mysql> RENAME table testing to test;
Query OK, 0 rows affected (0.17 sec)

mysql> Select * from testing;
ERROR 1146 (42S02): Table 'query.testing' doesn't exist

mysql> Select * from test;
+-----+---------+
| id1 | Name    |
+-----+---------+
| 1   | Harshit |
| 2   | Lovkesh |
| 3   | MOHIT   |
| 4   | MOHIT   |
+-----+---------+

4 rows in set (0.02 sec)
Copy after login

The above is the detailed content of How can we change the name of a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template