oracle9204(9i)_logical standby_ddl_related
Performing DDL on a Logical Standby Database
This section describes how to add an index to a table maintained through SQL apply operations.
By default, only accounts with SYS privileges can modify the database while the database guard is set to ALL or STANDBY. If you are logged in as SYSTEM or another privileged account, you will not be able to issue DDL statements on the logical standby database without first bypassing the database guard for the session.
The following example shows how to stop log apply services, bypass the database guard, execute SQL statements on the logical standby database, and then reenable the guard:
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
Database altered.
SQL> EXECUTE DBMS_LOGSTDBY.GUARD_BYPASS_ON;
PL/SQL procedure successfully completed.
SQL> ALTER TABLE SCOTT.EMP ADD CONSTRAINT EMPID UNIQUE (EMPNO);
Table altered.
SQL> EXECUTE DBMS_LOGSTDBY.GUARD_BYPASS_OFF;
PL/SQL procedure successfully completed.
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
Database altered.
This sample procedure could be used to execute other DDL statements. Oracle Corporation recommends that you do not perform. DML operations while the database guard bypass is enabled. This will introduce deviations between the primary and standby databases that will make it impossible for the logical standby database to be maintained. It is unlikely that you will be able to modify rows in a table in such a way that the logical standby database can incrementally maintain the rows.
9.1.3.2 Modifying Tables That Are Not Maintained by SQL Apply
Sometimes, a reporting application must collect summary results and store them temporarily or track the number of times a report was run. Although the main purpose of an application is to perform. reporting activities, the application might need to issue DML (insert, update, and delete) operations on a logical standby database. It might even need to create or drop tables.
You can set up the database guard to allow reporting operations to modify data as long as the data is not being maintained through SQL apply operations. To do this, you must:
- Specify the set of tables on the logical standby database to which an application can write data by executing the DBMS_LOGSTDBY.SKIP procedure. Skipped tables are not maintained through SQL apply operations.
- Set the database guard to protect only standby tables. This setting describes the list of tables that the logical standby database is maintaining. The list cannot include the tables to which your application will be writing.
In the following example, it is assumed that the tables to which the report is writing are also on the primary database.
The example stops SQL apply operations, skips the tables, and then restarts SQL apply operations so that changes can be applied to the logical standby database. The reporting application will be able to write to MYTABLES% in MYSCHEMA. They will no longer be maintained through SQL apply operations.
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
Database altered.
SQL> EXECUTE DBMS_LOGSTDBY.SKIP('SCHEMA_DDL','MYSCHEMA','MYTABLES%');
PL/SQL procedure successfully completed.
SQL> EXECUTE DBMS_LOGSTDBY.SKIP('DML','MYSCHEMA','MYTABLES%');
PL/SQL procedure successfully completed.
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
Database altered.
The example then queries the DBA_LOGSTDBY_PARAMETERS view to verify the logical standby database is updated. Verification can take a while so you might need to repeat the query until no rows are returned, as shown in the following example:
SQL> SELECT NAME FROM DBA_LOGSTDBY_PARAMETERS WHERE NAME = 'EVALUATE_SKIP';
no rows selected
Finally, the example sets the database guard to allow updates to the tables.
SQL> ALTER DATABASE GUARD STANDBY;
Database altered.
9.1.4 Handling Triggers and Constraints on a Logical Standby Database
Triggers and constraints are enabled on the standby database but they are not executed. For triggers and constraints on tables maintained through SQL apply operations, constraints are evaluated on the primary database and do not need to be re-evaluated on the logical standby database. The effects of the triggers executed on the primary database are logged and applied on the standby database. Triggers will be fired and constraints will be evaluated on tables not maintained through SQL apply operations.
9.1.5 Skipping SQL Apply Operations on a Logical Standby Database
If only a subset of activity on a primary database is of interest on the standby database, use the DBMS_LOGSTDBY.SKIP procedure to define filters that prevent log apply services from issuing the SQL statements on the logical standby database. (See for information about SQL statements that are skipped automatically.)
Tables continue applying SQL statements after filtering out unsupported datatypes or statements automatically. However, you must use the DBMS_LOGSTDBY.SKIP procedure to skip tables that you do not want to apply to the logical standby database. The following list shows typical examples of the types of SQL statements that can be filtered or skipped so that they are not applied on the logical standby database:
- DML or DDL changes for tables
- CREATE, ALTER, or DROP INDEX DDL statements
- CREATE, ALTER, DROP, or TRUNCATE TABLE statements
- CREATE, ALTER, or DROP TABLESPACE statements
- CREATE or DROP VIEW statements
demonstrates how to skip all SQL apply operations that reference the EMP table in a logical standby database.
Example 9-1 Skipping a Table in a Logical Standby Database
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;
SQL> EXECUTE DBMS_LOGSTDBY.SKIP('SCHEMA_DDL', 'SCOTT', 'EMP', NULL);
SQL> EXECUTE DBMS_LOGSTDBY.SKIP('DML', 'SCOTT', 'EMP', NULL);
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
In addition to skipping DML and DDL statements for schema and non-schema operations, you can also skip specific DML and DDL operations as well. shows how to skip ALTER TABLESPACE and CREATE TABLESPACE for non-schema DDL operations.
Example 9-2 Skipping ALTER or CREATE TABLESPACE Statements
SQL> EXEC DBMS_LOGSTDBY.SKIP(`CREATE TABLESPACE', NULL, NULL, NULL);
SQL> EXEC DBMS_LOGSTDBY.SKIP(`ALTER TABLESPACE', NULL, NULL, NULL);
SQL> COLUMN ERROR FORMAT a5;
SQL> COLUMN STATEMENT_OPT FORMAT a20;
SQL> COLUMN OWNER FORMAT a10
SQL> COLUMN NAME FORMAT a15;
SQL> COLUMN PROC FORMAT a20;
SQL> SELECT * FROM DA_LOGSTDBY_SKIP;
ERROR STATEMENT_OPT OWNER NAME PROC
----- ----------------- ---------- --------------- --------------------
N CREATE TABLESPACE
N ALTER TABLESPACE
Use the SKIP procedure with caution, particularly when skipping DDL statements. If a CREATE TABLE statement is skipped, for example, you must also skip any other DDL statements that refer to that table. Otherwise, these statements will fail and cause an exception. When this happens, the SQL apply services stop running and will need to be manually restarted.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-628165/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- How to Optimize PostgreSQL Logical ReplicationSQL
- Linux 建立LVM(Logical Volume)LinuxLVM
- 1.1 Logical Structure of Database ClusterStructDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- [20181113]Logical Standby建立2.txt
- 2.3.1.1.3 Application Containers Use Case: Logical Data WarehouseAPPAI
- rust-quiz:021-closure-or-logical-or.rsRustUI
- 精讀《國際化佈局 – Logical Properties》
- Oracle 19c Concepts(12):Logical Storage StructuresOracleStruct
- 榮耀9i引數與真機圖賞 榮耀9i配置怎麼樣?
- oracle 9i資料庫做spaOracle資料庫
- 4 Creating a Logical Standby Database 建立邏輯備庫Database
- Linux LVM Logical Volume Management 邏輯卷的管理LinuxLVM
- 榮耀9i隱藏劉海設定方法 榮耀9i怎麼隱藏劉海?
- Installing Oracle 9i on OELRHEL 4.8 64bitOracle
- 處理OGG-02198 Incompatible record (logical EOF) in trail fileAI
- ValueError: output parameter for reduction operation logical_and has too many dimensions ?Error
- 榮耀9i和小米6x對比評測 榮耀9i和小米6x哪個好?
- 榮耀Play和榮耀9i區別對比 差價600榮耀Play和榮耀9i哪個好?
- 在oracle 9i下線上重定義表Oracle
- oracle 9i臨時表產生過多redoOracle
- 榮耀9i和紅米Note5對比評測 榮耀9i和紅米Note5哪個好
- Oracle 9i統計資訊備份與恢復Oracle
- oracle ocp 19c考題8,科目082考試題-logical and physical database structuresOracleDatabaseStruct
- 9i和10g上rman全備的一點差別
- Oracle 9i升級19C 邏輯遷移詳細方法(一)Oracle
- Oracle 9i升級19C 邏輯遷移詳細方法(二)Oracle
- 關於Oracle 9i字符集問題的解決辦法FCOracle
- Oracle 9i升級19C 遷移關於失效索引的梳理方法Oracle索引
- Oracle 9i變數窺視引起執行計劃異常故障報告Oracle變數
- 邏輯鏈路控制與適配協議層(L2CAP,Logical Link Control and Adaptation Protocol)協議APTProtocol
- 榮耀9i碧玉青版開售:支援GPU Turbo的千元小屏機GPU
- 9i and 10g 透過SQL_ADDRESS 或sql_id查詢執行計劃SQL
- Oracle 9i, 10g, and 11g RAC on Linux所需要的Hangcheck-Timer Module介紹OracleLinuxGC
- Oracle 9i 11g歷史庫升級遷移資料至19c CDBOracle
- Oralce 入門教程:Oracle Database 9i 10g 11g程式設計藝術 深入資料庫體系結構 第2版OracleDatabase程式設計資料庫