

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Purpose of using CHANGE command in MySQL?
The CHANGE command in MySQL is used to rename column name. Let us first create a table −
mysql> create table DemoTable796 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,Name varchar(100),StudentAge int ); Query OK, 0 rows affected (0.56 sec)
Let us check the description of table −
mysql> desc DemoTable796;
This will produce the following output −
+------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | Name | varchar(100) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | +------------+--------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
Following is the query to use CHANGE command in MySQL −
mysql> alter table DemoTable796 change Name StudentName varchar(100); Query OK, 0 rows affected (0.29 sec) Records: 0 Duplicates: 0 Warnings: 0
Let us check the description of table once again −
mysql> desc DemoTable796;
This will produce the following output −
+-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(100) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | +-------------+--------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- What is the purpose of the command interpreter?
- How to change the Title of the console using PowerShell command?
- How to change PowerShell ISE font Size using command?
- How to change the color of the PowerShell ISE editor using command?
- Does MongoDB getUsers() and SHOW command fulfil the same purpose?
- What is the purpose of MySQL TRIM() function?
- Change command Method for Tkinter Button in Python
- How to change the order of plots in Pandas hist command?
- Rename a table in MySQL using RENAME TABLE command
- Connecting to the MySQL Server Using Command Options
- Using Options on the Command Line for MySQL programs?
- What is the purpose of using MySQL CHAR_LENGTH() function? Which function is the synonym of it?
- What is the purpose of using JLink in Java 9?
- What is the purpose of ORDER BY columnname*1 in MySQL?
- Getting MySQL path in command prompt
Advertisements