Blog

Blog

How To Rename a Column Name in SQL?

Rename a Column Name in SQL

Rename a Column Name in SQL

In this Article you will learn about

How To Rename a Column Name in SQL?

Renaming a column in a table in SQL is a simple task that can be accomplished using the ALTER TABLE statement and the RENAME COLUMN clause.

Here’s an example of how to use these statements to rename a column in a table called customers:

CREATE TABLE customers (
    customer_id INTEGER PRIMARY KEY,
    customer_name VARCHAR(255),
    phone_number VARCHAR(255),
    address VARCHAR(255)
);

This code creates a table called customers with four columns: customer_id, customer_name, phone_number, and address

The customers table will have the following structure:

customer_idcustomer_namephone_numberaddress

Query To Rename the Column name is :

ALTER TABLE customers
RENAME COLUMN customer_name TO full_name;

Now it renames the customer_name column to full_name.

After running the above code,

the customers table After rename will have the following structure :

customer_idfull_namephone_numberaddress

Note that the syntax for renaming a column may vary slightly depending on the database you are using. Consult the documentation for the specific database you are using for more information.

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare

Subscribe to Newsletter

Stay ahead of the rapidly evolving world of technology with our news letters. Subscribe now!