If suppose we have a requirement to update cores of records in a table.
to make it performance effective.
IF suppose xx_t1 which has corers of records. It contains a, b, c columns
Now I have a program which will update c column of this table for all the rows based on condition.
--Rename table
EXECUTE IMMEDIATE 'ALTER TABLE xxt1 TO xxt1_temp’;
--DROP table xx_t1;
EXECUTE IMMEDIATE 'DROP TABLE xxt1;
--Now use this logic to recreate xx_t1 again
EXECUTE IMMEDIATE '
CREATE TABLE xx_t1
AS
SELECT
a ,
b ,
xx_fun(a,b) c
FROM
xxt1_temp’;
--xx_fun() function will have the business logic.
EXECUTE IMMEDIATE 'CREATE INDEX xx_t1_U1 ON xx_t1(a,b) ';
EXECUTE IMMEDIATE 'ALTER INDEX xx_t1_U1 REBUILD UNRECOVERABLE';
============================================================
NOTE: If the table is dropped, Oracle automatically drops any index, trigger and constraintassociated with the table as well but not synonyms and views
==================================================
0 comments:
Post a Comment