A. All triggers on the table are invalidated and are automatically revalidated with the next DML execution
on the table.
B. All triggers on the table are invalidated and must be manually recompiled before the next DML
execution on the table.
C. All triggers on the table remain valid.
D. Only triggers that are affected by the changes to the structure of the table are invalidated and
automatically revalidated with the next DML execution on the table.
Answer: A
感觉描述有歧义,在线重定义后,trriger关联的是重定义前的表,而不是重定义后的表。
http://docs.oracle.com/cd/E11882_01/server.112/e25494/tables.htm#ADMIN11672
Results of the Redefinition Process
The following are the end results of the redefinition process:
-
The original table is redefined with the columns, indexes, constraints, grants, triggers, and statistics of the interim table.
-
Dependent objects that were registered, either explicitly using
REGISTER_DEPENDENT_OBJECT
or implicitly usingCOPY_TABLE_DEPENDENTS
, are renamed automatically so that dependent object names on the redefined table are the same as before redefinition.Note:
If no registration is done or no automatic copying is done, then you must manually rename the dependent objects. -
The referential constraints involving the interim table now involve the redefined table and are enabled.
-
Any indexes, triggers, materialized view logs, grants, and constraints defined on the original table (prior to redefinition) are transferred to the interim table and are dropped when the user drops the interim table. Any referential constraints involving the original table before the redefinition now involve the interim table and are disabled.
-
Some PL/SQL objects, views, synonyms, and other table-dependent objects may become invalidated. Only those objects that depend on elements of the table that were changed are invalidated. For example, if a PL/SQL procedure queries only columns of the redefined table that were unchanged by the redefinition, the procedure remains valid. See "Managing Object Dependencies" for more information about schema object dependencies.
SQL> DROP TABLE emp2 PURGE;
Table dropped
SQL> DROP TABLE emp3 PURGE;
Table dropped
SQL> CREATE TABLE emp2 AS SELECT * FROM scott.emp;
Table created
SQL> ALTER TABLE emp2 ADD CONSTRAINTS pk_emp2 PRIMARY KEY (empno);
Table altered
SQL> CREATE TABLE emp3 AS SELECT * FROM scott.emp WHERE 1=2;
Table created
SQL> ALTER TABLE emp3 ADD CONSTRAINTS pk_emp3 PRIMARY KEY (empno);
Table altered
SQL> ALTER TABLE emp3 MODIFY ename VARCHAR2(50);
Table altered
SQL> CREATE OR REPLACE TRIGGER trg_emp2
2 BEFORE UPDATE ON emp2
3 FOR EACH ROW
4 BEGIN
5 dbms_output.put_line(:old.empno);
6 END;
7 /
Trigger created
SQL> SET serveroutput ON
SQL> UPDATE emp2 SET sal = 1 WHERE ROWNUM <=1;
7369
1 row updated
SQL> DESC emp2;
Name Type Nullable Default Comments
-------- ------------ -------- ------- --------
EMPNO NUMBER(4)
ENAME VARCHAR2(10) Y
JOB VARCHAR2(9) Y
MGR NUMBER(4) Y
HIREDATE DATE Y
SAL NUMBER(7,2) Y
COMM NUMBER(7,2) Y
DEPTNO NUMBER(2) Y
SQL> BEGIN
2 DBMS_REDEFINITION.START_REDEF_TABLE(USER,'emp2','emp3');
3 dbms_redefinition.finish_redef_table(user, 'emp2', 'emp3');
4 END;
5 /
PL/SQL procedure successfully completed
SQL> DESC emp2;
Name Type Nullable Default Comments
-------- ------------ -------- ------- --------
EMPNO NUMBER(4)
ENAME VARCHAR2(50) Y
JOB VARCHAR2(9) Y
MGR NUMBER(4) Y
HIREDATE DATE Y
SAL NUMBER(7,2) Y
COMM NUMBER(7,2) Y
DEPTNO NUMBER(2) Y
SQL> UPDATE emp2 SET sal = 1 WHERE ROWNUM <=1;
1 row updated
SQL> UPDATE emp3 SET sal = 1 WHERE ROWNUM <=1;
7369
1 row updated