Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I rename my column in a SQL table?

How can I rename a column via alter table in MS SQL 2005?

For example:

alter table tablename rename "old col name" to "new col name"
like image 485
ALEXALEXIYEV Avatar asked Jun 17 '10 08:06

ALEXALEXIYEV


People also ask

How do I rename a column in SQL?

You select the table with ALTER TABLE table_name and then write which column to rename and what to rename it to with RENAME COLUMN old_name TO new_name .

How do I rename a single column?

If you want to rename a single column, just pass the single key-value pair in the columns dict parameter. The result will be the same if there is a non-matching mapping in the columns dictionary.

Can a column name be renamed?

The columns can also be renamed by directly assigning a list containing the new names to the columns attribute of the Dataframe object for which we want to rename the columns.


1 Answers

sp_rename 'TableName.ColumnName', 'NewColumnName', 'COLUMN'
like image 172
Cambium Avatar answered Oct 13 '22 03:10

Cambium