Friday, 11 May 2018

Change a column name in PostgreSQL, MySql and SQL Server


I am often asked how to rename a column in an existing (SQL) table.

First of all I want to warn that one should be careful when changing column names in existing tables as the changes can affect scripts, functions and procedures written for the database.

The queries to change column names are fairly easy to understand, but the syntax used for SQL Server, MySQL and PostgreSQL differs from each other..

The basic queries for the three database systems are as follows:

PostgreSQL



MySQL




SQL Server



Example:


The queries will be as follows:

PostgreSQL


MySQL


SQL Server


The result:



No comments:

Post a Comment