Solved

Swap column name from MGR to MGR_NAME

Posted on 2008-10-18
3
324 Views
Last Modified: 2013-12-19
Hi,

Empno has number data type, not null. MRG_NAME has number data type.

I changed this:

ALTER TABLE EMP RENAME COLUMN MGR TO MGR_NAME;

SELECT empno, ename, hiredate, mgr_name(empno)
FROM emp;

I want MGR_Name to display with empno.

Return, I got "MGR_NAME" invalid identifier.

Any advice is appreciated?
0
Comment
Question by:suredazzle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 1

Accepted Solution

by:
suredazzle earned 0 total points
ID: 22750860
After reading my book.
Verified the result is correct.

Need to add new column.


SQL> SELECT empno, ename, hiredate, mgr_name
FROM emp
WHERE empno NOT IN
    (SELECT mgr_name FROM emp
    WHERE mgr_name IS NOT NULL);

==========================================

     EMPNO ENAME      HIREDATE        MGR_NAME
---------- ---------- --------- ----------
      7782 CLARK      09-JUN-81       7839
      7654 MARTIN     28-SEP-81       7698
      7499 ALLEN      20-FEB-81       7698
      7844 TURNER     08-SEP-81       7698
      7900 JAMES      03-DEC-81       7698
      7521 WARD       22-FEB-81       7698
      7369 SMITH      17-DEC-80       7902
      7876 ADAMS      12-JAN-83       7788
      1456 JOHN SMITH 01-JAN-02       7566



0
 
LVL 1

Author Comment

by:suredazzle
ID: 22790851
Insert row into emp with deptno null.

Foreign key constraint of deptno in emp.

Best to re-create table emp2 and emp2.self_key. Delete constraint emp_foreign_key line.

Also, you can disable the column constraint.
0
 
LVL 1

Author Comment

by:suredazzle
ID: 22805313

Use self-join for 2 diff. table aliases, treat EMP like 2 separate tables.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question