

Nupur Dave is a social media enthusiast and an independent consultant.
#Sql rename column free#
If you need help with any SQL Server Performance Tuning Issues, please feel free to reach out at is also a CrossFit Level 1 Trainer (CF-L1) and CrossFit Level 2 Trainer (CF-L2).
#Sql rename column professional#
Pinal is an experienced and dedicated professional with a deep commitment to flawless customer service. To freely share his knowledge and help others build their expertise, Pinal has also written more than 5,500 database tech articles on his blog at. Pinal has authored 13 SQL Server database books and 40 Pluralsight courses. He holds a Masters of Science degree and numerous database certifications. The ID column will contain an integer type value representing the primary key of a table that must not. Within this table, we will have two columns ID and Name. Therefore, we have been making a table titled Test within our current SQLite database with the CREATE TABLE instruction. Pinal Dave is an SQL Server Performance Tuning Expert and independent consultant with over 17 years of hands-on experience. To rename a column, we must have a table in the database. You can see the same data now available in new table named “Table_Last” To check that the new renamed table exist in database run script: The Messages shows an error “Invalid object name ‘Table_First’.” “Table_First” will no longer be available in database.

Now, the table name “Table_First” is renamed as “Table_Last”. We can change the table name too with the same command.įollowing fig. verify that the column name has been changed. You can see the column name “Name” is now changed to “ NameChange“.įollowing fig. Name', ' NameChange', 'COLUMN'įollowing Fig. Now, to change the Column Name from “Name” to “ NameChange” we can use command: A small table with name “ Table_First” is created. Renaming database table column to new name.Įxample uses AdventureWorks database. In both the cases we will first see existing table. Renaming database table column to new name.This article demonstrates two examples of renaming database object. The syntax of sprename is the following: exec sprename ‘tablename.ColumnName’, ‘NewColumnName’, ‘column’ objecttype. Syntax (Oracle,MySQL,MariaDB): ALTER TABLE tablename RENAME TO newtablename Columns can be also be given new name with the use of ALTER TABLE. The script for renaming any object (table, sp etc) : In order to rename a column name, you must use sprename. For this purpose we can use ALTER TABLE to rename the name of table. The RENAME COLUMN statement allows you to rename an existing column in an existing table in. Here is a video demonstrating the discussion Use the RENAME COLUMN statement to rename a column in a table. I often get requests from blog reader for T-SQL script to rename database table column name or rename table itself.
