I have a master table.It contains 1300000 records.I want to change a column type from VARCHAR(100 CHAR) to VARCHAR2(300 CHAR).
I planned a way to do this. I will create a new column with a new name then I will copy data from old column to new column then I will drop old column and rename new column with old column name.
But master table contains a trigger. It adds data to master_history table for update and delete processes. So, how will the trigger affect my way? If I do process above , Is it okey?
My trigger is :
ALTER TRIGGER "TRG_MASTER_" ENABLE;
CREATE OR REPLACE TRIGGER "MASTER" AFTER
UPDATE OR
DELETE ON MASTER FOR EACH ROW
BEGIN
INSERT
INTO MASTER_HISTORY
(
ORDER_ID,
CUSTOMER_FIRST_NAME,
CUSTOMER_LAST_NAME,
CUSTOMER_EMAIL,
CUSTOMER_ADRESS
)
VALUES
(
:OLD.ORDER_ID,
:OLD.CUSTOMER_FIRST_NAME,
:OLD.CUSTOMER_LAST_NAME,
:OLD.CUSTOMER_EMAIL,
:OLD.CUSTOMER_ADDRESS,
);
END;
As far as concerns, there is no need for this complex logic. Oracle lets you extend the width of a varchar column with the following command:
ALTER TABLE master_history MODIFY mycol VARCHAR2(300);
--^-- modify this to your real column name
Extending the width of the column does not affect existing data.