关于创建materialized view 的问题

zdljj 2008-09-23 09:30:30
create materialized view MEDIA_TYPE
pctfree 10
pctused 40
initrans 1
maxtrans 255
tablespace MYDATA
storage
(
initial 32M
minextents 1
maxextents unlimited
)
refresh complete on demand
enable query rewrite
AS
select * FROM alert_entries a ,mapping b
WHERE to_char(a.creationdate, 'yyyymmdd') = to_char(SYSDATE-1,'yyyymmdd') ;
ORA-01031: insufficient privileges

当我执行如下命令时候就没有问题
create materialized view MEDIA_TYPE
tablespace MYDATA
AS
select * FROM alert_entries a ,mapping b
WHERE to_char(a.creationdate, 'yyyymmdd') = to_char(SYSDATE-1,'yyyymmdd') ;

搞不清楚是为什么。就算那段可以执行的程序在一个package中调用。有一台服务器正常另外台也会报ORA-01031: insufficient privileges。那位清楚是什么问题造成的权限问题。
...全文
274 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cosio 2008-09-27
  • 打赏
  • 举报
回复
ORA-01031 insufficient privileges

Cause: An attempt was made to change the current username or password without the appropriate privilege. This error also occurs if attempting to install a database without the necessary operating system privileges.

Action: Ask the database administrator to perform the operation or grant the required privileges.


应该没有权限
grant !
liuyi8903 2008-09-27
  • 打赏
  • 举报
回复
以上来自metalink Note:176213.1
liuyi8903 2008-09-27
  • 打赏
  • 举报
回复
Materialized View's defining query can not contain references to non-repeating
expressions like SYSDATE and ROWNUM when using options like QUERY REWRITE or
FAST REFRESH.


Create a Materialized View on a Pre-built table which includes a date field
defaulted to the SYSDATE.

The table must have the same name and be in the same schema as the resulting
Materialized View.

If the Materialized View is dropped, the pre-existing table reverts to its
identity as a table.

Example:
-------
-- Create a Pre-built table including a date field defaulted to SYSDATE

create table scott.semp
(empno number(4) primary key,
ename varchar2(10),
sdate date default SYSDATE;

-- Create a Materialized View on a Pre-built table

create materialized view scott.semp
on prebuilt table
as select empno,ename from scott.emp;

-- In case of a fast refresh, this workaround will only work for inserted rows
-- but not for updated rows. Create a Trigger for Update to workaround.

create materialized view scott.semp
on prebuilt table
refresh fast
as select empno,ename from scott.emp;

create or replace trigger scott.semp_update
before update on scott.semp
for each row
declare
sdate date := sysdate;
begin
:new.sdate := sdate;
end;
Remarks:
-------
The ON PREBUILT TABLE clause just registers an existing table as a
pre-initialized Materialized View that means that a complete refresh of the
master table is NOT done automatically.



17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧