Home » SQL

SQL query to change column name

In this article, we are going to learn about the columns of the table and the process to change the name of the column.
Submitted by Manu Jemini, on March 11, 2018

Somehow all of us end changing the name of one or name column of the table. This may be because of various reasons. So the main point we need to see is the requirement.

You will need two things:

  1. Table Name
  2. Column name

Then simply say to the database that Alter my table by changing the column name which you want to be changed and pass a new name. That’s it.

Table (employee) having three fields and four data in it,

Id		Name		Address

100		Aman		Mumbai
200		Arun		Pune
300		Karan		Delhi

As we can see, our table employee having three columns name id, name, address having three rows of data filled in it. Now, we are going to alter the name of the column (name) to (employeename) and for that, we need to create an alter query with change query in it. Then we take the result set of all the data and display them on the console.


ALTER TABLE employee 
CHANGE COLUMN 'name' 'employeename' VARCHAR(45) ;

Display table records.

SELECT * FROM employee;


SQL query to change column name

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.