New column default value for value and to cancel the generation

Hello

When you add a new column with a default value that is defined in a table that has existing records, are there the undo data generated?

Thank you

Christophe Lizé

Hoek wrote:
Hello, Solomon,

Congratulations to you, in the first place.

Thank you.

I am aware THAT DDL is implicitly committed. If there is a way to show there is generated cancellation, I would like to know how.

Of course, some cancellations are generated when the statement ALTER TABLE is issued. And of course, undo is generated with respect to the DEFAULT value. If you need a test case with a larger table to separate the apples to oranges:

SQL> CREATE TABLE tbl(
  2                   x NUMBER
  3                  )
  4  /

Table created.

SQL> INSERT
  2    INTO tbl(
  3             x
  4            )
  5    SELECT  level
  6      FROM  dual
  7      CONNECT BY level < 100001
  8  /

100000 rows created.

SQL> CREATE OR REPLACE
  2    TRIGGER AFTER_ALTER
  3      AFTER ALTER
  4      ON DATABASE
  5      DECLARE
  6          v_cnt NUMBER;
  7      BEGIN
  8          SELECT  used_urec
  9            INTO  v_cnt
 10            FROM  v$transaction;
 11          DBMS_OUTPUT.PUT_LINE('Undo records used: ' || v_cnt);
 12  END;
 13  /

Trigger created.

SQL> SET SERVEROUTPUT ON
SQL> ALTER TABLE tbl
  2    ADD y VARCHAR2(10) DEFAULT 'hoek'
  3  /
Undo records used: 268215

Table altered.

SQL>  

SY.

Tags: Database

Similar Questions

Maybe you are looking for