Solved

Swap column name from MGR to MGR_NAME

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Pl/SQL Query 31 62
Calculating percentages per course - Oracle Query 3 28
oracle rollup query 3 38
PL/SQL - Leading zeros 7 41
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

759 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

21 Experts available now in Live!

Get 1:1 Help Now