I am trying to extract data via a unique identifier from two separate schema in TOAD for Oracle using SQL. Normally, I would export to Python and work the csv from there, however, in this case, I must compare in TOAD before export as one data field is WAY too large to export without filtering down using the ticket identifier. So, I have tried:
SELECT LDKEY, LDOWNERTABLE, LDTEXT, LDOWNERCOL FROM DB.SCHEMA1 WHERE LDKEY = DB.SCHEMA2.TICKETUID
and…
SELECT LDKEY, LDOWNERTABLE, LDTEXT, LDOWNERCOL FROM DB.SCHEMA1 WHERE ( SELECT TICKETUID FROM DB.SCHEMA2 WHERE LDKEY = TICKETUID )
How can I compare the LDKEY
from one schema to the TICKETUID
of another? I only want to extract data where the key and ticket are equal – all other data I do not need. I can get data out using only one schema successfully, but one dataset DB.SCHEMA1
is too large to export, so it must be filtered first. How do comparisons across Schemas work in SQL/TOAD? How do I reference other schema from SQL queries?
I have seen similar questions out there, but none seemed to get at this directly.
Advertisement
Answer
Your question can be answered using SQL, regardless of whether you use TOAD or not. Add a WHERE clause (or join, depending on the data model) to compare the two values.
SELECT LDKEY, LDOWNERTABLE, LDTEXT, LDOWNERCOL FROM DB.SCHEMA1 INNER JOIN DB.SCHEMA2 ON LDKEY = TICKETUID