重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 268|回复: 0
打印 上一主题 下一主题

[Oracle] Flashback Queries Are Failing With ORA-1031

[复制链接]
跳转到指定楼层
楼主
发表于 2025-11-16 17:59:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
现象:
When enabling flashback data archive mode on a table, the users should be able to flashback query the table as long as they have the SELECT and FLASHBACK privileges for the table. However, this
does not work:

conn / as sysdba

drop user flash cascade;
drop user flash2 cascade;

create user flash identified by flash;
create user flash2 identified by flash2;

grant connect, resource to flash,flash2;
grant flashback any table to flash2;
create table flash.test(col1 number, col2 varchar2(100));
grant select on flash.test to flash2;

create flashback archive default testflash tablespace users retention 1
month;

alter table flash.test flashback archive;


insert into flash.test values(1,'rec1');
insert into flash.test values(2,'rec2');
commit;

--restart the database to make sure that the old data is not in the UNDO tablespace anymore

conn flash2/flash2

select * from flash.test as of timestamp (systimestamp - interval '1' minute);
select * from flash.test as of timestamp (systimestamp - interval '1' minute)
*
ERROR at line 1:
ORA-01031: insufficient privileges


原因:
To be able to use the flashback query feature, when the historical data must be retrieved from the archive data tables rather than from the UNDO tablespace, an user must be able to query the flashback archive tables. The privileges to read these flashback archive tables must be managed internally. However this does not happen. The problem was diagnosed in Bug 8791750 - SELECT AS OF TIMESTAMP FAILS WITH ORA-1031


处理方法:
The problem can be solved if  Patch 8791750 is installed. This bug 8791750 fix is included in 11.2.0.2 and 12.1 DB

If there is no patch available then we can temporarily grant "SELECT ANY TABLE" to the user executing the flashback query or we can grant directly the SELECT privilege on the three archive tables created for the table on which we enabled the flashback queries.

To find out the tables one has to do the following :

SQL> select * from sys_fba_trackedtables where obj# > 0;


OBJ# FA# DROPSCN OBJNAME OWNERNAME FLAGS SPARE
---- --- ------- ------- --------- ----- -----
62697 1  0       EMP     FLASH     0

Get the obj# from the above query and then run:

select table_name from dba_tables where table_name like 'SYS_FBA%<obj#>';

SQL> select table_name from dba_tables where table_name like 'SYS_FBA%62697';

TABLE_NAME
------------------------------
SYS_FBA_DDL_COLMAP_62697
SYS_FBA_TCRV_62697
SYS_FBA_HIST_62697

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2026-4-17 22:17 , Processed in 0.252919 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表