Wednesday 15 March 2017

Create, Modify and Migrate Tables in 12c

Creating a table :-

Below script will create a table in XX schema.

create table XX.XX_ORACLE_DEMO
(
TRX_ID NUMBER(15) not null,
TRX_NUMBER VARCHAR2(30),
TRX_TYPE VARCHAR2(30) not null,
AMOUNT   NUMBER
);


This will create one object in DB.

Use below query to verify :-

select * from dba_objects where object_name like 'XX_ORACLE_DEMO%';

This will give you one record i.e. only table info.

-- Upgrade the Table .  ( to create Editioning View)

begin
ad_zd_table.upgrade('XX', 'XX_ORACLE_DEMO');     --- Object owner  , table name are paremeters.
end;
/

select * from dba_objects where object_name like 'XXG_AR_DEMO%'

Now it wil give you 3 records. Once you run upgrade script it will create Editioned view and synonym in apps for the table.


Altering  a table :- 


 alter table  XX.XX_ORACLE_DEMO add BU_CODE VARCHAR2(30);

Table Shows New Column

select * from XX.XX_ORACLE_DEMO

But Editioning view is not showing new column

select * from XX.XX_ORACLE_DEMO#


Run the below script to Refresh the Editioning View

begin
ad_zd_table.patch('XX', 'XX_ORACLE_DEMO');     --- Object owner  , table name are paremeters.
end;
/

Migrating Tables to Other instances :-  In 12.2 oracle provides new feature to migrate tables using XDF file which can be downloaded from one instance and uploaded to another instance. Below are the commands which can be used to download and upload XDF files.


XDF Generation:- 

Download :-
$FND_TOP/bin/xdfgen.pl apps/apps_pwd XX_ORACLE_DEMO owner_app_shortname='XX'

Upload :-
$FND_TOP/bin/xdfcmp.pl xx/&xx_pwd XX_ORACLE_DEMO.xdf apps/&apps_pwd

3 comments:

  1. how to drop the column and then migrate using XDF?

    ReplyDelete
    Replies
    1. Drop the column generate the xdf file for that table and compare in the target instance using xdfcmp.pl . That will drop the column in the table of target instance.

      Delete
    2. Sorry for the late reply

      1. Drop the column, It will drop the column from table.
      2. run the below script, It will refresh Editioning View and apps synonym.
      begin
      ad_zd_table.patch('XX', 'XX_ORACLE_DEMO'); --- Object owner , table name are paremeters.
      end;
      3. Download XDF using above mentioned command and migrate it.

      Delete