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.

Similar Messages

  • How can i import tables from a different schema into the existing relational model... to add these tables in the existing model? plss help

    how can i import tables from a different schema into the existing relational model... to add these tables in the existing relational/logical model? plss help
    note; I already have the relational/logical model ready from one schema... and I need to add few more tables to this relational/logical model
    can I import the same way as I did previously??
    but even if I do the same how can I add it in the model?? as the logical model has already been engineered..
    please help ...
    thanks

    Hi,
    Before you start, you should probably take a backup copy of your design (the .dmd file and associated folder), in case the update does not work out as you had hoped.
    You need to use Import > Data Dictionary again, to start the Data Dictionary Import Wizard.
    In step 1 use a suitable database connection that can access the relevant table definitions.
    In step 2 select the schema (or schemas) to import.  The "Import to" field in the lower left part of the main panel allows you to select which existing Relational Model to import into (or to specify that a new Relational Model is to be created).
    In step 3 select the tables to import.  (Note that if there are an Foreign Key constraints between the new tables and any tables you had previously imported, you should also include the previous tables, otherwise the Foreign Key constraints will not be imported.)
    After the import itself has completed, the "Compare Models" dialog is displayed.  This shows the differences between the model being imported and the previous state of the model, and allows you to select which changes are to be applied.
    Just selecting the Merge button should apply all the additions and changes in the new import.
    Having updated your Relational Model, you can then update your Logical Model.  To do this you repeat the "Engineer to Logical Model".  This displays the "Engineer to Logical Model" dialog, which shows the changes which will be applied to the Logical Model, and allows you to select which changes are to be applied.
    Just selecting the Engineer button should apply all the additions and changes.
    I hope this helps you achieve what you want.
    David

  • Need query to compare the columns of 2 diff tables of 2 different schemas.

    There are two different tables(sample1, sample2) in different schemas(s_schema1, s_schema2).
    I want the query to compare the columns of two different tables of two different schemas and provide whether the data as well as the count of data in
    the column are same .
    if not provide the data which is not similar in the columns of two different table.
    NOTE:
    I need queries for both the cases.
    (i) The datatypes in columns of two different tables are same.
    (ii) The datatypes in columns of two different tables are diffrent.

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version.
    >
    I need queries for both the cases.
    >
    Great - write the queries!
    The forum is not a coding service where you ask people to write code for you for free.
    YOU need to write the code. Then if you have a problem with the code you have written post the code you have written (using \ tags) and explain the problem you are having.
    Read the FAQ about how to ask a question on the forums.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Moving Subpartitions to a duplicate table in a different schema.

    +NOTE: I asked this question on the PL/SQL and SQL forum, but have moved it here as I think it's more appropriate to this forum. I've placed a pointer to this post on the original post.+
    Hello Ladies and Gentlemen.
    We're currently involved in an exercise at my workplace where we are in the process of attempting to logically organise our data by global region. For information, our production database is currently at version 10.2.0.3 and will shortly be upgraded to 10.2.0.5.
    At the moment, all our data 'lives' in the same schema. We are in the process of producing a proof of concept to migrate this data to identically structured (and named) tables in separate database schemas; each schema to represent a global region.
    In our current schema, our data is range-partitioned on date, and then list-partitioned on a column named OFFICE. I want to move the OFFICE subpartitions from one schema into an identically named and structured table in a new schema. The tablespace will remain the same for both identically-named tables across both schemas.
    Do any of you have an opinion on the best way to do this? Ideally in the new schema, I'd like to create each new table as an empty table with the appropriate range and list partitions defined. I have been doing some testing in our development environment with the EXCHANGE PARTITION statement, but this requires the destination table to be non-partitioned.
    I just wondered if, for partition migration across schemas with the table name and tablespace remaining constant, there is an official "best practice" method of accomplishing such a subpartition move neatly, quickly and elegantly?
    Any helpful replies welcome.
    Cheers.
    James

    You CAN exchange a subpartition into another table using a "temporary" (staging) table as an intermediary.
    See :
    SQL> drop table part_subpart purge;
    Table dropped.
    SQL> drop table NEW_part_subpart purge;
    Table dropped.
    SQL> drop table STG_part_subpart purge;
    Table dropped.
    SQL>
    SQL> create table part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition p_1 values less than (10) (subpartition p_1_s_1 values ('A'), subpartition p_1_s_2 values ('B'), subpartition p_1_s_3 values ('C'))
      5  ,
      6  partition p_2 values less than (20) (subpartition p_2_s_1 values ('A'), subpartition p_2_s_2 values ('B'), subpartition p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create index part_subpart_ndx on part_subpart(col_1) local;
    Index created.
    SQL>
    SQL>
    SQL> insert into part_subpart values (1,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'C');
    1 row created.
    SQL> insert into part_subpart values (11,'A');
    1 row created.
    SQL> insert into part_subpart values (11,'C');
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> create table NEW_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition n_p_1 values less than (10) (subpartition n_p_1_s_1 values ('A'), subpartition n_p_1_s_2 values ('B'), subpartition n_p_1_s_3 values ('C'))
      5  ,
      6  partition n_p_2 values less than (20) (subpartition n_p_2_s_1 values ('A'), subpartition n_p_2_s_2 values ('B'), subpartition n_p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create table STG_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  /
    Table created.
    SQL>
    SQL> -- ensure that the Staging table is empty
    SQL> truncate table STG_part_subpart;
    Table truncated.
    SQL> -- exchanging a subpart out of part_subpart
    SQL> alter table part_subpart exchange subpartition
      2  p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL> -- exchanging the subpart into NEW_part_subpart
    SQL> alter table NEW_part_subpart exchange subpartition
      2  n_p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL>
    SQL>
    SQL> select * from NEW_part_subpart subpartition (n_p_2_s_1);
         COL_1 COL_2
            11 A
    SQL>
    SQL> select * from part_subpart subpartition (p_2_s_1);
    no rows selected
    SQL>I have exchanged subpartition p_2_s_1 out of the table part_subpart into the table NEW_part_subpart -- even with a different name for the subpartition (n_p_2_s_1) if so desired.
    NOTE : Since your source and target tables are in different schemas, you will have to move (or copy) the staging table STG_part_subpart from the first schema to the second schema after the first "exchange subpartition" is done. You will have to do this for every subpartition to be exchanged.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Apr 4, 2011 10:19 AM
    Added clarification for cross-schema exchange.

  • How to gather table stats for tables in a different schema

    Hi All,
    I have a table present in one schema and I want to gather stats for the table in a different schema.
    I gave GRANT ALL ON SCHEMA1.T1 TO SCHEMA2;
    And when I tried to execute the command to gather stats using
    DBMS_STATS.GATHER_TABLE_STATS (OWNNAME=>'SCHMEA1',TABNAME=>'T1');
    The function is failing.
    Is there any way we can gather table stats for tables in one schema in an another schema.
    Thanks,
    MK.

    You need to grant analyze any to schema2.
    SY.

  • Need to build a form based on a table in a different schema

    Hello all,
    I am still new to APEX. I have been playing with it for a few days.
    I have an APEX user 'demo' whose default schema is demo1.
    But I need to create a form that can insert,update and delete based on table 'employee' in schema demo2.
    Demo has all the rights on employee table in demo2. I also assigned the demo2 schema to demo user's workspace.
    But when I am building the form, demo1 is th eparsing schema, but in table/view owner only demo1 is available. I don't see demo2 even though I assigned it to demo user's workspace.
    Is it possible to build a form based on a table in a different schema? I tried creating a synonym, but it doesn't show up in the list of tables to select from.
    I don't want to create views or anything because there are many tables in different schemas and it's not possible to go on creating views or such for each one.
    I was able to access th etable in a report though by prefixing the table name with the schema name.
    I would appreciate if someone could point me in the right direction.
    Thanks!

    Varad,
    Thank you for the explanation. So from what I understand, every time I create a form or report based on a table in a different schema, just change the parsing schema in application definition to the new one and create the form or report. So this way my forms and reports or whatever can be based on different tables in different schemas and they would run fine when deployed in a runtime environment (provided the appropriate privileges are there on the objects in context)?
    I tried this and I was able to see the different schema and select the table and create the form. I haven't tested in runtime though.
    Seems like a feasible option, need to test all scenarios though. If this is a feasible solution then there is no need to create synonyms or views (I am not talking about others' scenarios such as security etc) etc. Just appropriate privileges will do it.
    Thanks Varad. Have you used this way of creating a form in your apps? I need to explore more to see if it breaks anything.
    So, every time I need to select an object, say a table, in a different schema I need to temporarily change the parsing schema to that schema in the application definition? Is that a correct statement?
    I will leave the thread open to see if anybody has any comments.

  • Joining two tables in two different schema

    Hi All,
    I have a requirement to join two tables in two different schema. How to join these two tables in view object.
    Many thanks in advance.
    Regards
    Kaushik Gopalakrishnan

    1) If these tables are in one and same database instance, then you can join them by specifying the fully-qualified table names (inlcuding the schema name), for example:
    SELECT ...
    FROM schema_A.table1 T1, schema_B.table2 T2
    WHERE T2.parent_code = T1.code
         AND ...2) If the tables are in different database instances, then you can create a database link in one of the databases and access the table from the other database via the DB link, for example:
    SELECT ...
    FROM schema_A.table1 T1, schema_B.table2@mydblink T2
    WHERE T2.parent_code = T1.code
         AND ...3) If the tables are in different database instances and there is no option for DB links, then you cannot join the tables in an ADF ViewObject.
    Dimitar

  • Script for Compare same table 'TAB1' structures in different schemas

    Hello, i am having three schema and in all schema i have same table for example TAB1 and i want to Compare TAB1 table structures in all three schema but i don't know the script. the different should content at least  DATA_TYPE,DATA_LENGTH,DECODE(DATA_PRECISION,NULL,NULL,DATA_PRECISION||','||DATA_SCALE) columns in query. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi Thanks..

    If you want a generic script use below function to get the difference.. Run the below script and let me know in case of any issues
    CREATE OR REPLACE TYPE nt_username IS TABLE OF VARCHAR2(50);
    CREATE OR REPLACE TYPE obj_struc IS OBJECT (user_name1     VARCHAR2(30),
                                               user_name2      VARCHAR2(30),
                                               column_name1    VARCHAR2(30),
                                               column_name2    VARCHAR2(30),
                                               data_type1      VARCHAR2(106),
                                               data_type2      VARCHAR2(106),
                                               data_length1    NUMBER(10),
                                               data_length2    NUMBER(10),
                                               data_precision1 VARCHAR2(50),
                                               data_precision2 VARCHAR2(50),
                                               column_id1      NUMBER(10),
                                               column_id2      NUMBER(10)
    CREATE OR REPLACE TYPE nt_struc IS TABLE OF obj_struc;
    CREATE OR REPLACE FUNCTION tabstruc_script (p_tabnm   VARCHAR2,
                                                p_usernm  nt_username
    RETURN nt_struc
    AS
    v_nt_struc nt_struc := nt_struc();
    v_ntusrnm nt_username := p_usernm;
    TYPE rec_stru IS RECORD (column_name    all_tab_columns.column_name%TYPE,
                             data_type      all_tab_columns.data_type%TYPE,
                             data_length    all_tab_columns.data_length%TYPE,
                             data_precision all_tab_columns.data_precision%TYPE,
                             data_scale     all_tab_columns.data_scale%TYPE,
                             column_id      all_tab_columns.column_id%TYPE
    TYPE nt_stru IS TABLE OF rec_stru;
    v_ntstru nt_stru  := nt_stru();
    v_columnname all_tab_columns.column_name%TYPE;
    v_reccnt NUMBER;
    v_cnt NUMBER;
    v_precision1 VARCHAR2(50);
    v_precision2 VARCHAR2(50);                    
    BEGIN
    FOR i IN 1..v_ntusrnm.COUNT
      LOOP
         SELECT COUNT(*) INTO v_reccnt
         FROM all_tables
         WHERE owner = v_ntusrnm(i)
         AND table_name = p_tabnm;
          IF v_reccnt >= 1 THEN
             SELECT column_name,  
                    data_type,    
                    data_length, 
                    data_precision,
                    data_scale,
                    column_id
             BULK COLLECT INTO v_ntstru
             FROM all_tab_columns
             WHERE owner = v_ntusrnm(i)
             AND table_name = p_tabnm;
              FOR j IN i+1..v_ntusrnm.COUNT
                LOOP
                     FOR k IN 1..v_ntstru.COUNT
                       LOOP
                          SELECT COUNT(*) INTO v_cnt
                          FROM all_tab_columns
                          WHERE owner = v_ntusrnm(j)
                          AND table_name = p_tabnm
                          AND column_name = v_ntstru(k).column_name;
                           IF v_cnt >= 1 THEN
                             FOR l IN (SELECT column_name,  
                                              data_type,    
                                              data_length, 
                                              data_precision,
                                              data_scale,
                                              column_id
                                       FROM all_tab_columns
                                       WHERE owner = v_ntusrnm(j)
                                       AND table_name = p_tabnm
                                       AND column_name = v_ntstru(k).column_name)
                                LOOP
                                  IF ((v_ntstru(k).column_id <> l.column_id)
                                      OR (v_ntstru(k).data_type <> l.data_type)
                                      OR (NVL(v_ntstru(k).data_length,0) <> NVL(l.data_length,0))
                                      OR (NVL(v_ntstru(k).data_precision,0) <> NVL(l.data_precision,0))
                                      OR (NVL(v_ntstru(k).data_scale,0) <> NVL(l.data_scale,0))) THEN
                                     v_nt_struc.EXTEND;
                                     SELECT DECODE(v_ntstru(k).data_precision,NULL,NULL,v_ntstru(k).data_precision||','||v_ntstru(k).data_scale),
                                            DECODE(l.data_precision,NULL,NULL,l.data_precision||','||l.data_scale)
                                     INTO v_precision1,
                                          v_precision2
                                     FROM DUAL;
                                     v_nt_struc(v_nt_struc.COUNT) := obj_struc(v_ntusrnm(i),
                                                                               v_ntusrnm(j),
                                                                               v_ntstru(k).column_name,
                                                                               l.column_name,
                                                                               v_ntstru(k).data_type,
                                                                               l.data_type,
                                                                               v_ntstru(k).data_length,
                                                                               l.data_length,
                                                                               v_precision1,
                                                                               v_precision2,
                                                                               v_ntstru(k).column_id,
                                                                               l.column_id);
                                  END IF;
                                END LOOP;
                           END IF;
                       END LOOP;
                      FOR m IN(SELECT column_name,  
                                      data_type,    
                                      data_length, 
                                      data_precision,
                                      data_scale,
                                      column_id
                               FROM all_tab_columns
                               WHERE owner = v_ntusrnm(i)
                               AND table_name = p_tabnm
                               AND column_name NOT IN(SELECT column_name
                                                      FROM all_tab_columns
                                                      WHERE owner = v_ntusrnm(j)
                                                      AND table_name = p_tabnm))
                          LOOP                                         
                            v_nt_struc.EXTEND;
                            SELECT DECODE(m.data_precision,NULL,NULL,m.data_precision||','||m.data_scale)
                            INTO v_precision1
                            FROM DUAL;
                            v_nt_struc(v_nt_struc.COUNT) := obj_struc(v_ntusrnm(i),
                                                                      v_ntusrnm(j),
                                                                      m.column_name,
                                                                      NULL,
                                                                      m.data_type,
                                                                      NULL,
                                                                      m.data_length,
                                                                      NULL,
                                                                      v_precision1,
                                                                      NULL,
                                                                      m.column_id,
                                                                      NULL);
                          END LOOP;
                         FOR n IN(SELECT column_name,  
                                          data_type,    
                                          data_length, 
                                          data_precision,
                                          data_scale,
                                          column_id
                                   FROM all_tab_columns
                                   WHERE owner = v_ntusrnm(j)
                                   AND table_name = p_tabnm
                                   AND column_name NOT IN(SELECT column_name
                                                          FROM all_tab_columns
                                                          WHERE owner = v_ntusrnm(i)
                                                          AND table_name = p_tabnm))
                           LOOP
                            v_nt_struc.EXTEND;
                            SELECT DECODE(n.data_precision,NULL,NULL,n.data_precision||','||n.data_scale)
                            INTO v_precision2
                            FROM DUAL;
                            v_nt_struc(v_nt_struc.COUNT) := obj_struc(v_ntusrnm(j),
                                                                      v_ntusrnm(i),
                                                                      n.column_name,
                                                                      NULL,
                                                                      n.data_type,
                                                                      NULL,
                                                                      n.data_length,
                                                                      NULL,
                                                                      v_precision2,
                                                                      NULL,
                                                                      n.column_id,
                                                                      NULL);
                           END LOOP;
                        END LOOP;
            END IF;
      END LOOP;
    RETURN v_nt_struc;
    EXCEPTION
    WHEN OTHERS THEN
      RAISE;
    END tabstruc_script;
    SELECT * FROM TABLE(tabstruc_script(:tabnm,nt_username(:user1,:user2,:user3)));
    You need to pass tablename and username to calling this function. Username is a nested table here so you can pass like nt_username(:user1,:user2,:user3)

  • How to integrate different tables structures from different databases?

    Hi
    I'm new to oracle ..kindly help me with the below issue...
    I have same set of inter-related attributes (a,b,c,d) in two different databases A and B.
    The structure of tables in both the database are different but they carry same attributes in same relation.
    I have to integrate these attributes into single db object such that any update to base tables updates my object.How can i do this and what object will be helpful?
    Thanks

    Arun Rajesh wrote:
    Hi
    I'm new to oracle ..kindly help me with the below issue...
    I have same set of inter-related attributes (a,b,c,d) in two different databases A and B.
    The structure of tables in both the database are different but they carry same attributes in same relation.
    I have to integrate these attributes into single db object such that any update to base tables updates my object.How can i do this and what object will be helpful?
    ThanksWelcome to Forum!!!
    Please elaborate your question.
    Arun Rajesh wrote:
    I have same set of inter-related attributes (a,b,c,d) in two different databases A and B.1. What are the ATTRIBUTES?
    Arun Rajesh wrote:
    The structure of tables in both the database are different but they carry same attributes in same relation.2. Post the Table Structures.
    Arun Rajesh wrote:
    I have to integrate these attributes into single db object such that any update to base tables updates my object.How can i do this and what object will be helpful?3. What is the end result that you desire? A sample output shall help in our understanding.
    PS:- Please go through this to understand SQL and PL/SQL FAQ.
    Regards,
    P.

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Compare DB objects between different schemas

    Hi,
    I want to compare db objects beween 2 different schemas like QA and PROD.
    Please suggest me a tool that compares table definitions,stored procedures and other db objects between different schemas.

    Did you check the above video link which is shared?
    Yes I'd agree with you and also i faced these situations to check what objects i need to export from Dev to Quality ( to analyze what are already correct or what have to be imported again)
    Generally Quality & Prod are in sync.
    Also will be waiting along with you if anyone comments on any such tool.
    Regards,
    Krishna Tangudu

  • Compare table data between two schemas?

    Hi,
    I am looking for a script to compare the table data between the schemas (two different databases)? I know how to compare table by table but looking for a generic script where I can compare all the tables data from one schema to another schema?
    Thanks a lot...

    here the idea, adapt it with your needs :)
    Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    Connected as SYS
    SQL> create user user1 identified by user1;
    User created
    SQL> grant create  session to user1;
    Grant succeeded
    SQL> grant create table to user1;
    Grant succeeded
    SQL> alter user user1 quota 10m on DATA;
    User altered
    SQL> create user user2 identified by user2;
    User created
    SQL> alter user user2 quota 10m on DATA;
    User altered
    SQL> grant create table to user2;
    Grant succeeded
    SQL> grant create  session to user2;
    Grant succeeded
    SQL> create table user1.test(a Number) tablespace DATA;
    Table created
    SQL> create table user2.test(a Number) tablespace DATA;
    Table created
    SQL> insert into user1.test values (1);
    1 row inserted
    SQL> insert into user1.test values (2);
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> insert into user2.test values (2);
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> create table sys.logs(Diff number) tablespace data;
    Table created
    SQL> select * from sys.logs;
          DIFF
    SQL>
    CREATE OR REPLACE PROCEDURE TEST_MY_DIFF IS
      CURSOR CUR_ IS
        SELECT D.TABLE_NAME T_NAME FROM DBA_TABLES D WHERE D.OWNER = 'USER1';
      W_DIFF NUMBER;
      TYPE CV_TYP IS REF CURSOR;
      CV CV_TYP;
    BEGIN
      EXECUTE IMMEDIATE 'TRUNCATE TABLE SYS.LOGS';
      FOR I IN CUR_ LOOP
        W_DIFF := 0;
        OPEN CV FOR 'select count(*)
    from
    ( select * from USER1.' || I.T_NAME || '
    minus
    select * from USER2.' || I.T_NAME || ' )
    union all
    ( select * from USER2.' || I.T_NAME || '
    minus
    select * from USER1.' || I.T_NAME || ')
        LOOP
          FETCH CV
            INTO W_DIFF;
          INSERT INTO SYS.LOGS VALUES (W_DIFF);
          COMMIT;
          EXIT WHEN CV%NOTFOUND;
        END LOOP;
      END LOOP;
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END;
    SQL> BEGIN
      2  test_my_diff;
      3  end;
      4  /
    PL/SQL procedure successfully completed
    SQL> select * from sys.logs;
          DIFF
             1
             1

  • Cpying / Importing only a few tables structure from one schema to other!

    Greetings,
    Can any one please suggest me the best method to copy the structure of series of tables from one schema to other in a eased way!
    For example:- There is a MC scheama and there are about 1000 tables... and there is a AB schema where I need to copy only structure of 85 selected tables from MC -> AB..
    Please suggest!

    Hi,
    You could use any of the following:
    1) Export 85 tables from source to destination
    2) Use Data Pump Export with Network_link if you are on 10g
    3) Use CTAS (create table as select )
    4) Use DBMS_METADATA.GET_DDL procedure on the source to create a script
    Probably, others would come up with more bright ideas.
    Regards

  • Acess table located on different schema

    hi ,
    oracle 10.2.0.1.0
    I have production database and i'm able to access video_asset_language located on different schema (CAM) of same db.there is synonym for the table here (at production ) .If I query user_synonyms the last column DBLINK has entry here.
    Now from development DB I created a synonym for the table video_language_asset located in CAM schema. it says "translation error " . Synonym is created but not able to fetch from the table. If I query user_synonyms the last column DBLINK has no entry here.
    Please suggest what I need to do .
    thanks
    Kishna

    - Verify you have been granted select access to the table (from user_tab_privs_recd)
    - Verify the database link exists, if not create it (get the definition using dbms_metadata.get_ddl
    - get the correct synonym definition, and replace the synonym when (get the definition using dbms_metadata.get_ddl)
    Sybrand Bakker
    Senior Oracle DBA

  • HTML DB application using table in a different schema

    I need to create a new HTML DB application. The table is in a different schema than mine. The DBA granted me rights to see it and I can see it from iSQL. HTML DB does not give the alternative of selecting this table.

    This thread covers your issue.
    New to HTML DB, have questions about service admin and schemas
    Ask your DBA to add workspace to schema mapping.
    Sergio

Maybe you are looking for

  • Wrong calculation in PF in the first month of hiring

    Hi All, I hire one employee on 13.10.2008 and run the payroll. In /3f1(employee contribution) is coming Rs.478 and (employer contribution)  /3f3 is calculating Rs.146 and /3f4( EPS) is calculating Rs.332. when i run his payroll on next month i.e. nov

  • How to add custom link to shopping cart

    hello, can anyone tell me how to add a link to the shopping cart page (rather than using the View cart link on the module_shoppingcartsummary)? also, is it possible to customise the module? instead of: 2 item(s), Total: £0.00 View Cart i'd like to di

  • Oracle 9i and Linux

    In the documentation of Oracle 9i database, it stands that it has been validated with suse 7.1 and patches. I would like if anybody tried to run Oracle 9i database on a Mandrake 7.x or 8, ora Debian linux ?

  • VISIO 2010 Default File Associations

    PROBLEM: Visio 2010 is not set as the default program for opening the .vsd file type.  I tried to set the default file associations to Visio 2010, but it doesn't show up in the list of default programs.  BACKGROUND: I am running Windows 7 Home Premiu

  • Glitch in ios 5.1

    There seems to be a glitch in ios 5.1 while swapping between full screen apps and closing them after that.....