[Oracle] column ambiguously defined / must name this expression with a column alias

    춘대학 DML 3번 문제

     

    오류 1

    [오류문구]

    column ambiguosly defined 

     

    1. WHERE절의 오타

    2. TB_DEPARTMENT과 TB_PROFESSOR 테이블에 DEPARTMENT_NO가 동일하여 이 어떤 컬럼인지 명확하게 명시하라는 오류가 뜬다.

    더보기

    The solution is quite simple: you will have to expand the projection to explicitly select named columns. Then you can either leave out the duplicate columns, retaining just (say) COACHES.ID or use column aliases: coaches.id as COACHES_ID.

     

    출처 - stackoverflow.com/questions/6233086/ora-00918-column-ambiguously-defined-in-select

     

     

    오류 2

    [오류문구]

    ORA-00998: must name this expression with a column alias

     

    * 서브쿼리 SELECT 절에 산술식 또는 함수식 기술된 경우에 반드시 별칭 지정해야됨

    더보기

    An expression or function was used in a CREATE VIEW statement, but no corresponding column name was specified. When expressions or functions are used in a view, all column names for the view must be explicitly specified in the CREATE VIEW statement.

     

    => 답변은 뷰를 생성하는 구문에 대한 것이지만, 대충 요런 늑김 

     

    출처 - stackoverflow.com/questions/42326426/ora-00998-must-name-this-expression-with-a-column-alias

     

     

    성공 ! 

     


    배운점

    1. 오타를 잘 확인하자

    2. 이제부터라도 USING 구문 대신 ON 구문을 사용하자 ( 현업에서 USING ~ ON 구문을 더 많이 사용한다고 함 )

    3. 테이블 별칭(?) TB_DEPARTMENT D, TB_PROFESSOR P < 습관화하자 ! 

    4. 서브쿼리 사용시 SELECT문에 기술된 함수/산술식에는 별칭을 부여하자 

    728x90

    댓글