Oracle Rename Column Using ALTER Query & Rename Table Example


In Oracle, to rename a column in a table, use ALTER TABLE RENAME COLUMN statement.

Table of Contents

Alter table rename column in oracle table query

Alter table rename column in oracle table query

Oracle Rename Column table syntax:

  1. To rename a column in oracle we have to use rename column statement
  2. You have to use rename column statement along with alter table statement
  3. The RENAME COLUMN statement allows us to rename an existing column in an existing table in any schema (except the schema SYS).
ALTER TABLE
   table_name
RENAME COLUMN
old_column_name 
TO
new_column_name;

For example, we have an employee table which contains columns as id,name,email,date_hired and job columns

We will rename the email column to email_id

create table employees ( 
   id number not null, 
   name varchar2(50) not null, 
   email varchar2(255), 
   date_hired date, 
   job varchar2(255) 
)

Oracle Rename Column in a table query example

To rename a column in oracle table use the below query

ALTER TABLE
   employees
RENAME COLUMN
email 
TO
email_id;

Oracle Rename table name syntax:

To rename a table name in oracle use following query syntax

RENAME TABLE_NAME to NEW_TABLE_NAME:

Oracle Rename table query example:

The below query renames the table name employees to new table name

RENAME employees to emp;

To rename a column name or table name, you must be the database owner or the table owner.

Wait before leaving. why can’t you follow me on twitter or be a friend on Facebook or linkedn to get in touch with me.

Spread the word

Get free link to download 900+ Material Icons
Avatar
Arunkumar Gudelli

I am One among a million Software engineers of India. I write beautiful markup.I make the Web useful.

Related

Next
Previous