Solved

Swap column name from MGR to MGR_NAME

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

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…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now