
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we change the name of a MySQL table?
RENAME command is used to change the name of a MySQL table. Its syntax is as follows −
RENAME table old_tablename to new_tablename2;
Example
In the example below, we rename 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)
- Related Articles
- How can I change the name of an existing column from a MySQL table?
- How can we change the data type of the column in MySQL table?
- Can we give underscore in a MySQL table name?
- Can we perform MySQL UPDATE and change nothing in a table?
- How can I change the storage engine of a MySQL table?
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- Can we create a table with a space in name in MySQL?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can we make a MySQL clone table?
- How can we add values into the columns of a MySQL table?
- How can we remove a column from MySQL table?
- How can we update values in a MySQL table?
- How can we insert data into a MySQL table?
- How can we modify column/s of MySQL table?

Advertisements