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
Similar Messages
-
Different ways to copy data between two schemas in one instance
Hi there,
I am searching a good way to copy data between two schemas in the same instance.
Both schemas have an identical structure such as triggers, tables, views and so on. The only difference is the purpose: one is the productivity system and one is for development.
I looked at datapump but I do not explicit want to export / import. I want to keep the data in the productivity schema as well as copy it to the other schema. Any ideas? I found out there is a copy statement but I dont't know how that works.
Thank you so far,
JörnThank you for your replies!
I also thought of creating a second instance for development and move the dev - schema to it. I just don't know whether our server can handle both (performance?). Anyway the idea is to have a possibility to quickly rebuild the data inside a schema without indixes or triggers, just pure data. I thought the easiest way would be to copy the data between the schemas as they are exactly the same. However if you tell me DataPunp is the best solution i won't deny using it :).
When you export data a file is created. does that also mean that the exported data is deleted inside the schema?
best regards
Jörn
Ps: Guido, you are following me, aren' t you? ;-) -
Moving data between two schemas
I need to move data between to schemas. I have a created packaged code to accomplish this. The problem is the execution time. When running the insert statements from the source schema to insert data into the target schema, it takes considerably longer to complete the statement than if I copied the tables from the source schema into the target schema and executed the same statement in the target schema. Any insight as to why this might be?
Also all data resides on the same physical disk, running version 10g on a W2K server.
Thanks in advance
Here is a sample of one of the insert statements:
INSERT INTO target_table(tt_id, tt_disp, tt_date, tt_emp_1, tt_emp_2, tt_emp_3)
SELECT src_tab.src_id,
src_tab.scr_disp,
src_tab.scr_date,
src_tab.scr_emp_1,
src_tab.scr_emp_2,
src_tab.scr_emp_3
FROM
(SELECT
row_number() over(
ORDER BY SUBSTR(fn_cil_sort_format(SUBSTR(src_cil,
1, 8)), 1, 4), SUBSTR(src_cil, 4, 8)) AS src_id,
scr_disp,
fn_date_format(date_time) AS scr_date,
v_convert AS scr_emp_1,
v_convert AS scr_emp_2,
v_convert AS scr_emp_3
FROM source_table
ORDER BY SUBSTR(fn_sort_format(SUBSTR(src_cil, 1, 8)), 1, 4),
SUBSTR(src_cil, 4, 8)) src_tab
WHERE scr_disp IS NOT NULL;In addition to the above post, you should create the table initially with NOLOGGING. create table as select has the ability to bypass logging. This should increase performance very much. No log writes will have to be taking place.
Lee -
How to compare data between two tables?
Hi,
My team is trying to develop a SAP data migration tool (DMT) using ABAP.
One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
Any help would be greatly appreciated, thanks!Hi Kian,
Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
Thanks,
Vinay -
Query the data between two tables
Need help for query the data between two tables
Table 1: Time sheet
P.ID P.Name EmpID HoursSpend DateTime
c12234 Test 25 4 06/12/2013
c12234 Test 25 7 06/13/2013
c12234 Test 25 8 06/15/2013
c12234 Test 5 3 06/21/2013
c12234 Test 2 5 07/15/2013
c12234 Test 25 4 07/21/2013
Table 2: cost table
EmpID FromDate ToDate Rate
25 05/01/2013 06/30/2013 250
2 04/01/2013 05/31/2013 150
25 07/01/2013 09/30/2013 300
Output
P.ID P.Name EmpID HoursSpend DateTime Rate Total (HoursSond x Rate)
c12234 Test 25 4 06/12/2013 250 1000 (4*250)
c12234 Test 25 7 06/13/2013 250 1750
c12234 Test 25 8 06/15/2013 250
2000
c12234 Test 25 4 07/21/2013 300
1200
c12234 Test 2 5 07/15/2013 150
750
===========================================
Total 28
6700
============================================
Here EmpID =2 don't have rate in the cost table on july month should be pick from last entry from cost table.Hi Gopal,
According to your description, it seems that the output needn’t include the row when EmpID=2. Because the DateTime for it in Table1 doesn’t included between FromDate column and ToDate column. After testing the issue in my environment, we can refer to the
query like below to achieve your requirement:
SELECT time.*,cost.EmpID,cost.Rate,(time.HoursSpend * cost.Rate)as [Total (HoursSond x Rate)]
FROM [Time sheet] as time
INNER JOIN
[cost table]as cost
ON time.EmpID = cost.EmpID
AND time.DateTime BETWEEN cost.FromDate AND cost.ToDate
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Transaction to see common data between two tables
Is there any transaction to see common data between two tables with out creating views.
what is the transaction to see the link between two tables
regards
pavanHi,
Go to a transparent table for which you want to know the common fields, from there click the button GRAPHICS (shortcut Ctrl + Shift + F11) in the application tool bar. Then you are redirected to a list containing the tables belonging to the same group. There select whatever tables you would like to see and click COPY. A window will pop-up and will show the relationship between the fields of the tables in a flow chart format.
see to this link also.
Common fields b/w tables
Regards,
Revathi Bhoopal. -
Intervals, synchronize the data between two oracle tables located in diffe
Hi Experts,
Is there any way I can, at set intervals, synchronize the data between two oracle tables located in different servers? What is the software, if there is any? If there are steps I can follow, so much the better.
Thanks!I'm not sure what you want to achieve here...
I want to synchronize both the Servers , so that it can update HO servers as well as Factory Server with the complete data. Could you please elaborate a little bit more; basing on your description I could also tell you how to setup timesync for those two servers if I understand "complete data" as the current date and time...
Also a lot of solutions are platform and version specific so it would help if you could indicate OS and Database Versions (4 digit).
And I still fail to see what this has to do with forms. You might want to post your question to the Database General forum: General Database Discussions
cheers -
How to compare data between two worksheet in Excel for applescript
Hi All,
How to compare the data from two different worksheet in Excel and set the value into one worksheet according to the same name? Here is the example. Worksheet 1 & 2 current we have, the final worksheet is the result we want and the value can be input in worksheet 1. Much appreciate if you can help on it.
Worksheet 1:
Name Number
Leo 25
Jame 55
Leo 30
Jame 60
Tim 44
Tomas 77
Lyne 35
Tonny 66
Jame 22
Game 88
Worksheet 2:
Name Number 2
Leo 60
Jame 150
Tim 66
Tomas 88
Lyne 55
Tonny 99
Game 111
Rusult in Worksheet 1
Name Number Total Number per name in Worksheet 1 Number 2 in Worksheet 2
Leo 25 55 60
Jame 55 137 150
Leo 30 55 60
Jame 60 137 150
Tim 44 44 66
Tomas 77 77 88
Lyne 35 35 55
Tonny 66 66 99
Jame 22 137 150
Game 88 88 111I'd probably use a database for this, if there's any quantity of data involved here. Import from Excel into {SQLite, MySQL, PostgreSQL, FileMaker, maybe Core Data}, or pick your preferred key-value store, keep your data in the database, then export or (via ODBC/JDBC) then access live database data from within the spreadsheets.
Alternatively and if you're looking at small quantities of data (say, less than 10,000 entries, or less than a thousand depending on the language), then just use whatever passes for a key-value store in your preferred scripting language {Python, bash, Lua, or maybe php, AppleScript or Java} and use that. Export Excel to CSV {gag} or XML, then load that into Python and process as needed, then write out CSV {gag} or XML.
AppleScript is a scripting language for GUI applications, and also useful for processing events. If you're not doing that sort of stuff, then there can be other choices, and other choices can often have extensive frameworks and libraries for common tasks.
Sooner or later, most everybody runs into a wall when using a spreadsheet... Various folks have encountered those limits and have migrated from spreadsheets to FileMaker databases, and now use a database as the central store for their operations — and that's the other issue that can arise with spreadsheets... Where's the canonical data? -
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. -
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 -
All Dates between two given Dates
Hi,
I need all the dates between two given dates in select-options .
For example the range in select-options is 01/01/2007 - 31/03/2007 .
I need all the dates between the two given dates .
How can i do this .Is there any FM for this ?
Regards,
Ziause this
CSCP_PARA1_GET_PERIODS
data:begin of daytab occurs 0.
include structure scscp_period_str.
data:end of daytab.
call function 'CSCP_PARA1_GET_PERIODS'
exporting
i_datuv = r_budat-low
i_datub = r_budat-high
i_timeunit = 'D'
tables
et_dates = daytab.
here u have to put one more logic.
loop at daytab where datuv in r_budat.
endloop.
So u will get all the dates
Regards
prabhu -
HI everyone!
I'm trying to obtain the dates between two given dates....
example:
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date a = sdf.parse("12/10/2005");
Date b = sdf.parse("22/12/2005");My desired result its a ArrayList of all dates between that period...
I already used the GregorianCalendar adding one day in a while condition until its equals the second date but it dosn't work for large periods of time...
Can somebody help me with this task?
thanks in advance !while(gc.getTime().compareTo(finaldate ) != 0){No, that's still fragile. You're still comparing EXACT values, instead of checking for when one equals OR EXCEEDS the other.
If you're not going to use DrLaszlo's example to use the Calendar class for a better way, then at least do this instead:
while(gc.getTime().compareTo(finaldate ) < 0){ -
Select all the dates between two txt fields. how?
In a 6i form cursor I need to select all the dates between two provided dates. I have two text fields FLD1 and FLd2 with date datatype. There is no table behind both the fields.
For example
:FLD1:='01-MAR-2013';
:FLD2:='10-MAR-2013';
Now I have to select all the dates from 01-mar-2013 to '10-mar-2013'. how to do it?Gul wrote:
In a 6i form cursor I need to select all the dates between two provided dates. I have two text fields FLD1 and FLd2 with date datatype. There is no table behind both the fields.
For example
:FLD1:='01-MAR-2013';
:FLD2:='10-MAR-2013';
Now I have to select all the dates from 01-mar-2013 to '10-mar-2013'. how to do it?As'salamualikum Gul
Try this
SELECT TO_DATE('01-MAR-2013', 'DD-MON-RRRR') - 1 + rownum AS d
FROM ALL_OBJECTS
WHERE TO_DATE('01-MAR-2013', 'DD-MON-RRRR') - 1 + rownum BETWEEN TO_DATE('01-MAR-2013', 'DD-MON-RRRR') AND TO_DATE('10-MAR-2013', 'DD-MON-RRRR')Hope this helps -
Findig dates between two dates
Hi everybody,
I have one table (TEST) with 2 columns having only one record
i need list of dates between from_date and to_date
the sample data...
from_date to_date
====== ======
02-JUL-09 17-JUL-2009
I found below query to retrieve the dates between two dates.
select to_date('02-jul-2009','dd-mon-yyyy')+level-1 dt from dual
connect by level<=to_date('17-jul-2009','dd-mon-yyyy')-to_date('02-jul-2009','dd-mon-yyyy')+1
It is working properly.
i have changed the above query with my table column names
select to_date(from_date,'dd-mon-yyyy')+level-1 dt from Test
connect by level<=to_date(to_date,'dd-mon-yyyy')-to_date(from_date,'dd-mon-yyyy')+1
In this case it is not working...
i am unable to find the reason...
Thank you.Hi,
It is working fine for me, what is the data type for from_date and to_date.
select to_date(from_date,'dd-mon-yyyy')+level-1 dt from Test
connect by level<=to_date(to_date,'dd-mon-yyyy')-to_date(from_date,'dd-mon-yyyy')+1;
DT
02-JUL-09
03-JUL-09
04-JUL-09
05-JUL-09
06-JUL-09
07-JUL-09
08-JUL-09
09-JUL-09
10-JUL-09
11-JUL-09
12-JUL-09
13-JUL-09
14-JUL-09
15-JUL-09
16-JUL-09
17-JUL-09Regards
Anurag Tibrewal
PS: Also post your output with the second query. -
Use of SAP memory to transfer data between two different sessions.
Hello experts,
I wish to know how to use SAP memory to transfer data between two different sessions.
The scenario is that when I run a report and change a variable, the value of changed variable should be availabe to another user on another terminal.
Thanks & Regards!
SumitHello,
Just to add what Max has already mentioned. IMPORT TO / EXPORT FROM DATABASE statements can be used to store data in special "cluster" tables (you can't use any DDIC table) e.g., INDX.
@OP: You can opt for Shared Memory(SHM) for this specific requirement as well. In my opinion SHM is a bit tricky to code, but it is easier to monitor. The opposite holds true for "data clusters".
You should remember SHM is app-server specific. So if you've a load balancing scenario, using SHM can cause problems.
Hope i'm clear.
BR,
Suhas
Edited by: Suhas Saha on Nov 19, 2010 4:12 PM
Maybe you are looking for
-
Batch processing saves files in wrong folder.
I ran into a problem the other day, and I believe an item should be added to the Process Multiple Files window, or perhaps it's a bug that should be squashed. I have a folder with many subfolders in it, all full of jpegs. I wanted to use the Process
-
I have a email address . It is not possible to buy icloud storage for it or to add to my first account where i have plenty of icloud storage available. <Email Edited by Host>
-
How can I edit an iMovie project created on one machine on a different one?
I created an iMovie on one MacBook, and want a colleague to edit it. I created a dropbox folder, moved all the files there; i can see them on the other Mac, but the project doesn't show up in the project window in iMovie on the other Mac and I can't
-
My phonetouch pad is not working
can anyone help?
-
Sharpen Filter under "Expert " editing in Photoshop Elements 11?
Where is the "Sharpen Filter" under the "Expert" Tab in Photoshop Elements 11?