ORA-00918: column ambiguously defined(列の定義が曖昧)
Oracle意味
クエリ内の複数のテーブルに同じ名前の列があり、テーブル/別名の接頭辞なしで使われているため、Oracle はどのテーブルに属するか判断できない。
原因
結合された両方のテーブルに同じ名前の列がある (例: 両方に ID)、その列が SELECT、WHERE、ORDER BY で修飾なし (接頭辞なし) で使われている。
対処方法
曖昧な列はすべてテーブル名または別名で修飾する: SELECT a.id, b.id FROM tableA a JOIN tableB b ON a.id = b.a_id; テーブルに短い別名を付け、すべての列に接頭辞を付けて可読性と明確さを高める。
同じデータベースの他の項目
- ORA-02291integrity constraint violated - parent key not found(整合性制約違反 - 親キーがない)
- ORA-02292integrity constraint violated - child record found(整合性制約違反 - 子レコードがある)
- ORA-00979not a GROUP BY expression(GROUP BY の式ではない)
- ORA-06550line/column PLS-... PL/SQL コンパイルエラー
- ORA-04068existing state of packages has been discarded(パッケージの既存の状態が破棄された)
- ORA-01427single-row subquery returns more than one row(単一行副クエリが複数行を返した)
- ORA-12899value too large for column(列に対して値が大きすぎる)