Professional Documents
Culture Documents
-- Step 1. Request access for dbms_redefinition package and views from DBA
Check if the table can be redefined
========================================================
EXEC Dbms_Redefinition.Can_Redef_Table('APP_OWNER','APP_TABLE',DBMS_REDEFINITION
.CONS_USE_ROWID);
If no errors are reported it is safe to use dbms_redefinition to migrate this ta
ble
========================================================
-- Step 2. Create Interim table. (APP_OWNER)
========================================================
CREATE TABLE APP_TABLE_INTERMEDIATE TABLESPACE DATA_ENC_TS as (select * from APP
_TABLE where 1=2)
========================================================
-- Step 3. Check the dependencies for that table :
========================================================
SQL> select owner,index_name,index_type from user_indexes where TABLE_NAME='APP_
TABLE';
OWNER
INDEX_NAME
INDEX_TYPE
------------------------------ ------------------------------ -------------------------APP_OWNER
APP_TABLE_UPD_IDX
NORMAL
APP_OWNER
APP_TABLE_LOG_UPD_IDX
NORMAL
APP_OWNER
APP_TABLE_UNIQUE_ADDR_UK
NORMAL
APP_OWNER
APP_TABLE_DT_IDX
NORMAL
C INDEX_OWNER
INDEX_NAME
STATUS
------------------------------ - ------------------------------ ----------------------------- -------SYS_C00297379
C
ENABLED
SYS_C00297380
C
ENABLED
SQL> select name,owner,type from user_dependencies where REFERENCED_NAME='APP_TA
BLE';
NAME
-----------------------------APP_PACKAGE
DELETE_CBOX_REPORT
OWNER
TYPE
------------------------------ -----------------APP_OWNER
PACKAGE BODY
APP_OWNER
PROC
========================================================
-- Step 4. Start the Redefintion Process
========================================================
BEGIN
DBMS_REDEFINITION.START_REDEF_TABLE(
uname
=> 'APP_OWNER',
orig_table => 'APP_TABLE',
int_table => 'APP_TABLE_INTERMEDIATE',
options_flag => DBMS_REDEFINITION.CONS_USE_ROWID);
END;
/
========================================================
-- Step 5. Copy the dependent objects - After all rows are migrated
If there are lot of indexes which have PII columns you might want to
skip this Step and rebuild indexes as part of Step 11.
Decide on this Setup based on the number of indexes with PII. You can skip this
step and rebuild all indexes at the end.
========================================================
OWNER
TYPE
------------------------------ -----------------APP_OWNER
PACKAGE BODY
APP_OWNER
PROC
11. Move only the index having PII column to the encrypted tablespace : (Only if
you haven t executed step 5 to move all the indexes)
ALTER INDEX APP_TABLE_unique_addr_uk REBUILD ONLINE TABLESPACE enc_data_ts;
12. Start the application .