建立oracle快照的步驟

Steven1981發表於2007-03-08
建立oracle快照的步驟[@more@]
1、 建立快照之前需要在sys使用者下執行catrep.sql(此操作需要一個大的回滾段), 並且給user授予CREATE ANY SNAPSHOT、ALTER ANY SNAPSHOT許可權
注:建立快照的兩端資料庫字符集最好一樣。

2、 user建立DBLINK
CREATE DATABASE LINK TEST CONNECT TO SCOTT IDENTIFIED BY TIGER USING ‘TEST’;

3、 user建快照
CREATE SNAPSHOT S_TEST
REFRESH COMPLETE START WITH SYSDATE NEXT SYSDATE+1/24
AS SELECT * FROM SCOTT.TEST@TEST ;

REFRESH語句具體語法如下:
REFRESH
specifies how and when Oracle automatically refreshes the snapshot:

FAST
specifies a fast refresh, or a refresh using only the updated data stored in the snapshot log associated with the master table.

COMPLETE
specifies a complete refresh, or a refresh that reexecutes the snapshot's query.

FORCE
specifies a fast refresh if one is possible or complete refresh if a fast refresh is not possible. Oracle decides whether a fast refresh is possible at refresh time.

If you omit the FAST, COMPLETE, and FORCE options, Oracle uses FORCE by default. See also "Refreshing Snapshots".

START WITH
specifies a date expression for the first automatic refresh time.

NEXT
specifies a date expression for calculating the interval between automatic refreshes.

Both the START WITH and NEXT values must evaluate to a time in the future. If you omit the START WITH value, Oracle determines the first automatic refresh time by evaluating the NEXT expression when you create the snapshot. If you specify a START WITH value but omit the NEXT value, Oracle refreshes the snapshot only once. If you omit both the START WITH and NEXT values, or if you omit the REFRESH clause entirely, Oracle does not automatically refresh the snapshot.


4、 更改快照
ALTER SNAPSHOT S_TEST
REFRESH COMPLETE START WITH SYSDATE NEXT SYSDATE+1/2;

5、 手動重新整理快照
EXEC DBMS_SNAPSHOT.REFRESH(‘S_TEST’ , ‘C’);
第一個引數是要重新整理的快照名
第二個引數是重新整理的方式,F----FAST, C---COMPLETE

6、 檢視快照最後重新整理的日期
SELECT NAME,LAST_REFRESH
FROM ALL_SNAPSHOT_REFRESH_TIMES;

[[i] Last edited by liuyy on 2005-10-10 at 14:28 [/i]]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/703656/viewspace-903362/,如需轉載,請註明出處,否則將追究法律責任。

相關文章