
はじめに
こんにちは。Oracle Databaseの検証チームです。
今回は、Oracle 23aiの新機能「エラー詳細の表示」をご紹介します。
Oracle DatabaseでSQLを操作していて、不意にエラーが出た時ドキッとしませんか。
エラーの原因が必ずあるにしろ、まだ経験が浅い筆者はどこから調べればよいのか分からず、
どこを調べればよいのかをまず調べるところから…ということもしばしばあります。
今回ご紹介する「エラー詳細の表示」機能はOracle Database 23aiから導入されました。
SQL*Plus接続中に得たエラーの解明の糸口にすることができると思います。

エラー出力の比較
今回はOracle Database 19cと23aiでSQL*PlusからORA-12154を発生させて比較します。
19cで存在しない接続文字列を指定してSQL*Plusに接続
[oracle@ora19c-singleDB ~]$
[oracle@ora19c-singleDB ~]$ sqlplus SYSTEM@dekirumon
SQL*Plus: Release 19.0.0.0.0 - Production on 木 4月 10 14:45:11 2025
Version 19.23.0.0.0
Copyright (c) 1982, 2023, Oracle. All rights reserved.
パスワードを入力してください:
ERROR:
ORA-12154: TNS: 指定された接続識別子を解決できませんでした
ユーザー名を入力してください: ^C
[oracle@ora19c-singleDB ~]$
19cでは、エラー番号と概要を得ることができました。
23aiで存在しない接続文字列を指定してSQL*Plusに接続
[oracle@basedb-tky admin]$ [oracle@basedb-tky admin]$ sqlplus SYSTEM@dekirumon SQL*Plus: Release 23.0.0.0.0 - for Oracle Cloud on 木 4月 10 14:44:40 2025 Version 23.4.1.24.06 Copyright (c) 1982, 2024, Oracle. All rights reserved. パスワードを入力してください: ERROR: ORA-12154: データベースに接続できません。別名dekirumon (/u01/app/oracle/product/23.0.0.0/dbhome_1/network/admin/tnsnames.ora内)が見つか りません。 ヘルプ: https://docs.oracle.com/error-help/db/ora-12154/ ★ ユーザー名を入力してください: ^C [oracle@basedb-tky admin]$
23aiでは、19c同様エラー番号と概要を得られたことに加え、URLが表示されました。
このURLを開くと、該当するエラーの詳細(原因や取るべきアクション)を確認することができます。
SET ERRORDETAILSについて
「エラー詳細の表示」機能は、出力内容をSET ERRORDETAILSで制御することができます。
SET ERRORDETAILSは、SQL*PlusでSQL、PL/SQLまたはSQL*Plus文の実行中に失敗したときに
Oracle Databaseエラー・ヘルプの原因、処置、URLの詳細が表示されるようにできます。
SET ERRORDETAILS { OFF | ON | VERBOSE }
ON | Oracle Databaseエラー・ヘルプのURLが表示される。デフォルトの設定。 |
---|---|
VERBOSE | Oracle Databaseエラー・ヘルプのURLと、エラー・メッセージの原因、処置、パラメータなどの詳細が表示される。 |
OFF | URLもその他のエラー・ヘルプ詳細も表示されなくなります。 |
設定値ごと実行結果は以下です。
- SET ERRORDETAILS ON
SQL> SET ERRORDETAILS ON SQL> SQL> select * from dekirumom; select * from dekirumon * 行1でエラーが発生しました。: ORA-00942: 表またはビュー "SYS"."DEKIRUMON"は存在しません ヘルプ: https://docs.oracle.com/error-help/db/ora-00942/ SQL>
- SET ERRORDETAILS VERBOSE
SQL> SET ERRORDETAILS VERBOSE SQL> SQL> select * from dekirumon; select * from dekirumon * 行1でエラーが発生しました。: ORA-00942: 表またはビュー "SYS"."DEKIRUMON"は存在しません ヘルプ: https://docs.oracle.com/error-help/db/ora-00942/ Cause: The specified table or view did not exist, or a synonym pointed to a table or view that did not exist. To find existing user tables and views, query the ALL_TABLES and ALL_VIEWS data dictionary views. Certain privileges may be required to access the table. If an application returned this message, then the table that the application tried to access did not exist in the database, or the application did not have access to it. Action: Check each of the following: - The spelling of the table or view name is correct. - The referenced table or view name does exist. - The synonym points to an existing table or view. If the table or view does exist, ensure that the correct access privileges are granted to the database user requiring access to the table. Otherwise, create the table. Also, if you are attempting to access a table or view in another schema, make sure that the correct schema is referenced and that access to the object is granted. Params: 1) object_name: The table or view name specified as SCHEMA.OBJECT_NAME, if one is provided. Otherwise, it is blank. SQL>
- SET ERRORDETAILS OFF
SQL> SET ERRORDETAILS OFF SQL> SQL> select * from dekirumon; select * from dekirumon * 行1でエラーが発生しました。: ORA-00942: 表またはビュー "SYS"."DEKIRUMON"は存在しません SQL>
OERRコマンド
OSコマンドとしてOERRコマンドは存在していましたが、23aiからはSQL*Plusでも使えるようになりました。
実際にエラーが発生していない状態でもOEERコマンドを実行すればエラーの詳細(原因や取るべきアクション)を表示できます。
- 実行例
SQL> OERR ORA-01081
Message: "cannot start already-running ORACLE - shut it down first"
ヘルプ: https://docs.oracle.com/error-help/db/ora-01081/
Cause: An attempt was made to start Oracle while it was already running.
Action: Shut down Oracle first, if you want to restart it.
SQL>
SQL> OERR SP2-0027
Message: "Input is too long (> %d characters) - line ignored\n"
Help: https://docs.oracle.com/error-help/db/sp2-00027/
Cause: The input value specified was too long.
Action: Re-enter with fewer characters.
SQL>
SQL> OERR TNS-12535
SP2-0160: unable to open "/u01/app/oracle/product/23.0.0.0/dbhome_1/network_src/mesg/tnsus.msg"
Help: https://docs.oracle.com/error-help/db/sp2-0160/
SQL>
おわりに
今回は、Oracle 23aiの新機能「エラー詳細の表示」をご紹介、検証してみました。
23aiにはそんな便利な機能があるんだ!と発見のお手伝いができていましたら幸いです。
最後までお読みいただきありがとうございました。
他の新機能もご紹介!
BIGFILE表領域の縮小機能を使ってみました!
SQL HISTORY(SQL履歴)を使ってみました!
お問い合わせはこちら!

投稿者プロフィール
