Waseem Mubasher
Waseem Mubasher

Reputation: 47

How to rename a column in a query in ORACLE

Is this query right for changing the name of a column in the employees table:

select first_name, rename_column('first_name' to 'empName') from employees;

Upvotes: 2

Views: 22973

Answers (5)

DIPAK SHAH
DIPAK SHAH

Reputation: 41

ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;

Upvotes: 0

Megha Shukla
Megha Shukla

Reputation: 21

   alter table employee
rename column first_name  to emp_name ;

Upvotes: 1

ravi chaudhary
ravi chaudhary

Reputation: 625

there are two ways 1) give alias name to the column

 SELECT first_name AS emp_name 
 FROM employee;

2) change column name

   alter table employee
rename first_name  to emp_name ;

Upvotes: 5

Theo Müller
Theo Müller

Reputation: 45

If you are going to change the name just in your current result-set, you can do following:

select first_name AS emp_name from employees;

if you are going to change the name permanently, you have to work with ALTER TABLE:

ALTER TABLE employees CHANGE first_name emp_name VARCHAR2(255);

Upvotes: -2

Linger
Linger

Reputation: 15068

To set an alias for a field use the following:

SELECT first_name AS "empName", hire_date AS "Tenure On December 31 2014"
FROM employees;

Upvotes: 2

Related Questions