解决方案:在sqlnet.ora中设置SQLNET.OUTBOUND_CONNECT_TIMEOUT=60和SQLNET.INBOUND_CONNECT_TIMEOUT=60,然后重启监听器和数据库。
从百度知道
ORA-00166: remote/local nesting level is too deep 提示远程/本地嵌套层级过深,这是由于TNS Listener服务超时导致的。在sqlnet.ora中增加参数SQLNET.OUTBOUND_CONNECT_TIMEOUT=300和SQLNET.INBOUND_CONNECT_TIMEOUT=300,重启监听,重启数据库即可。
从CSDN博客
ORA-00166远程/本地嵌套层级过深 错误原因:由于db_link访问远程数据库时,远程数据库访问本数据库,形成了嵌套访问,导致循环嵌套层级过深。解决办法:1.使用dblink_authentication认证方式;2.在sqlnet.ora中设置SQLNET.ALLOWED_LGNM=REMOTE_OS_AUTHENT;3.使用数据库链接时指定认证用户。
从Oracle官方文档
The ORA-00166 error occurs when the nesting level of remote or local database links exceeds the maximum allowed. To resolve, reduce the nesting depth by redesigning the database link usage, or increase the nesting limit if possible, but primarily avoid deep nesting. For remote processing, use database links with proper authentication and timeouts.
从知乎讨论
修复ORA-00166的最简单方法是在监听配置中调整超时参数,sqlnet.ora添加:SQLNET.EXPIRE_TIME=10 SQLNET.OUTBOUND_CONNECT_TIMEOUT=180 重启监听器。远程方案是通过设置dblink的认证用户,避免循环调用。
从Stack Overflow
This error happens due to too many nested DB links. Solution: Break the chain of links or use a synonym or view on the remote side to flatten it. Also, set in sqlnet.ora: DIAG_ADR_ENABLED=OFF if needed, but main fix is architectural.
FAQ
Q: ORA-00166是什么原因?
A: 主要是数据库链接嵌套太深,或超时导致的循环嵌套。
Q: 只改sqlnet.ora够吗?
A: 通常够,但有时需要重设计链接结构避免深嵌套。
Q: 远程处理方案具体怎么做?
A: 使用DBLINK认证用户,如DBLINK_AUTHENTICATE='USERNAME',并设置超时参数。
Q: 重启什么服务?
A: 重启TNS监听器和相关数据库实例。