The best way to Rename Column Title in SQL?


Rename Column Name in SQL

It would continuously occur that we see a necessity to vary the title of the phase within the information set to fill their want. With the help of SQL or Structured Question Language, the Database Directors retailer, replace, management and get well info in social information units. Thus, this text lets us comprehend easy methods to rename a column title in SQL.

The accompanying factors can be canvassed on this article:

  1. What’s SQL?
  2. What’s RENAME command in SQL?
  3. The best way to Rename column title in SQL?
  4. Rename column title in MS SQL Server

So allow us to get the whole lot rolling then, at that time,

What’s SQL?

SQL, commonly known as SEQUEL, is a Structured Question Language utilized for overseeing and attending to information units. It will depend on the English language and is deliberate in a fashion to get well, management, and entry the knowledge effortlessly within the occasion that you just want to discover out in regards to the nuts and bolts of SQL prime to backside. In SQL, there are totally different statements/instructions used to regulate info. One such management, which could be very well-known in information units is renaming the column title in SQL.

On this means, allow us to comprehend easy methods to make the most of the RENAME command in SQL.

What’s RENAME command in SQL?

This command is utilized to vary the title of a column to a different column title. Altering the desk to a different desk title is likewise utilized. Enable us to understand easy methods to contain this or column in numerous information units. But, earlier than that, let’s take a look on the proven desk and perceive by taking it as our instance by showcasing the information of renaming instructions in SQL.

SID SName SUBJECT ROLL NO.
1 RICKY SHARMA SQL 2001
2 DAISY SINGH PYTHON 3502
3 SAMEER SETH MACHINE LEARNING 2503
4 POOJA SHARMA DEEP LEARNING 4504
5 NEHA AGARWAL RPA  3005

The best way to Rename column title in SQL?

Rename column title in MySQL, MariaDB, Oracle, and PostgreSQL

To rename a column title in MySQL, MariaDB, Oracle, and Postgre SQL, you possibly can observe the beneath syntax:

Syntax

ALTER TABLE TableName 
RENAME COLUMN OldColumnName TO NewColumnName:

Instance:

Write a question to rename the column title “SID” to “StudentsID”.

ALTER TABLE College students:

RENAME COLUMN SID TO StudentsID;

On executing the above question, you will notice the next output:

StudentsID SName SUBJECT ROLL NO.
1 RICKY SHARMA SQL 2001
2 DAISY SINGH PYTHON 3502
3 SAMEER SETH MACHINE LEARNING 2503
4 POOJA SHARMA DEEP LEARNING 4504
5 NEHA AGARWAL RPA  3005

Rename column title in MS SQL Server

The method of renaming column title is MS SQL Server is totally different when in comparison with the opposite databases. In MS SQL Server, it’s important to use the saved process referred to as sp_rename.

Syntax

sp_rename 'TableName.OldColumnName', 'New ColumnName', 'COLUMN';

Instance:

sp_rename ‘College students.SID’, ‘StudentsID’, ‘COLUMN’;

Write a question to rename the column title “SID” to “StudentsID”.

The ensuing output would be the similar as that for the above queries.

With that, we attain a conclusion to this text on Rename column title in SQL. I need to imagine that you just discovered this text instructional. I need to imagine that you just comprehended easy methods to make the most of the above instructions.

Similar Posts

Leave a Reply

Your email address will not be published.