Solved

Swap column name from MGR to MGR_NAME

Posted on 2008-10-18
3
323 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

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

749 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