在Oracle 10gR2中设定指定的恢复点实现轻松闪回
欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 Oracle href="http://search.e800.com.cn/Oracle" target=_blank alt="Oracle"> Oracle 9i引入的闪回查询功能显示前一个时间点的查询结果。但是,表本身并没有改变。 Oracle 10g 增强了闪回功能,可
欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入
Oracle href="http://search.e800.com.cn/Oracle" target=_blank alt="Oracle">Oracle 9i引入的闪回查询功能显示前一个时间点的查询结果。但是,表本身并没有改变。Oracle 10g增强了闪回功能,可以永久闪回一个表格。现在Oracle 10g第二版通过增加指定的恢复点,使这一过程更加方便。
存储
应用恢复点不必知道准确的SCN。恢复点建立后,它即恢复当前SCN。因此,使用恢复点名称等同于使用对应的SCN。
CREATE RESTORE POINT(创建恢复点)命令的语法很简单:
CREATE RESTORE POINT restore_point_name;
FLASHBACK ANY TABLE或SELECT ANY DICTIONARY权限需要建立一个正常(无保证)的恢复点。一旦恢复点不再需要,对应的DROP RESTORE POINT命令就将它删除。
列表A显示向OE模式提供的正确许可,建立一个恢复点,然后在一个错过正确WHERE子句的错误UPDATE后建立一个FLASHBACK TABLE。
<br>SQL> CONNECT / AS SYSDBA<br><br>Connected.<br><br>SQL> GRANT SELECT ANY DICTIONARY TO oe; <br>Grant succeeded. <br>SQL> CONNECT OE/OE<br><br>Connected. <br>SQL> -- Tables must have row movement enabled to flash back<br><br>SQL> ALTER TABLE warehouses 2 ENABLE ROW MOVEMENT; <br>Table altered. <br>SQL> CREATE RESTORE POINT my_update; <br>Restore point created. <br>SQL> COLUMN name FORMAT a25<br><br>SQL> COLUMN time FORMAT a32<br><br>SQL> <br>SQL> SELECT name, scn, time, <br>guarantee_flashback_database 2 FROMv$restore_point; <br>NAME SCN TIME GUA <br><br>------------------------- ---------- ------------------------------ <br><br>MY_UPDATE 734934 10-AUG-06 03.32.29.000000000 PM NO <br>SQL> UPDATE warehouses 2 SET warehouse_name = ''Bellevue, WA''; <br>9 rows updated. <br>SQL> COMMIT; <br>Commit complete. <br>SQL> SELECT warehouse_id, warehouse_name 2 FROM warehouses; <br>WAREHOUSE_ID WAREHOUSE_NAME <br><br>------------ ----------------------------------- <br>1 Bellevue, WA 2 Bellevue, WA 3 Bellevue, WA 4 Bellevue, <br>WA 5 Bellevue, WA 6 Bellevue, WA 7 Bellevue, WA 8 Bellevue,<br>WA 9 Bellevue, WA 9 rows selected.SQL> CONNECT / AS SYSDBA Connected.<br><br>SQL> GRANT SELECT ANY DICTIONARY TO oe; <br>Grant succeeded. <br>SQL> CONNECT OE/OE<br><br>Connected. <br>SQL> -- Tables must have row movement enabled to flash back<br><br>SQL> ALTER TABLE warehouses 2 ENABLE ROW MOVEMENT; <br>Table altered. <br>SQL> CREATE RESTORE POINT my_update; <br>Restore point created. <br>SQL> COLUMN name FORMAT a25<br><br>SQL> COLUMN time FORMAT a32<br><br>SQL> <br>SQL> SELECT name, scn, time, <br>guarantee_flashback_database 2 FROMv$restore_point; <br>NAME SCN TIME GUA <br><br>------------------------- ---------- ------------------------------- <br><br>MY_UPDATE 734934 10-AUG-06 03.32.29.000000000 PM NO <br>SQL> UPDATE warehouses 2 SET warehouse_name = ''Bellevue, WA''; <br>9 rows updated. <br>SQL> COMMIT; <br>Commit complete. <br>SQL> SELECT warehouse_id, warehouse_name 2 FROM warehouses; <br>WAREHOUSE_ID WAREHOUSE_NAME <br><br>------------ -----------------------------------<br>1 Bellevue, WA 2 Bellevue, WA 3 Bellevue, <br>WA 4 Bellevue, WA 5 Bellevue, WA 6 Bellevue, WA 7 Bellevue,<br>WA 8 Bellevue, WA 9 Bellevue, WA 9 rows selected. <br>SQL> FLASHBACK TABLE warehouses 2 TO RESTORE POINT my_update; <br>Flashback complete. <br>SQL> SELECT warehouse_id, warehouse_name 2 FROM warehouses; <br>WAREHOUSE_ID WAREHOUSE_NAME <br><br>------------ ----------------------------------- <br>1 Southlake, Texas 2 San Francisco 3 New Jersey 4 Seattle, <br>Washington 5 Toronto 6 Sydney 7 Mexico City 8 Beijing 9 Bombay <br>9 rows selected.<br><br> <br>SQL> FLASHBACK TABLE warehouses 2 TO RESTORE POINT my_update; <br>Flashback complete. <br>SQL> SELECT warehouse_id, warehouse_name 2 FROM warehouses; <br>WAREHOUSE_ID WAREHOUSE_NAME <br><br>------------ ----------------------------------- <br>1 Southlake, Texas 2 San Francisco 3 New Jersey 4 Seattle, <br>Washington 5 Toronto 6 Sydney 7 Mexico City 8 Beijing 9 Bombay <br>9 rows selected. Copy after login |
列表A
恢复点存储在控制文件中,所以即使数据库关闭(安装好,但未开),它们仍然有效。这意味着你还可在FLASHBACK DATABASE命令中使用它们。
作者:Bob Watkins(OCP、MCDBA、MCSE、MCT)是一位有25年经验的计算机专业人士,从事过技术培训师、顾问与数据库管理员等职。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.
