To compare Table in different Database
Hi
Is possible to compare tables in Different Database ?
They are same tables , but data can to be different
TIA
May be you can try with DBMS_RECTIFIER_DIFF.DIFFERENCES
Similar Messages
-
How to create a view consisting of data from tables in2 different databases
Using Oracle 10.2g
I have 2 databases Gus and haggis on Comqdhb schema.
glink indicates a databse link between Haggis and Gus
In Gus there are tables student,subject,grade,school containing columns like upn...
STUDENT
upn
academicYear
SUBJECT
subject
GRADE
examlevel
grade
SCHOOL
sn
In HAGGIS there are tables student,grade,teacher containing columns upn...desc below.
STUDENT
upn
GRADE
grade
upn
academicyear
level
Create view in your HAGGIS database which will join all of the exam grades together. You should have one view which will produce the following relation :
examGrade(upn, subject, examlevel, sn, grade,academicYear)
so I need to create a view which gets the data from both the tables in both the databases.
create view as examGrade(upn, subject, examlevel, sn, grade,academicYear) as select s.upn
But i am not getting how to select a column from 2 tables in different databases
I mean if i said
select upn from comqdhb.student@glink,comqdhb.student;
select upn from comqdhb.student@glink,comqdhb.student
ERROR at line 1:
ORA-00918: column ambiguously defined
help me out,Thank you.Thank you for the reply will follow up the code format
Create views in your HAGGIS schema database which will join all of the exam grades together. You should have one view which will produce the following relation :
examGrade(upn, subject, examlevel, sn, grade,academicYear)
I understand that there wont be duplication when we use conditions
If i query
select count(upn)
from comqdhb.student@glink I get 9000
but after the union
create view examGrade(upn, subject, examlevel, sn, grade,academicYear)
as
select distinct s.upn as upn
, g.subject as subject
, g."LEVEL" as examlevel
, g.grade as grades
, '9364097'
, to_number(g.academicyear) as academicyear
from comqdhb.student s
, comqdhb.grade g
where s.upn=g.upn
union
select s.upn
, sb.subject
, g.elevel
, g.grade
, s.acyr
, sc.sn
from comqdhb.subject@glink sb
, comqdhb.student@glink s
, comqdhb.gradevalues@glink g
, comqdhb.school@glink sc,
, comqdhb.studentingroup@glink sg
, comqdhb.teachinggroup@glink tg
where sb.sid=tg.sid
and tg.gid=sg.gid
and sg.upn=s.upn
and g."LEVEL"=tg.elevel
and s.school=sc.id
and sc.id=tg.id; returns
count(upn) from exam gradeIt gets stuck actually sometimes it returns
932002 some results.
2:
Another problem i am having which i am trying to solve and written up my ideas but haven't been getting the expected results.Hope you can help.Thank you.
Information:
=======
All children take exams at the age of 16 called a General Certificate of SecondaryEducation (GCSE).
They have to study and take exams in Mathematics, English and Science, and can take other subjects such as History, French, Art etc. Most students will study between 5 and 10 different subjects before taking their GCSEs.
For each exam, a student is awarded a grade from A*, A, B,C,D,E,F,G,U,X An A* grade is the best grade achievable and an X is the worst grade.
In order to analyze how students have performed, each grade is mapped to a numeric value as follows:
Grade Numerical score
A* 8
A 7
B 6
C 5
D 4
E 3
F 2
G 1
U 0
X 0
Now why i need this avgGCSE is because i have to create a view containing avgGCSE of the students it is used in the next question where a condition is avgGCSE is between 6.5 and 7
In order to calculate the avgGCSE the idea is to calculate the grades of the students and map the grades to their corresponding scores/values
add them all up and div by the total no of grades to get the avg.
desc comqdhb.STUDENT@glink;
STUDENT
=======
UPN
FNAME
CNAME
DOB
GENDER
PREVIOUSSCHOOL
XGCSE
SCHOOL
ACYR
STUDENTINGROUP
=============
UPN
GID
STARTDATE
ENDDATE
GRADE
GRADEVALUES
===========
GRADE
LEVEL
VALUE
I have a opinion that xgcse in STUDENT table refers to the avgGCSE which i want to calculate as when i asked my professor as to what xgcse he said that he forgot to take it out of the table and it is not necessary while creating avggcse.
select *
from comqdhb.student@glink
where xgcse<6.5; Displaying a result
returns:
UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
===========================================================================
1011 KIMBERLY ABBOT 07-JUL-79 f none 3.93500948 2 2
select *
from comqdhb.student@glink
where xgcse between 6.5 and 7 and upn = 1386; Displaying a result
returns:
UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
===========================================================================
1386 STEPHANIE AANNESSON 15-JAN-79 f none 6.88873 2 2 so if xgcse is the avgGCSE then upn 1011 has avggcse<6.5 and 1386 has avggcse >6.5
my idea was backward strategy like so now if we find out upn 1368 has suppose xgcse(avggcse)>6.5 how to extract the avggcse for the particular upn We need to map grades from GRADEVALUES to grade in STUDENTINGROUP and map upn from studentingroup to upn in student to output the values for the corresponding grades from GRADEVALUES
select grade
from comqdhb.studentingroup@glink
where upn = 1011;
Result:
GRADE
=====
D
F
B
E
C
E
E
B
8 rows selected. Mapping each grade to the corresponding value and calculating we get
32/8=4 total(values to corresponding grades)/no of grades.
But the xgcse for upn 1011 is 3.935 and i am getting 4!! maybe xgcse isn't avggrade but ? is the procedure by me correct for calculating avggcse
select grade
from comqdhb.studentingroup@glink
where upn = 1386;
Result:
GRADE
======
A*
A*
A*
A*
B
A*
A*
A
B
B
B
11 rows selected. grade to the corresponding value and calculating we get
79/11=7.12 total(values to corresponding grades)/no of grades.
But the xgcse for upn 1011 is 6.88... and i am getting 7.12!!
But another problem
when i say
select g.value,g.grade
from comqdhb.gradevalues@glink g
, comqdhb.studentingroup@glink sg
where g.grade=sg.grade
and sg.upn=1011;
result:
======
VALUE GRADE
===========
100 B
100 B
80 C
60 D
40 E
40 E
40 E
20 F
6 B
6 B
5 C
VALUE GRADE
=============
4 D
3 E
3 E
3 E
2 F
16 rows selected.
select distinct g.value,g.grade
from comqdhb.gradevalues@glink g
, comqdhb.studentingroup@glink sg
where g.grade=sg.grade
and sg.upn=1011;
result:
======
VALUE GRADE
============
2 F
100 B
6 B
3 E
60 D
5 C
4 D
80 C
40 E
20 F
10 rows selected. I am getting only 8 for the query
select grade
from comqdhb.studentingroup@glink
where upn = 1386; here its becomming 10 and also its displaying values as 100 and ...
select distinct *
from comqdhb.gradevalues@glink;
GRADEVALUES
===========
LEVEL GRADE VALUE
================================
a A 120
a B 100
a C 80
a D 60
a E 40
a F 20
a U 0
a X 0
g A 7
g A* 8
g B 6
LEVEL GRADE VALUE
================================
g C 5
g D 4
g E 3
g F 2
g G 1
g U 0
g X 0
18 rows selected. I was hoping if i could map the grades and get the values and calculate avggrade by total(values)/count(values)that would be it but here there are values like 100...
select sum(g.value)/count(g.grade) as avggrade
from comqdhb.gradevalues@glink g
, comqdhb.studentingroup@glink sg
where g.grade=sg.grade
and sg.upn=1386;
avggrade
========
37.4375 the avggrade cant be this big and when i map each grade i obtained for 1368 like a to 7+b to 6 so on i get avggrade 7.12
kindly help.
Edited by: Trooper on Dec 15, 2008 4:49 AM -
Select query based on joining of tables from different database is taking too long
Hi Team,
Select query on table with millions of records is taking very long time. It took 50mins, the below query is joining on multiple table from two databases DB1.dbo.Table1 contains 100 million records and also Table3 and Table4 (of different database) might
contain close to 1million records.
Select T1.*
From DB1.dbo.Table1 T1
Join DB1.dbo.Table2 T2 on RTRIM(T1.Col3) = RTRIM(T2.Col3)
Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
Join Table3 U on CA.Col2 = U.Col2 AND RTRIM(T2.Col2) = U.Col3
Where U.Col4 NOT IN ('A1', 'A2', 'A3', 'A4', 'A5', 'A6','A7','A8','A9')
And (T1.flg IS NULL OR T1.flg = 'N')
And LTRIM(RTRIM(T2.Col2)) NOT IN ('B1','B2')
How can i improve the performance of this query. Actual thing is update the data in Db1.dbo.table1 based on the conditions but if the select is taking close to 1hr then update will take hours together. Indexes already implemented on all the tables.
Thanks,
Eshwar.
Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.Thanks.
Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
This join is not working with spaces if Rtrim is not used.
Thanks! Eshwar.
Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users. -
How to join tables from different databases (DBLink/DB connection )
Hello,
i have an issue and i hope you could help me to solve it. My problem is: I want to create native sql select which joins two tables from different DB (both of them are ORACLE, one of them internal, another one - external). I have found several notes and posts, but without any success. Db connection exists in dbcon table, so this part of my problem has been solved.
I would like something like that:
select * from table1@xxx inner join table2.
i can not split this select into two separate ones, because both tables store over 30 mln. entries and i do not want to create any copies of them.
Br,
dezHi,
you might need to create a DB-Link on DB level and use EXEC SQL.
Lots of stuff on google about this, like
Oracle DBLink ( external database )
Volker -
Joining tables in different databases
Hi,
I know we can access multiple databases like Oracle, Informix etc. through a single toplink session using session broker. Also in toplink documentation it says there is a work around for joining tables that exists in different databases i.e. joining an Oracle table with an Informix Table. If anyone had tried this or if it is possible, please let me know how to do this.
Thanks..If I could know, how to perform or some sample code, for the following two steps it would be great.
Write descriptor ammendment code to bind together that go from (A) to (B) and (B) to (A).
Be sure to map the ammendment descriptors in the mapping workbench.Or please point me to the right toplink documentation or examples.
Thanks a lot for your help. -
Dealing with tables from different databases?
Hi. I'm a newbie to Visual Studio 2012 and stuck on how to interact with different datasets.
I am building a report that is associated with with two tables, each from a different database. The
master_flat table with the primary key matter_number is from the first database and it contains all the columns I need that should show up in the report layout I've built. However,
billing_table with the primary key matter_number contains a flag that I go by which I must use to determine whether each matter should come through in the reporting or not.
I've set the master_flat as dataset1 and the billing_table as dataset2. Now, what is the best way in Visual studio 2012 to filter by the matters that has flag "N" in dataset2?
ThanksWe are way out of sync. Lets synchronize. I'm not sure which question you are refering to. Is it the "C# or VBnet" question or is it the "One or two database Question". It seem like it would be the database question since you
should know which programming language you are using.
Open SQL Server Management Studio (SSMS). After login, there is an explorer where you can browse the databases, tables, and fields in the tables. You should be able to view how you build the database. If you right click any tables and then
"Script Table As : Select To : New Query Editor Window". There is an execute button to run the query. You can aslo edit the query. I usually test all my qeuries in SSMS before actually using them in an application. I would get a JOIN
SQL working in SSMS.
If you let me know if you are using VBnet or C# I will write a simple LINQ. Even better if you supply me the names of the columns of the two tables.
jdweng -
How to join tables on different databases
In the company I work in, we've got some java applications working on two different instances which "hide" to each others (one on 10g and the other on 8i). Some decoding tables, which should common to both of them, are only present on 8i one.
I've been told that java works 'cause it allows to connect to both of databases and then report the information on front end applications.
The question is this: since we'll have to get reports on both of databases, is it possible to perform queries by using tools like oracle forms, oracle reports, sql developers, ... for joining the tables of the two different databases as java does? We have to get how to accede directly to the two instances for getting data from both of them for reporting activities. I remind you that we cannot use dblinks between the two databases for internal security reasons.
Thanks in advance!Even java can't join between tables on two databases if the db links are not created.
So it essentially works that it fetches the data from one db and then from another db ( using two different db connctions) and then you can utlize these data and perform some joining.
Coming back to database world. It can be done like the usual dw approach.
1. Connect to a third db:
2. Get data from one database
3. get data from other database.
now do all the joins that you want to do -
Create tables in different database schemas using EJB 3 Entity Persistent
Hi All,
I would like to find out how to get the following tasks done using EJB 3.0 Java Entity Persistent:
( i ) Create tables in different schemas such as STUDENT under EDUCATION schema and table PATIENT in HOSPITAL schema. We can then reference them in SQL as EDUCATION.STUDENT and HOSPITAL.PATIENT.
( ii ) Reference these tables uniquely once they are created.
There are no pre-existing tables or naming conventions that needs to be adhere to in this situation.
I have no problem creating tables on the current schema in EJB 3.0 Java Entity Persistent.
Any suggestions would be appreciated.
Thanks,
JackUse the schema attribute of the Table annotation:
package javax.persistence;
@Target({TYPE}) @Retention(RUNTIME)
public @interface Table
String name( ) default "";
String catalog( ) default "";
String schema( ) default "";
UniqueConstraint
uniqueConstraints( ) default {};
} -
Create Foreing Key to one table in different dataBase
Hi, I need create a reference to one table in other database. I understand that Database Link can be used to connect me to other database but when I am creating the foreing key in my table, I can see only the tables in the schemas that have my data base not the other schemas. I created a connection with database link but I do not see the form to make reference to this connection from the create table wizard. I am using Oracle 9i and the client is 9.01.01.
Thanks in advance,
Mónica AlarcónWe cannot use tables in another table to enforce data integrity. This makes a lot of sense if you think about what would happen if the remote database goes down.
If you want to do this, then you need to use replication (materilaized view) to bring the parent table's data into the locaL database.
Cheers, APC -
How to create a view between two table under different database?
thx
Assuming the different database is Oracle, you'll probably need to create a 'dblink'. Researching that topic should get you where you need to go.
-
How to compare table in different versions?
Hi,
Please let me know how to comare table fields in different versions?
Ex: I need to compare the table fields of version 4.5 with ECC6.0.
Thank you.Hi,
goto Se11 Transaction -> enter table -> display.
Utilities ->Version -> version management
now click on remote comparison -> enter target system.
Regards
Kiran Sure -
SUM table on different database
I have the same table in two different bases. In one of them should make a view that will make the sum of these two tables. I have created database link and can make queries with one base to another. What do you do?
user10649758 wrote:
I have the same table in two different bases. In one of them should make a view that will make the sum of these two tables. I have created database link and can make queries with one base to another. What do you do?
What do you do?
I don't do anything.
Can you write code for tables when you don't know what the tables look like?
Neither can anyone else here.
How do I ask a question on the forums? -
Updating a table of different database user using db links
Consider two databases
db10gA and db10gB which is having a db link from A to B
There is a user A in db10gA
and another user B in db10gB
the user require to insert,update,delete records of user B tables
so how is the DML privileges are granted to user A to perform these tasks at db10gB database
whether it is the type of db link decides to do these tasks
whether any synonym created at db10gA side might help to do the jobuser7993571 wrote:
Consider two databases
db10gA and db10gB which is having a db link from A to B
There is a user A in db10gA
and another user B in db10gB
the user require to insert,update,delete records of user B tables
so how is the DML privileges are granted to user A to perform these tasks at db10gB database
whether it is the type of db link decides to do these tasks
whether any synonym created at db10gA side might help to do the jobUser A will act on behalf of the user who has created the DBLINK; for example if you have created the DBLINK with a user having a DBA role; and grant the DBLINK access to A, A can act on behalf of the DBA who has created the DBLINK. -
Replicating Tables to different Database
I am using Oracle 10.2 Database and here is the scenario
1. DB1 located on Network A
2. DB2 located on Network B
3. Reporting server is located on Network B
4. When running report on Reporting server, it uses DB2 with reference to DB1
5. Noticed slow performance when generating report
We are thinking if we can copy the reference tables from DB1 to DB2 but we need to daily update DB2 tables. High level steps will be:
1. Export tables from DB1 and import to DB2 (one time only)
2. Perform daily update/insert on the changes/additions made on DB1 tables to DB2 tables
Any comment on these steps? If these are ok, how can I update the changes to DB2?mrp wrote:
I am using Oracle 10.2 Database and here is the scenario
1. DB1 located on Network A
2. DB2 located on Network B
3. Reporting server is located on Network B
4. When running report on Reporting server, it uses DB2 with reference to DB1
5. Noticed slow performance when generating reportWithout actual measurements, you are hoping to get lucky with where source of slowdown originates,
I suggest that before making any changes you do extensive SQL_TRACE=TRUE to see where elapsed time actually occurs. -
How to move data in the table to different database ?
I'm currently having some problem with moving some of my data from devlopment db to production db. Currently i'm having 2 dev. db and i would like to combine the data in the table into 1 prod. db. Can anyone pls tell me, is it possible to do so. Please tell me the solution on how this can be done, if you guys know.
Thanks in advance.Hi,
create a database_link from your
PROD db to each of the DEV dbs.
then insert into table (select * from
table@dev_db1)
insert into table (select * from table@dev_db2)
HTH
Detlev
null
Maybe you are looking for
-
Home Sharing in Itunes 9 on Windows Home Server
I have installed iTunes 9 and have started using Home Sharing. I want to be able to use Home Sharing with my WHS (Windows Home Server) as our music is stored there and we have iTunes on all computers, plus 2 iphones and iPods. This would need a Home
-
How to return to the same PLACE on a page after you link to another page
If you are on a long page that contains links, if you click on the link, go to the new page, read, then return to the first page, you are dropped at the top of the page, not where you left from as FF3.* did. It matters because some pages I use have h
-
Permissions errors ...recurring or not fixed
Hi Folks, I recently upgraded to 10.9. Overall it is working well. But since i plan to make a clone, upgrade my drive (SSD) and clone back, i wanted to ensure all was well, so i repaired permissions. A huge list of errors was corrected . I restarted
-
I need some help. I have an iMac 21" (brand new). For some reason the computer goes to sleep and then shuts down completely. I am assuming it has something to do with the UPS setting in the system preferences. My question is 1. how doe I set them cor
-
How can we send workitem after Po approval decision has been taken by appro
Hi. How can we send workitem after Po approved decision has been taken by approver1 to approver2 in the same flow? Regards, Chow.