简体   繁体   English

SQL--尝试将查询结果导出为 CSV 时出错

[英]SQL--— Error when trying to export query results as CSV

I am running a large query (6 million records) which has a lot of INNER JOINS with other tables but when I am trying to export the query results on CSV I am getting the following results.我正在运行一个大型查询(600 万条记录),它与其他表有很多 INNER JOINS,但是当我尝试将查询结果导出到 CSV 时,我得到以下结果。 I googled it for a while but could not get any result.我用谷歌搜索了一段时间,但没有得到任何结果。

ORA-01555: snapshot too old: rollback segment number 69 with name
"_SYSSMU69_2356811035$" too small
ORA-0263: "snapshot too old: rollback segment number %s with name \"%s\" too small" 
*Cause: rollback records needed by a reader for consistent read are overwritten by other writers
*Action:  If in Automatic Undo Management mode, increase undo_retention setting. Otherwise, rollback segments 
Vendor code 1555

Let me explain you what happens.让我解释一下会发生什么。 When Oracle executes a query, the result of the query, no matter how much time the query takes, must be consistent with the picture of that data at the moment the query was initiated.当 Oracle 执行查询时,查询的结果,无论查询花费多少时间,都必须与查询开始时该数据的图片一致。

The ORA-1555 errors can happen when a query is unable to access enough undo to build a copy of the data at the time the query started. ORA-1555 错误可能发生在查询无法访问足够的撤消权限以在查询开始时构建数据副本时。 Committed "versions" of blocks are maintained along with newer uncommitted "versions" of those blocks so that queries can access data as it existed in the database at the time of the query.已提交的块“版本”与这些块的较新的未提交“版本”一起维护,以便查询可以访问在查询时存在于数据库中的数据。 These are referred to as "consistent read" blocks and are maintained using Oracle undo management.这些被称为“一致读取”块,并使用 Oracle 撤消管理进行维护。

This consistency is handled by the UNDO tablespace.这种一致性由 UNDO 表空间处理。 In your case, the most probable scenario is the following:在您的情况下,最可能的情况如下:

  • The query that runs the csv is started at one moment in time.运行 csv 的查询在某一时刻启动。 Oracle runs the query to get the 6 million rows that were in those tables at that moment in time. Oracle 运行查询以获取当时这些表中的 600 万行。
  • During the execution of the query, several other processes are running DML operations against the affected records, therefore the data that was before is moved to the UNDO tablespace ( Rollback segments is the type of the segments stored on the UNDO tablespace )在查询执行期间,其他几个进程正在对受影响的记录运行 DML 操作,因此之前的数据被移动到 UNDO 表空间(回滚段是存储在 UNDO 表空间上的段的类型)
  • However, if your undo is small or your undo_retention is not enough, in order to preserve the integrity of the database, Oracle will overwrite those rollback segments with new ones if there is no enough space on that tablespace.但是,如果您的 undo 很小或您的 undo_retention 不够,为了保持数据库的完整性,如果该表空间上没有足够的空间,Oracle 将用新的回滚段覆盖这些回滚段。

Try the following things:尝试以下几点:

  • Increase undo tablespace增加撤销表空间
  • Increase undo_retention parameter.增加 undo_retention 参数。

There are a plethora of bugs in old Oracle versions related with ORA-1555, and other possibilities when undo data are lob segments, etc.. If you have access to Support, here you will find the master note ORA-1555相关的旧Oracle版本有很多bug,还有其他可能是undo数据是lob段等。

ORA-1555 Master Note ORA-1555 主注

ORA-1555 Diagnosis and Troubleshooting ORA-1555 诊断和故障排除

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM