SQL ALTER (RENAME)

Changing the table name to a relevant name can be needed often in the databases. Not only the table but the column names can be also changed as per the added information. For the same, we can use ALTER (RENAME) in SQL to rename the names of tables or columns. The ways of altering or changing the table can differ in each database.

  • Syntax of ALTER TABLE (To RENAME table) –

ALTER TABLE table_name RENAME TO new_table_name;

 

  • Syntax of ALTER TABLE (To RENAME column name) –

ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;

Demo Table –

Product Table

Category Region City Country Customer_ID Customer_name
Technology West Aurora United States TP-21565 Tracy Poddar
Office Supplies West Aurora United States TP-21565 Tracy Poddar
Office Supplies West Pasadena United States HA-14920 Helen Andreada
Furniture West Pasadena United States HA-14920 Helen Andreada
Office Supplies West Mesa United States HJ-14875 Heather Jas

Example – Consider the Product table of the Customer database where we have to change the column name from “Customer Name” To “Name” using ALTER (RENAME).

ALTER TABLE [dbo].[Products] RENAME COLUMN [Customer Name] TO [Name];

Other SQL topics to check out:

Follow us on TwitterFacebookLinkedin, and Tableau Public to stay updated with our latest blog and what’s new in Tableau.

Automate data analysis pipeline and create report ready dashboards

If you are looking forward to getting your data pipeline built and setting up the dashboard for business intelligence, book a call now from here.

#analytics #data #business #artificialintelligence #machinelearning #startup #deeplearning #deeplearning #datascience #ai #growth #dataanalytics #india #datascientist #powerbi #dataanalysis #tableau #SQL #businessanalytics #businessanalyst #businessandmanagement #dataanalyst #businessanalysis #analyst #analysis #powerbideveloper #powerbidesktop #letsviz

Established in 2020, Lets Viz Technologies provides a full range of high-quality data analysis and data visualization services. We are also an authorized Zoho Partner.

 

Contact

WeWork Berger Delhi One, C-001/A2, Sector 16B, Noida, Uttar Pradesh 201301

0124-502-5592
info@lets-viz.com

We are Social

Trust Pilot Reviews