作者:Digital Observer(施嘉伟)
Oracle ACE Associate: Database
PostgreSQL ACE Partner
11年数据库行业经验,现主要从事数据库服务工作
拥有Oracle OCM、DB2 10.1 Fundamentals、MySQL 8.0 OCP、WebLogic 12c OCA、KCP、PCTP、PCSD、OCI、PolarDB技术专家、达梦师资认证、数据安全咨询高级等认证
ITPUB认证专家、PolarDB开源社区技术顾问
国内某高校企业实践指导教师
公众号:Digital Observer;CSDN:施嘉伟;ITPUB:sjw1933;PGFans:施嘉伟。
Oracle database 23ai发布也有一段时间了,带来了许多具有亮点的新特性。那么今天我们来分享下oracle 23ai最明显的一个新特性。SQL*Plus输错命令你会明显的感觉到与之前版本不同了,下面带大家了解SQL*Plus的新特性!
操作系统版本 |
数据库版本 |
CentOS Linux release 8.0.1905 (Core) |
Oracle Database 23ai FREE |
Oracle 23ai 版本的 SQL*Plus 显示很多错误消息的帮助 URL。这些链接提供了错误消息的完整描述以及应对方法。
SQL> select * from shijw;
select * from shijw
*
ERROR at line 1:
ORA-00942: table or view "SHIJW"."SHIJW" does not exist
Help: https://docs.oracle.com/error-help/db/ora-00942/
SQL>
URL 的显示由 ERRORDETAILS 设置控制。设定范围值为 OFF、ON 和 VERBOSE,其中 ON 为默认值。
SQL> show errordetails
errordetails ON
SQL>
我们使用OFF参数时,URL就不会提示了
SQL> select * from shijw;
select * from shijw
*
ERROR at line 1:
ORA-00942: table or view "SHIJW"."SHIJW" does not exist
SQL>
如果我们设置VERBOSE将会显示有关错误的详细信息。
SQL> set errordetails verbose
SQL> select * from shijw;
select * from shijw
*
ERROR at line 1:
ORA-00942: table or view "SHIJW"."SHIJW" does not exist
Help: 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>
当然也可以通过环境变量ORA_SUPPRESS_ERROR_URL来实现ERRORDETAILS的值设置,设置为ON或OFF。
理想状态下应该是这样的:
export ORA_SUPPRESS_ERROR_URL=TRUE
SQL> show errordetails
errordetails OFF
SQL>
export ORA_SUPPRESS_ERROR_URL=FALSE
SQL> show errordetails
errordetails ON
SQL>
不过我执行下来,似乎有问题,不知道是不是bug。
[oracle@localhost admin]$ export ORA_SUPPRESS_ERROR_URL=TRUE
[oracle@localhost admin]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Production on Mon May 13 06:19:06 2024
Version 23.4.0.24.05
Copyright (c) 1982, 2024, Oracle. All rights reserved.
Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05
SQL> show errordetails
errordetails ON
SQL> exit
Disconnected from Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05
[oracle@localhost admin]$ export ORA_SUPPRESS_ERROR_URL=FALSE
[oracle@localhost admin]$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - Production on Mon May 13 06:19:25 2024
Version 23.4.0.24.05
Copyright (c) 1982, 2024, Oracle. All rights reserved.
Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05
SQL> show errordetails
errordetails ON
SQL>
PING 命令测试网络连接,其方式与tnsping实用程序类似。 没有其他参数,它会测试当前连接。[你可以理解为就是oracle将tnsping集成到了sqlplus里面,可以用ping代替tnsping命令]。这也是一个进步,我不用切窗口tnsping了。
SQL> ping 192.168.239.254
Local Net Naming configuration file: /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora
Attempting to contact: (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.239.254)(PORT=1521)))
SP2-1683: Ping failed with error TNS-12541.
Help: https://docs.oracle.com/error-help/db/sp2-1683/
SQL> ping
Ok (0.270 msec)
SQL> ping abc
Local Net Naming configuration file: /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora
Attempting to contact: (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = FREEPDB1)))
Ok (0.784 msec)
SQL>
当然如果存在多个监听服务的情况下我们也可以用来测试监听是否正常:
SQL> ping listener free
Local Net Naming configuration file: /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora
Attempting to contact: (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = FREE)))
Ok (0.868 msec)
之前大家知道OERR 命令可以显示指定错误消息的原因和操作。现在无论有或没有“-”分隔符,它都可以工作。
SQL> oerr ORA 00600
Message: "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
Help: https://docs.oracle.com/error-help/db/ora-00600/
Cause: This is the generic internal error number for Oracle program
exceptions. It indicates that a process has encountered a low-level,
unexpected condition. The first argument is the internal message
number. This argument and the database version number are critical in
identifying the root cause and the potential impact to your system.
SP2-0642: SQL*Plus internal error state 2590, context 45378:32768:0
Help: https://docs.oracle.com/error-help/db/sp2-0642/
Unable to proceed
SQL> oerr ORA-00600
Message: "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
Help: https://docs.oracle.com/error-help/db/ora-00600/
Cause: This is the generic internal error number for Oracle program
exceptions. It indicates that a process has encountered a low-level,
unexpected condition. The first argument is the internal message
number. This argument and the database version number are critical in
identifying the root cause and the potential impact to your system.
SP2-0642: SQL*Plus internal error state 2590, context 45378:32768:0
Help: https://docs.oracle.com/error-help/db/sp2-0642/
Unable to proceed

HELP命令,三种方式都可以执行出结果,效果一样与OERR
help 00600
help ora 00600
help ora-00600
Oracle 23ai 版本的 SQL*Plus 现在支持 BOOLEAN 数据类型。
SQL> select true, false from dual;
TRUE FALSE
----------- -----------
TRUE FALSE
大家认为 SQL*Plus 的这些新特性是否对日常工作带来比较大的帮助,欢迎评论区交流,欲知更多精彩内容,请关注下一期公众号!




原文作者:Digital Observer;如有侵权,请联系管理员删除。