Solved

Swap column name from MGR to MGR_NAME

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

776 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