Compare table structure

Hi all,
I have an 3rd party apps with 9i database, which was upgraded to 11gR2 database, I have a backup of the 9i Hr schema.
In this database, I have schema "HR" with 1000+ rows.
Can you help/give me sql script on how to compare or to check what tables structure has been changed?
I want to track if a certain table column have increased/decreased in length or has been added/removed "not null" constraints , or was changed datatypes, etc.
Thanks a lot.
Edited by: KinsaKaUy? on 08-Sep-2011 01:16

Hi Boris,
select dbms_metadata.get_ddl('TABLE','SCHEMA_NAME','TABLE_NAME') from dual;
ORA-31603: object "SCHEMA_NAME" of type TABLE not found in schema "TABLE_NAME"
ORA-06512: at "SYS.DBMS_METADATA", line 2625
ORA-06512: at "SYS.DBMS_METADATA", line 2668
ORA-06512: at "SYS.DBMS_METADATA", line 2983
ORA-06512: at "SYS.DBMS_METADATA", line 3897
ORA-06512: at "SYS.DBMS_METADATA", line 5678
ORA-06512: at line 1
31603. 00000 - "object \"%s\" of type %s not found in schema \"%s\""
*Cause:    The specified object was not found in the database.
*Action:   Correct the object specification and try the call again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Compare table structures in different schemas. help please

    Hi all,
    I have a question...
    I have tables on different schemas some thing like
    Schema A
    Table 1
    Table 2
    Table 3
    Schema B
    Table 1
    Table 2
    Table 3
    Now situation is Table 1 and Table 2 will have similar structure or Table 1 in Schema B will have additional columns.
    like so... on... for all other tables...
    example !
    Schema A:
    Desc Table 1;
    Name                                  Type            Null
    No                                Number            Notnull
    Name                           Varchar2(10)     Not null
    Fee                              Number (10,2)   Not null
    Scheam B;
    Desc Table1;
    Name                                  Type               Null
    DX_No                                Number            Notnull
    DX_Name                           Varchar2(10)      Not null
    DX_Fee                              Number (10,2)   Not null
    comments                          Varchar(2)        Now I need to write a procedure sort of thing to compare these tables which are in different in column names in both schema and get it exported to Excel sheet.
    and here thing is first three columns SHOULD BE TREATED AS SAME even though prefix of DX_ exist since REST OF THE PART OF COLUMN NAME IS SAME.
    and in same way commets is new coloumn in schema B only..So that should be highlighted excel sheets..
    I am not sure how OAD or SQL Developer handle this...Is there any plsql block I can write to do above..
    Thanks in advance..

    An example of one method (this is just a starting point, you'll have to build it out to suit your needs).
    create table emp as select * from scott.emp where 1=0;
    alter table emp add (junk number(1));
    select
          t1.column_name as t1_column_name
       ,  t2.column_name as t2_column_name
    from
       select column_name
       from
          dba_tab_columns
       where
          table_name  = 'EMP'
       and
          owner       = user
    ) t1
    full outer join
       select column_name
       from
          dba_tab_columns
       where
          table_name  = 'EMP'
       and
          owner       = 'SCOTT'
    ) t2
    on (t1.column_name = t2.column_name)
    where
       t1.column_name is null
    or
       t2.column_name is null;
    T1_COLUMN_NAME                 T2_COLUMN_NAME
    JUNK
    1 row selected.
    TUBBY_TUBBZ?If you need to remove prefix's ... you would just do that in the select list (using regexp_replace, translate, substr, whatever you think is appropriate for your situation).
    Edited by: Tubby on Nov 6, 2010 12:38 PM
    Forgot to mention that this code will report differences between two schemas, regardless of where the additional columns reside ... if you have a 'master' schema that is the definitive source, then you would want to use the query provided by Xtender.

  • Compare table structure and add the missing columns

    Hello,
    I want to compare the table schema of two tables and update with some plsql code the second one with the missing columns of the fist one :
    Example
    SQL> desc a
    Name Type Nullable Default Comments
    C1 VARCHAR2(10) Y
    C2 NUMBER(3) Y
    C3 NUMBER(10,2) Y
    SQL> desc b
    Name Type Nullable Default Comments
    C1 VARCHAR2(10) Y
    C2 NUMBER(3) Y
    I want a script that will generate the following code
    alter table b add (c3 number(10,2))
    Thanks
    Andreas

    How abt the below mentioned code
    SQL>desc a
    Name Null? Type
    C1 VARCHAR2(30)
    C2 NUMBER(3)
    C3 NUMBER(10,2)
    C4 NOT NULL DATE
    C5 VARCHAR2(30)
    SQL>desc b
    Name Null? Type
    C1 VARCHAR2(30)
    SQL>ed
    Wrote file afiedt.buf
    1 Declare
    2 Cursor c1 is select Column_name,Data_length,Data_type,DATA_PRECISION,DATA_SCALE,
    3 Nullable
    4 From User_tab_columns
    5 Where Table_name = 'A';
    6 v_length Number;
    7 v_str Varchar2(200);
    8 v_null Varchar2(10);
    9 Begin
    10 For c2 in c1 loop
    11 Select count(1) into v_length
    12 From user_tab_columns
    13 Where Table_name = 'B'
    14 And Column_name = c2.column_name;
    15 if v_length = 0 Then
    16 Select Decode(c2.Nullable,'N','NOT NULL','') into v_null From Dual;
    17 if c2.Data_type = 'NUMBER' Then
    18 v_str := 'alter table b add '||c2.column_name||
    19 ' '||c2.data_type||'('||c2.data_precision||','||c2.data_scale||') '||
    20 v_null;
    21 Elsif c2.Data_type = 'DATE' Then
    22 v_str := 'alter table b add '||c2.column_name||
    23 ' '||c2.data_type||' '||v_null;
    24 Else
    25 v_str := 'alter table b add '||c2.column_name||
    26 ' '||c2.data_type||'('||c2.data_length||') '||v_null;
    27 End if;
    28 Execute immediate v_str;
    29 End if;
    30 End loop;
    31* End;
    SQL>/
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:04.03
    SQL>desc b
    Name Null? Type
    C1 VARCHAR2(30)
    C2 NUMBER(3)
    C3 NUMBER(10,2)
    C4 NOT NULL DATE
    C5 VARCHAR2(30)

  • How to compare the structure of multiple tables ..have only TOAD & PUTTY

    Hi,
    Many times i get a request to load some tables' data from one schema to another . But before doing that i need to compare the structures of the tables in the source & target schema.
    How can i do that? The list of tables keep on changing every now & then. In TOAD there is no option to compare a selected list of tables. Comparing the whole schemas is not a option before me as the schemas are too huge and it takes a lot of time to do the schema level comparision.
    Note this is a client machine and we are not allowed to install any s/w.
    I am working on making a unix script which does that for me. But that may take some time considering the hectic work schedule and my poor knowledge of unix scripting.
    Can someone suggest some way to do it?
    Regds,
    Kunwar

    i need to compare the structures of the tables in the source & target schema.SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'SOURCE'
    MINUS
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'TARGET'
    UNION
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'TARGET'
    MINUS
    SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE FROM DBA_TAB_COLUMNS WHERE OWNER = 'SOURCE'

  • Demantra PTP table structure changed in 7.3.X.X

    The staging tables structure is changed in Demantra version 7.3 onwards as compared to Demantra 7.2.X.X. Some of the "Required" columns in "BIIO_Promotion" table which is used to load promotion data`has been removed in Demantra 7.3. And some more "Required" columns are added in "BIIO_Promotion" table.
    The disappointing thing is that the implementation and user guide doesn't speak about it. How the implementer know, what type of values to load in these mandatory columns to populate the promotion data in Demantra.
    Regards,
    Milind...

    go to tables statements -
    > double click on the structure----> it will takes you to that structure

  • How to compare table data and table field

    Hi buddy,
        I have some question about how to compare table data and table field.
       1. I know there is one method:   CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS  , it use in unit test to compare the table data(A and B) , you can loop table A into structure A1, then use this mehtod it can compare whether table B contain structure A1.  but when I try to use this in main program it will dump.
              CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS(
                                                                                                        LINE    = A1
                                                                                                        TABLE = B ).
           Is there any method or FM can be used to compare the table data ?
        2. I also want to compare two table field , try to find out the different. How to realize this.
    Thank you for your sincerely answer.

    Hi Zongjie,
    What`s the difference, if you using loop A into wa_A, read table B into wa_B with all field, then compare with wa_A and wa_B.
    The question 2, seems no standard FM available here.
    Loop A into wa_A.
       Loop B into wa_B.
           if wa_A-field1 eq wa_B-field1.
           endif.
            if wa_A-field2 eq wa_B-field2. 
           endif.
       endloop.
    endloop.
    regards,
    Archer

  • How to compare table data available in two different databases

    Hi,
    I need to compare two tables data in available in two databases - how easly I can do that .. I have Table A in Database A and Table A in Database B which is snapshot of DB A.TableA - but here are some discrepencies now I need to match two tables .. but no extra space available, so no exp imp.
    Thanks in advance,
    Chitrasen

    HI,
    What is the difference that you are looking for, if it si for some records missing in some tables you could use MINUS and get the output. IF you are looking to compare the TABLE structure then you could look into the datadictionary VIEWS of both the database's and check the difference.
    Thanks

  • Sorting columns of Tree table structure

    Hi ,
    We have developed Tree Table structure based on the tutorial, but the data in the columns are not in the right order. Can anyone tell me how to do column sorting for Tree table structure, I know how to do column sorting on normal table structure but that logic does not work for Tree table structures
    Appreciate your help
    Som

    Hi Som,
    If you are using TutWD_TreeByNestingTableColumn project as example, this code can help you:
      //@@begin javadoc:onActionSortTree(ServerEvent)
      /** Declared validating event handler. */
      //@@end
      public void onActionSortTree(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionSortTree(ServerEvent)
         sort(wdContext.nodeCatalogEntries());
        //@@end
      private void sort(IPrivateTreeTableView.ICatalogEntriesNode catalogEntriesNode) {
           if(null==catalogEntriesNode) return;
         catalogEntriesNode.sortElements(COMPORATOR);
         int size = catalogEntriesNode.size();
         for(int i=0;i<size;i++) {
              sort( catalogEntriesNode.nodeChildCatalogEntries(i) );
      private static final Comparator COMPORATOR = new CatalogEntriesComparator();
      private static class CatalogEntriesComparator implements Comparator {
         public int compare(Object o1, Object o2) {
              IPrivateTreeTableView.ICatalogEntriesElement ot1 = (IPrivateTreeTableView.ICatalogEntriesElement)o1;
              IPrivateTreeTableView.ICatalogEntriesElement ot2 = (IPrivateTreeTableView.ICatalogEntriesElement)o2;
              return Collator.getInstance().compare(     ot1!=null ? ot1.getTITLE() : "",
                                                      ot2!=null ? ot2.getTITLE() : "");
         public boolean equals(Object obj) {
              return false;
    Best regards, Maksim Rashchynski.

  • FM9 Compare Documents - compare tables

    We have to create a “redline” document for distribution that compares a new version of a document to a previous version of the document, for each draft revision we generate.
    The FM9 Compare Documents utility works great for identifying insertions and deletions in basic text. However, our documents are full of tables. Many, many very long tables.
    If anything about a table structure changes between the previous and new version (i.e., a row is added/deleted, a column is added/deleted, the anchor is moved, or any cell formatting is changed) then FM simply inserts both the old table and new table in the composite document. The only conditional tracking it does with the tables is to put a change bar next to the old and new table anchors, and only the anchors take on the conditional color (i.e., red for deleted or blue for inserted), not the tables themselves.
    In the composite document, the two tables look like regular text - no conditions are applied. We have to MANUALLY color-code the insertions and deletions within all of the tables. This can literally take days. There has GOT to be a better way to make this more efficient!
    So my question is: is there any way to automatically identify the changes within tables in FrameMaker, or with any application that would partner with FrameMaker? I can’t find enough information about FrameMaker 10 to know if they have addressed the Compare Documents feature between tables.
    Any help on this topic would be greatly appreciated!
    Cathy Outlaw
    Technical Communicator

    cathy_outlaw wrote:
    We have to create a “redline” document for distribution that compares a new version of a document to a previous version of the document, for each draft revision we generate.
    The FM9 Compare Documents utility works great for identifying insertions and deletions in basic text. However, our documents are full of tables. Many, many very long tables.
    If anything about a table structure changes between the previous and new version (i.e., a row is added/deleted, a column is added/deleted, the anchor is moved, or any cell formatting is changed) then FM simply inserts both the old table and new table in the composite document. The only conditional tracking it does with the tables is to put a change bar next to the old and new table anchors, and only the anchors take on the conditional color (i.e., red for deleted or blue for inserted), not the tables themselves.
    In the composite document, the two tables look like regular text - no conditions are applied. We have to MANUALLY color-code the insertions and deletions within all of the tables. This can literally take days. There has GOT to be a better way to make this more efficient!
    So my question is: is there any way to automatically identify the changes within tables in FrameMaker, or with any application that would partner with FrameMaker? I can’t find enough information about FrameMaker 10 to know if they have addressed the Compare Documents feature between tables.
    Any help on this topic would be greatly appreciated!
    Cathy Outlaw
    Technical Communicator
    Have you tried Table > Convert Table to Text in both documents and comparing the text?
    **EDIT
    Converting "regular" tables - i.e., no straddled (merged) cells - is pretty reliable, but tables with straddled cells are unpredictable.
    Also I haven't tried comparing tables via their text conversions myself. If this works, you can convert text back to table, though I'm not sure how your marked-up changes might be preserved in the table.
    EDIT**
    HTH
    Regards,
    Peter Gold
    KnowHow ProServices
    Message was edited by: peter at knowhowpro

  • BI 7 : Command to export a table structure of SAP R/3 into a script/text ?

    Hi All.
    Greetings.
    Am New to SAP R/3 system.  And request help.
    We are trying to pull data from SAP R/3 thro Bussiness Objects Data Services into Oracle.
    For now : we create a target oracle table looking at the table structure of SAP R/3 from SE 11.
    In BODS, We then do the query transformation, and use the oracle target table created by us manually.
    This works absolutely fine.
    We would like to know the command by which we could export the table structure of any existing table
    in SAP R/3 into a script / or to text file,
    which we could use to create the same table structure in oracle.
    Rather than manually typing some 200 field names for each tables.
    Can anyone advise on this.
    Thanks
    Indu

    Hello,
    The problem is caused due to the spaces in your directories
    C:\SAP Dumps\Core Release SR1 Export_CD1_51019634/DB/ADA/DBSIZE.XML
    Replace the spaces with underscores and restart the installation from from scratch.
    Cheers
    Bert

  • Load Data from a table on one server's database, to the same table structure in multiple server databases

    Hi,
    I have a situation where i have to load data from one server/database table to multiple servers/databases.
    Example:
    I need to load data from dbo.TABLE_A  (on Server: Server_A & Database: Database_A)  to the same table on the list of server databases like
    Server: Server_B , Database: Database_B
    Server: Server_C , Database: Database_C
    Server: Server_D , Database: Database_D
    Server: Server_E , Database: Database_E
    Server: Server_F , Database: Database_F
    Server: Server_G , Database: Database_G
    Server: Server_H , Database: Database_H
    so on and so forth on 250 such server database combinations.
    The table structure is the same on all the servers.
    If i make the source or destination dynamic, it throws an error while mapping ?
    I cannot get Linked server permissions and SQL Server Config thing doesn't work as well.
    Please suggest on how to load data from one source to multiple server/databases.
    Thank you.

    I just need to transfer one table's data. its like i have to use a query to pick data for
    the most recent data. So i use something like, select A, B, C, D from dbo.table where ETL_TIMESTAMP > (the max(etltimestamp) in the destination on different server). There are no foreign key relationships and the data should not be truncated. it just had
    to append the new records.

  • TIPS(18) : CREATING SCRIPTS TO RECREATE A TABLE STRUCTURE

    제품 : SQL*PLUS
    작성날짜 : 1996-11-12
    TIPS(18) : Creating Scripts to Recreate a Table Structure
    =========================================================
    The script creates scripts that can be used to recreate a table structure.
    For example, this script can be used when a table has become fragmented or to
    get a defintion that can be run on another database.
    CREATES SCRIPT TO RECREATE A TABLE-STRUCTURE
    INCL. STORAGE, CONSTRAINTS, TRIGGERS ETC.
    This script creates scripts to recreate a table structure.
    Use the script to reorganise a table that has become fragmented,
    to get a definition that can be run on another database/schema or
    as a basis for altering the table structure (eg. drop a column!).
    IMPORTANT: Running the script is safe as it only creates two new scripts and
    does not do anything to your database! To get anything done you have to run the
    scripts created.
    The created scripts does the following:
    1. save the content of the table
    2. drop any foreign key constraints referencing the table
    3. drop the table
    4. creates the table with an Initial storage parameter that
    will accomodate the entire content of the table. The Next
    parameter is 25% of the initial.
    The storage parameters are picked from the following list:
    64K, 128K, 256K, 512K, multiples of 1M.
    5. create table and column comments
    6. fill the table with the original content
    7. create all the indexes incl storage parameters as above.
    8. add primary, unique key and check constraints.
    9. add foreign key constraints for the table and for referencing
    tables.
    10.Create the table's triggers.
    11.Compile any depending objects (cascading).
    12.Grant table and column privileges.
    13.Create synonyms.
    This script must be run as the owner of the table.
    If your table contains a LONG-column, use the COPY
    command in SQL*Plus to store/restore the data.
    USAGE
    from SQL*Plus:
    start reorgtb
    This will create the scripts REORGS1.SQL and REORGS2.SQL
    REORGS1.SQL contains code to save the current content of the table.
    REORGS2.SQL contains code to rebuild the table structure.
    undef tab;
    set echo off
    column a1 new_val stor
    column b1 new_val nxt
    select
    decode(sign(1024-sum(bytes)/1024),-1,to_char((round(sum(bytes)/(1024*1
    024))+1))||'M', /* > 1M new rounded up to nearest Megabyte */
    decode(sign(512-sum(bytes)/1024), -1,'1M',
    decode(sign(256-sum(bytes)/1024), -1,'512K',
    decode(sign(128-sum(bytes)/1024), -1,'256K',
    decode(sign(64-sum(bytes)/1024) , -1,'128K',
    '64K'
    a1,
    decode(sign(1024-sum(bytes)/4096),-1,to_char((round(sum(bytes)/(4096*1
    024))+1))||'M', /* > 1M new rounded up to nearest Megabyte */
    decode(sign(512-sum(bytes)/4096), -1,'1M',
    decode(sign(256-sum(bytes)/4096), -1,'512K',
    decode(sign(128-sum(bytes)/4096), -1,'256K',
    decode(sign(64-sum(bytes)/4096) , -1,'128K',
    '64K'
    b1
    from user_extents
    where segment_name=upper('&1');
    set pages 0 feed off verify off lines 150
    col c1 format a80
    spool reorgs1.sql
    PROMPT drop table bk_&1
    prompt /
    PROMPT create table bk_&1 storage (initial &stor) as select * from &1
    prompt /
    spool off
    spool reorgs2.sql
    PROMPT spool reorgs2
    select 'alter table '||table_name||' drop constraint
    '||constraint_name||';'
    from user_constraints where r_constraint_name
    in (select constraint_name from user_constraints where
    table_name=upper('&1')
    and constraint_type in ('P','U'));
    PROMPT drop table &1
    prompt /
    prompt create table &1
    select decode(column_id,1,'(',',')
    ||rpad(column_name,40)
    ||decode(data_type,'DATE' ,'DATE '
    ,'LONG' ,'LONG '
    ,'LONG RAW','LONG RAW '
    ,'RAW' ,'RAW '
    ,'CHAR' ,'CHAR '
    ,'VARCHAR' ,'VARCHAR '
    ,'VARCHAR2','VARCHAR2 '
    ,'NUMBER' ,'NUMBER '
    ,'unknown')
    ||rpad(
    decode(data_type,'DATE' ,null
    ,'LONG' ,null
    ,'LONG RAW',null
    ,'RAW' ,decode(data_length,null,null
    ,'('||data_length||')')
    ,'CHAR' ,decode(data_length,null,null
    ,'('||data_length||')')
    ,'VARCHAR' ,decode(data_length,null,null
    ,'('||data_length||')')
    ,'VARCHAR2',decode(data_length,null,null
    ,'('||data_length||')')
    ,'NUMBER' ,decode(data_precision,null,' '
    ,'('||data_precision||
    decode(data_scale,null,null
    ,','||data_scale)||')')
    ,'unknown'),8,' ')
    ||decode(nullable,'Y','NULL','NOT NULL') c1
    from user_tab_columns
    where table_name = upper('&1')
    order by column_id
    prompt )
    select 'pctfree '||t.pct_free c1
    ,'pctused '||t.pct_used c1
    ,'initrans '||t.ini_trans c1
    ,'maxtrans '||t.max_trans c1
    ,'tablespace '||s.tablespace_name c1
    ,'storage (initial '||'&stor' c1
    ,' next '||'&stor' c1
    ,' minextents '||t.min_extents c1
    ,' maxextents '||t.max_extents c1
    ,' pctincrease '||t.pct_increase||')' c1
    from user_Segments s, user_tables t
    where s.segment_name = upper('&1') and
    t.table_name = upper('&1')
    and s.segment_type = 'TABLE'
    prompt /
    select 'comment on table &1 is '''||comments||''';' c1 from
    user_tab_comments
    where table_name=upper('&1');
    select 'comment on column &1..'||column_name||
    ' is '''||comments||''';' c1 from user_col_comments
    where table_name=upper('&1');
    prompt insert into &1 select * from bk_&1
    prompt /
    set serveroutput on
    declare
    cursor c1 is select index_name,decode(uniqueness,'UNIQUE','UNIQUE')
    unq
    from user_indexes where
    table_name = upper('&1');
    indname varchar2(50);
    cursor c2 is select
    decode(column_position,1,'(',',')||rpad(column_name,40) cl
    from user_ind_columns where table_name = upper('&1') and
    index_name = indname
    order by column_position;
    l1 varchar2(100);
    l2 varchar2(100);
    l3 varchar2(100);
    l4 varchar2(100);
    l5 varchar2(100);
    l6 varchar2(100);
    l7 varchar2(100);
    l8 varchar2(100);
    l9 varchar2(100);
    begin
    dbms_output.enable(100000);
    for c in c1 loop
    dbms_output.put_line('create '||c.unq||' index '||c.index_name||' on
    &1');
    indname := c.index_name;
    for q in c2 loop
    dbms_output.put_line(q.cl);
    end loop;
    dbms_output.put_line(')');
    select 'pctfree '||i.pct_free ,
    'initrans '||i.ini_trans ,
    'maxtrans '||i.max_trans ,
    'tablespace '||i.tablespace_name ,
    'storage (initial '||
    decode(sign(1024-sum(e.bytes)/1024),-1,
    to_char((round(sum(e.bytes)/(1024*1024))+1))||'M',
    decode(sign(512-sum(e.bytes)/1024), -1,'1M',
    decode(sign(256-sum(e.bytes)/1024), -1,'512K',
    decode(sign(128-sum(e.bytes)/1024), -1,'256K',
    decode(sign(64-sum(e.bytes)/1024) , -1,'128K',
    '64K'))))) ,
    ' next '||
    decode(sign(1024-sum(e.bytes)/4096),-1,
    to_char((round(sum(e.bytes)/(4096*1024))+1))||'M',
    decode(sign(512-sum(e.bytes)/4096), -1,'1M',
    decode(sign(256-sum(e.bytes)/4096), -1,'512K',
    decode(sign(128-sum(e.bytes)/4096), -1,'256K',
    decode(sign(64-sum(e.bytes)/4096) , -1,'128K',
    '64K'))))) ,
    ' minextents '||s.min_extents ,
    ' maxextents '||s.max_extents ,
    ' pctincrease '||s.pct_increase||')'
    into l1,l2,l3,l4,l5,l6,l7,l8,l9
    from user_extents e,user_segments s, user_indexes i
    where s.segment_name = c.index_name
    and s.segment_type = 'INDEX'
    and i.index_name = c.index_name
    and e.segment_name=s.segment_name
    group by s.min_extents,s.max_extents,s.pct_increase,
    i.pct_free,i.ini_trans,i.max_trans,i.tablespace_name ;
    dbms_output.put_line(l1);
    dbms_output.put_line(l2);
    dbms_output.put_line(l3);
    dbms_output.put_line(l4);
    dbms_output.put_line(l5);
    dbms_output.put_line(l6);
    dbms_output.put_line(l7);
    dbms_output.put_line(l8);
    dbms_output.put_line(l9);
    dbms_output.put_line('/');
    end loop;
    end;
    declare
    cursor c1 is
    select constraint_name, decode(constraint_type,'U',' UNIQUE',' PRIMARY
    KEY') typ,
    decode(status,'DISABLED','DISABLE',' ') status from user_constraints
    where table_name = upper('&1')
    and constraint_type in ('U','P');
    cname varchar2(100);
    cursor c2 is
    select decode(position,1,'(',',')||rpad(column_name,40) coln
    from user_cons_columns
    where table_name = upper('&1')
    and constraint_name = cname
    order by position;
    begin
    for q1 in c1 loop
    cname := q1.constraint_name;
    dbms_output.put_line('alter table &1');
    dbms_output.put_line('add constraint '||cname||q1.typ);
    for q2 in c2 loop
    dbms_output.put_line(q2.coln);
    end loop;
    dbms_output.put_line(')' ||q1.status);
    dbms_output.put_line('/');
    end loop;
    end;
    declare
    cursor c1 is
    select c.constraint_name,c.r_constraint_name cname2,
    c.table_name table1, r.table_name table2,
    decode(c.status,'DISABLED','DISABLE',' ') status,
    decode(c.delete_rule,'CASCADE',' on delete cascade ',' ')
    delete_rule
    from user_constraints c,
    user_constraints r
    where c.constraint_type='R' and
    c.r_constraint_name = r.constraint_name and
    c.table_name = upper('&1')
    union
    select c.constraint_name,c.r_constraint_name cname2,
    c.table_name table1, r.table_name table2,
    decode(c.status,'DISABLED','DISABLE',' ') status,
    decode(c.delete_rule,'CASCADE',' on delete cascade ',' ')
    delete_rule
    from user_constraints c,
    user_constraints r
    where c.constraint_type='R' and
    c.r_constraint_name = r.constraint_name and
    r.table_name = upper('&1');
    cname varchar2(50);
    cname2 varchar2(50);
    cursor c2 is
    select decode(position,1,'(',',')||rpad(column_name,40) colname
    from user_cons_columns
    where constraint_name = cname
    order by position;
    cursor c3 is
    select decode(position,1,'(',',')||rpad(column_name,40) refcol
    from user_cons_columns
    where constraint_name = cname2
    order by position;
    begin
    dbms_output.enable(100000);
    for q1 in c1 loop
    cname := q1.constraint_name;
    cname2 := q1.cname2;
    dbms_output.put_line('alter table '||q1.table1||' add constraint ');
    dbms_output.put_line(cname||' foreign key');
    for q2 in c2 loop
    dbms_output.put_line(q2.colname);
    end loop;
    dbms_output.put_line(') references '||q1.table2);
    for q3 in c3 loop
    dbms_output.put_line(q3.refcol);
    end loop;
    dbms_output.put_line(') '||q1.delete_rule||q1.status);
    dbms_output.put_line('/');
    end loop;
    end;
    col c1 format a79 word_wrap
    set long 32000
    set arraysize 1
    select 'create or replace trigger ' c1,
    description c1,
    'WHEN ('||when_clause||')' c1,
    trigger_body ,
    '/' c1
    from user_triggers
    where table_name = upper('&1') and when_clause is not null
    select 'create or replace trigger ' c1,
    description c1,
    trigger_body ,
    '/' c1
    from user_triggers
    where table_name = upper('&1') and when_clause is null
    select 'alter trigger '||trigger_name||decode(status,'DISABLED','
    DISABLE',' ENABLE')
    from user_Triggers where table_name='&1';
    set serveroutput on
    declare
    cursor c1 is
    select 'alter table
    '||'&1'||decode(substr(constraint_name,1,4),'SYS_',' ',
    ' add constraint ') a1,
    decode(substr(constraint_name,1,4),'SYS_','
    ',constraint_name)||' check (' a2,
    search_condition a3,
    ') '||decode(status,'DISABLED','DISABLE','') a4,
    '/' a5
    from user_constraints
    where table_name = upper('&1') and
    constraint_type='C';
    b1 varchar2(100);
    b2 varchar2(100);
    b3 varchar2(32000);
    b4 varchar2(100);
    b5 varchar2(100);
    fl number;
    begin
    open c1;
    loop
    fetch c1 into b1,b2,b3,b4,b5;
    exit when c1%NOTFOUND;
    select count(*) into fl from user_tab_columns where table_name =
    upper('&1') and
    upper(column_name)||' IS NOT NULL' = upper(b3);
    if fl = 0 then
    dbms_output.put_line(b1);
    dbms_output.put_line(b2);
    dbms_output.put_line(b3);
    dbms_output.put_line(b4);
    dbms_output.put_line(b5);
    end if;
    end loop;
    end;
    create or replace procedure dumzxcvreorg_dep(nam varchar2,typ
    varchar2) as
    cursor cur is
    select type,decode(type,'PACKAGE BODY','PACKAGE',type) type1,
    name from user_dependencies
    where referenced_name=upper(nam) and referenced_type=upper(typ);
    begin
    dbms_output.enable(500000);
    for c in cur loop
    dbms_output.put_line('alter '||c.type1||' '||c.name||' compile;');
    dumzxcvreorg_dep(c.name,c.type);
    end loop;
    end;
    exec dumzxcvreorg_dep('&1','TABLE');
    drop procedure dumzxcvreorg_Dep;
    select 'grant '||privilege||' on '||table_name||' to '||grantee||
    decode(grantable,'YES',' with grant option;',';') from
    user_tab_privs where table_name = upper('&1');
    select 'grant '||privilege||' ('||column_name||') on &1 to
    '||grantee||
    decode(grantable,'YES',' with grant option;',';')
    from user_col_privs where grantor=user and
    table_name=upper('&1')
    order by grantee, privilege;
    select 'create synonym '||synonym_name||' for
    '||table_owner||'.'||table_name||';'
    from user_synonyms where table_name=upper('&1');
    PROMPT REM
    PROMPT REM YOU MAY HAVE TO LOG ON AS SYSTEM TO BE
    PROMPT REM ABLE TO CREATE ANY OF THE PUBLIC SYNONYMS!
    PROMPT REM
    select 'create public synonym '||synonym_name||' for
    '||table_owner||'.'||table_name||';'
    from all_synonyms where owner='PUBLIC' and table_name=upper('&1') and
    table_owner=user;
    prompt spool off
    spool off
    set echo on feed on verify on
    The scripts REORGS1.SQL and REORGS2.SQL have been
    created. Alter these script as necesarry.
    To recreate the table-structure, first run REORGS1.SQL.
    This script saves the content of your table in a table
    called bk_.
    If this script runs successfully run REORGS2.SQL.
    The result is spooled to REORGTB.LST.
    Check this file before dropping the bk_ table.
    */

    Please do NOT cross-postings: create a deep structure for dynamic internal table
    Regards
      Uwe

  • Vendor-Customer balances in group currency-table/structure/function module?

    Hi All,
    Which table/structure/function module can be used to get balances for vendors and customers in group currency? We just wnat to extract balances in group currency so FBL1N and FBL5N are not options. Is there any SAP report which can provide these balances for both vendors and customers?
    Thanks and regards,
    Pinky

    Hi Pinky,
    I came across one report S_ALR_87012079 - Transaction Figures: Account Balance, Program RFSRRCUA, which extracts Account Balances of Vendor. Once the report is executed, you can do Currency Translation from one currency to different currencies. In the output screen, in the Top Menu, select 'Settings -> Currency' and you can convert to another currency. I am not sure, if this helps you. If this helps, kindly update your comments here.
    Thank you.
    Suresh Jayanthi.

  • How to copy paste a table structure from word document into Text Field [field format Rich Text]

    In our current implementation we have a Blank page with Text Field [field format Rich Text] on generated PDF Document.
    Once the PDF document is generated, user can copy paste content form any word/rtf document to into the Text Field.
    Pasted content retains all text formatting [Bold, Italic, Underline, Indentation] except the Table format. Text Field is removing table metadata from the content and converting it into plant text.
    Is there anyway to copy paste table structure as it is from word document into Text Field?

    Hi,
    I don't think you can! While you can paste formatted text into the rich text field, the table metadata means nothing to the textfield.
    Niall

  • Insert multiple text files to multiple tables that have different table structures

    Hi All,
    I have a small problem. I have lots of text files in a folder location. Say for an example Company.txt, Code.txt. I need to insert all these files to tables similar to the file structure. Company file to Company table and Code file to Code table. The catch
    is that all these table structures differ one to another.
    How can i do this using SSIS? I guess using a for each loop with some data flow task would be a start.
    Can some body give me a step by step example on how i can achieve this.
    Thanks
    LM

    It is very complicated to accomplish the above requirement using the standard Data Flow Task. You have to essentially setup a separate task for each table layout. If you can use third-party solutions, check the commercial CozyRoc
    Data Flow Task Plus. It is an extension of the standard Data Flow Task, with ability to do dynamic data flows at runtime. You can load all your tables and layouts with only one Data Flow Task. The other benefit is the solution doesn't require programming.SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

Maybe you are looking for

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and ret

  • Some pictures are red

    Hi Guys, Sine i have installed Mountain Lion, some of my Pictures in Mounain Lion are with a kind of red shade this is also in Itunes happened with the Movie covers.. does any one know how i can fix it ? I also have that on some PNG files as well Tha

  • Officejet 5740 from mac OS 10.5.8

    I just purchased an Officejet 5740.  I set it up as a network printer using  a Windows 7 laptop.  I have been able to print from the laptop and from a Windows 7 desktop but I have not been able to find a driver to install the printer to my wife's MAC

  • Subcontracting Challan printing after reconciliation (status assigned)

    Hi, My requirement is to reprint the subcontracting challan after reconciliation (status assigned). To reprint the challan we use the tcode j1if11 and tick print immediately. Spool is generated and we are taking printout. But since the challan is rec

  • Safari Shutting Down Randomly

    Every time I view a page with a decent amount of content, Safari automatically shuts downs and gives me the choice the "Report", "Reopen", "Try Again", etc... Any help?