Join the execution of several Tables Plan
Try to understand the query execution plan:
HR> SELECT e.last_name , d.department_name, l.city
2 FROM employees e, departments d , locations l
3 WHERE e.department_id = d.department_id
4 AND
5 d.location_id = l.location_id;
Execution Plan
----------------------------------------------------------
Plan hash value: 1235509609
--------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 106 | 4346 | 9 (23)| 00:00:01 |
|* 1 | HASH JOIN | | 106 | 4346 | 9 (23)| 00:00:01 |
| 2 | MERGE JOIN | | 27 | 837 | 6 (34)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| DEPARTMENTS | 27 | 513 | 2 (0)| 00:00:01 |
| 4 | INDEX FULL SCAN | DEPT_LOCATION_IX | 27 | | 1 (0)| 00:00:01 |
|* 5 | SORT JOIN | | 23 | 276 | 4 (50)| 00:00:01 |
| 6 | VIEW | index$_join$_003 | 23 | 276 | 3 (34)| 00:00:01 |
|* 7 | HASH JOIN | | | | | |
| 8 | INDEX FAST FULL SCAN | LOC_CITY_IX | 23 | 276 | 1 (0)| 00:00:01 |
| 9 | INDEX FAST FULL SCAN | LOC_ID_PK | 23 | 276 | 1 (0)| 00:00:01 |
| 10 | TABLE ACCESS FULL | EMPLOYEES | 107 | 1070 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------
So he needs to MERGE between DEPARTMENTS (that has been sorted by index) JOIN and (here's the part confusing...) LOCATIONS including oracle used HASH JOIN (?) to bring the information from and then sort the opinion generated by the system that has been created...?Is that this HASH JOIN to step 7 only refers to a view that is generated by the system that oracle had to sort and not actually HASH JOIN
between two tables?
Thanks much for you patience
Hello
Perhaps, it helps to understand things better if we walk in the plan.
Plans have a hierarchical structure (which is translated graphically by fingerprints). Operating needs parent all the children completed operations before it can do its job (which is generally combining lines with children in one way or another).
Another point is that joins can have anything like their entries, tables not only. That is a hash join can join an index for an index or a table to an index, or then to join a table results of hash one another and so on and so forth.
With this in mind, we can go back on what is happening here step by step:
The needs of the join by hash (1) (2) and (10) to finish. (10) is a basic operation, since a table scan depends on nothing else, but merge join handset (2) (3) and (5), who both are complex operations (i.e. dependent on one or more children). Specifically, lines (3) from the DEPARTMENTS table using ROWID obtained from a full analysis of the index of DEPT_LOCATION_IX (4), (5) is simply lines join hash (7) and sorted in the order required.
I hope this helps.
Best regards
Nikolai
Published by: Nikolay Savvinov on January 26, 2012 05:26
Tags: Database
Similar Questions
-
outer join when there are several tables are involved
Could not put up the question correctly to the last channel, my problem is with the join when there are several tables are involved, this is just one example of the task that I have to carry.
Tab1 aura model id retailer_id information for all the weeks (from the first Monday) of the month of JUNE with cost and Helen
Tab1
model_id
retailer_id
sell_date
cost
Helene
1
12
June 3, 13
100
40
1
12
June 10, 13
200
20
1
12
17 June 13
300
20
1
12
24 June 13
400
20
2
12
June 3, 13
300
10
2
12
June 10, 13
200
20
2
12
17 June 13
300
20
2
12
24 June 13
400
20
Tab2:
each retailer belongs to a dealer, under the table has the same information
retailer_id
Dealer_id
12
100
13
100
14
101
15
101
16
101
Tab 3
There is a third layer where each dealership is having a garage band
Dealer_id
Dealer_group
100
1001
101
1001
102
2001
103
2001
104
3001
105
3001
Tab4:
Of this table for each model and dealer discount information for the month of June (every week)
model_id
Dealer_group
discount_date
discount
1
1001
June 3, 13
10
1
1001
June 10, 13
20
1
1001
17 June 13
10
1
1001
24 June 13
30
2
1001
June 3, 13
10
2
1001
June 10, 13
20
2
1001
17 June 13
10
2
1001
24 June 13
30
3
2001
June 3, 13
10
3
2001
June 10, 13
20
3
2001
17 June 13
10
3
2001
24 June 13
30
Master_info:
It's the main table which is the master table for model /retailer information
Model_id
retailer_id
1
12
2
12
3
12
4
12
1
13
2
13
Output
model_id
retailer_id
sell_date
cost
Helene
Final (cost-helene-discount)
1
12
June 3, 13
100
40
50
1
12
June 10, 13
200
20
160
1
12
17 June 13
300
20
270
1
12
24 June 13
400
20
350
2
12
June 3, 13
300
10
280
2
12
June 10, 13
200
20
160
2
12
17 June 13
300
20
270
2
12
24 June 13
400
20
350
3
12
June 3, 13
0
0
0
3
12
June 10, 13
0
0
0
3
12
17 June 13
0
0
0
3
12
24 June 13
0
0
0
4
12
June 3, 13
0
0
0
4
12
June 10, 13
0
0
0
4
12
17 June 13
0
0
0
4
12
24 June 13
0
0
0
1
13
June 3, 13
0
0
0
1
13
June 10, 13
0
0
0
1
13
17 June 13
0
0
0
1
13
24 June 13
0
0
0
2
13
June 3, 13
0
0
0
2
13
June 10, 13
0
0
0
2
13
17 June 13
0
0
0
1
13
24 June 13
0
0
0
For highted above records (model_id / retailer_id combination) there is no record in tab1 but they have entered in master_info then the recordings should come for all model_id/retailer_id with all the 0 values
Hello
Thanks for posting the sample data.
It is unclear what dates you want to include in the output. The following query shows how you can generate every Monday in a given range. If you only want to include the dates that are actually present in tabl1 and/or tab4, you can simplify this a bit.
WITH date_range AS
(
SELECT TRUNC (TO_DATE (' 3 June 2013', 'DD-Mon-YYYY'))
, 'IW '.
) AS first_monday
, TRUNC (TO_DATE (24 June 2013 ', 'DD-Mon-YYYY') + 6)
, 'IW '.
) AS last_monday
OF the double
)
all_mondays AS
(
First_monday SELECT + (7 * (LEVEL - 1)) AS sell_date
OF date_range
CONNECT BY LEVEL<= 1="" +="" (="" (last_monday="" -="">=>
/ 7
)
)
SELECT mi.model_id
mi.retailer_id
am.sell_date
, Cost of NVL (t1.cost, 0) AS
, NVL (t1.rebat, 0) IN the refund
, NVL (t1.cost, 0)
-(NVL (t1.rebat, 0))
+ NVL (t4.discount, 0)
) AS final
E master_info
CROSS JOIN all_mondays am
LEFT OUTER JOIN tab1 t1 ON t1.model_id = mi.model_id
AND t1.retailer_id = mi.retailer_id
AND t1.sell_date = am.sell_date
LEFT OUTER JOIN tab2 t2 ON t2.retailer_id = mi.retailer_id
LEFT OUTER JOIN tab 3 t3 ON t3.dealer_id = t2.dealer_id
LEFT OUTER JOIN tab4 t4 ON t4.model_id = t1.model_id
AND t4.dealer_group = t3.dealer_group
AND t4.discount_date = t1.sell_date
ORDER BY mi.retailer_id
mi.model_id
am.sell_date
;
The results are not exactly what said you you wanted. I suspect it's because of typos in that you posted.
-
create the view of several tables of days
Hello
I'll have existing oracle db with the daily stat data, tables strangely named data_mon, data_tue, data_wed... For my batch that I intend to use the view with multiple day data, let say for the last 5 days.
Do not know how better to implement my sql with these suffixes _mon statement to make it more or less dynamic.
I create also ever seen from several tables, then, probably, that I can do something that will add daily updated data and remove data from 5 days?
You will appreciate comments on the details and the whole concept. I have prev sql server experience.
Thank you
Tuser12943718 wrote:
Hello
I'll have existing oracle db with the daily stat data, tables strangely named data_mon, data_tue, data_wed... For my batch that I intend to use the view with multiple day data, let say for the last 5 days.
Do not know how better to implement my sql with these suffixes _mon statement to make it more or less dynamic.
I create also ever seen from several tables, then, probably, that I can do something that will add daily updated data and remove data from 5 days?You will appreciate comments on the details and the whole concept. I have prev sql server experience.
Thank you
TChange the data model if you have 1 table for a day.
You have just a DATA table and a column to indicate the day of the application.
Then you don't need a view, do not need anything dynamic, do not need to break your head against a wall for a simple query... etc.
-
How to extract the indictments of several tables
Hi all
I have 10 tables that all have the same columns, but different data in each column. I would like to get a count of how many fields is not null for a specific column in each table. I tried to figure this out for hours without success. We use oracle 10g and I use Toad to write my SQL.
I will try to give you an example.
The SQL below returns the numbers for one of the tables. I would like to get the counts for each table with a single query.
SELECT COUNT(*) FROM RRM_HOME_EQ WHERE unit_id is not null AND account_off is not null;
Thanks in advance
OR
Try as below...
Select (select count (*) from emp where deptno = 10) tab1, tab2 (select count (*) of the Department)
Double;
TAB1 TAB2
---------- ----------
3 7
Hope this helps... !
-
The execution of several brothers in the planning
Hello
I'm new on the schedule. Can someone help me understand how the planning/Essbase handles the same BR run for the second time (without first one being finished) through planning? Is it possible to restrict it?
Thank you!but I guess I still think if there is a way to restrict the user to run the same BR again once it is already running by him/herself or someone else.
^ ^ ^ There is no way to do it. You could perhaps set a flag the data, and then do a test for the but it will definitely compromise the performance of the code because of the restrictions around IF statements.
To fly the planning of business rules is to severely limit the scope of the calculation of:
(1) only to calculate the members that relate to a form, for example, do not calculate the salary information on the form of office supplies.
(2) read the POV of the form and use it to limit the scope of FIX
(3) use "the aggregation-centric" approach and combine only the parts of the hierarchy which are affected by a particular form.Pretty much everyone does 1 & 2. The third option seems even rarer that we shouldn't. I know not why it is not taught to each bootcamp schedule because it has the potential (there are limits to the performance improvement it may bring, but it may be dramatic) to completely heavy Planning apps work acceptably.
Kind regards
Cameron Lackpour
-
How to display the results of the database from several tables in descending order?
I have a key word to search for images on my website that allows visitors to search for specific things. My db msysql has 15 tables and for the search function I use a UNION ALL operation to join them any visitor can find all tables at the same time. The problem is that all the results are in ascending order. How can I get the results in descending order.
SELECT *.
FROM table1
Keyword WHERE AS id LIKE %s or %s
UNION ALL
SELECT *.
FROM table2
Keyword WHERE AS id LIKE %s or %s
UNION ALL
SELECT *.
TABLE 3
Keyword WHERE AS id LIKE %s or %s
PS
I tried this and it doesn't work:
SELECT * FROM table1 WHERE AS %s or id AS %s ORDER BY id DESC keyword
and I know that this is not conventional to use SELECT * with so many tables, but believe me, I have my reasons. I'm not trying to do is to wrap the whole UNION within an external SELECTION
Once more, the order by clause can only appear at the end of the last select statement in a UNION query. You have it on all select statements.
-
[Help] Join the query from 3 tables
Hi, I'm new to database. I have a question about joining 3 tables, forgive me for my bad English.
My paintings look like this
Table 1: person (id, firstname, lastname)
Table 2: AssignPersonAddress (id, personid, addressid, type)
Table 3: address (id, phone, street, etc.)
I need AssignPersonAddress table, because in my data structure, a person may have more than 1 address and address type must be registered (for example: private, work)
I want to do a select query to the State any person with his private phone and work phone, like this.
NOBODY | PRIVATE | WORK
Right now my query looks like this
the problem is that I only get the person who has a private address and the job. But what I want is all anyone no matter if the person has only 1 or 2 address.select p.name , a1.tel AS Private, a2.tel AS Work from person p, addresse a1 , AssignPersonAddress apd1, AssignPersonAddress apd2, addresse a2 where p.id = apd1.person (+) and apd1.adresse = a1.id and apd1.art = 'Private' and p.objectid = apd2.person (+) and apd2.adresse = a2.id and apd2.art = 'Work'
As you can see I put the left outer join in where condition, but I always get the wrong result.
THX in advance
Danny
Published by: raitodn on October 1st, 2009 03:51
Published by: raitodn on October 1st, 2009 04:12
-
CONNECT PRIOR TO THE HELP OF SEVERAL TABLES RETURNS AWKAWARD RESULTS.
CREATE TABLE "JAM"."FTVORGN2" ( "FTVORGN_COAS_CODE" VARCHAR2(1 CHAR) NOT NULL ENABLE, "FTVORGN_ORGN_CODE" VARCHAR2(6 CHAR) NOT NULL ENABLE, "FTVORGN_EFF_DATE" DATE NOT NULL ENABLE, "FTVORGN_ACTIVITY_DATE" DATE NOT NULL ENABLE, "FTVORGN_USER_ID" VARCHAR2(30 CHAR) NOT NULL ENABLE, "FTVORGN_NCHG_DATE" DATE NOT NULL ENABLE, "FTVORGN_TERM_DATE" DATE, "FTVORGN_TITLE" VARCHAR2(35 CHAR) NOT NULL ENABLE, "FTVORGN_STATUS_IND" VARCHAR2(1 CHAR), "FTVORGN_ORGN_CODE_PRED" VARCHAR2(6 CHAR), "FTVORGN_DATA_ENTRY_IND" VARCHAR2(1 CHAR) NOT NULL ENABLE, "FTVORGN_VPDI_CODE" VARCHAR2(6 CHAR) )
I have a table as above.
I also have a table as below.
CREATE TABLE "JAM"."FORUSOR" ( "FORUSOR_USER_ID_ENTERED" VARCHAR2(30 CHAR) NOT NULL ENABLE, "FORUSOR_COAS_CODE" VARCHAR2(1 CHAR) NOT NULL ENABLE, "FORUSOR_ORGN_CODE" VARCHAR2(6 CHAR) NOT NULL ENABLE, "FORUSOR_ACCESS_IND" VARCHAR2(1 CHAR) NOT NULL ENABLE, "FORUSOR_ACTIVITY_DATE" DATE NOT NULL ENABLE, "FORUSOR_USER_ID" VARCHAR2(30 CHAR) NOT NULL ENABLE, "FORUSOR_WBUD_ACCESS_IND" VARCHAR2(1 CHAR) NOT NULL ENABLE, "FORUSOR_SURROGATE_ID" NUMBER(19,0), "FORUSOR_VERSION" NUMBER(19,0), "FORUSOR_DATA_ORIGIN" VARCHAR2(30 CHAR), "FORUSOR_VPDI_CODE" VARCHAR2(6 CHAR) )
REM INSERTING into FTVORGN2 SET DEFINE OFF; Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','01',to_date('01-OCT-88','DD-MON-RR'),to_date('19-MAR-97','DD-MON-RR'),'TRAIN01',to_date('31-DEC-99','DD-MON-RR'),null,'TOTAL UNIVERSITY','A',null,'N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','1006',to_date('22-SEP-14','DD-MON-RR'),to_date('22-SEP-14','DD-MON-RR'),'MJ35',to_date('31-DEC-99','DD-MON-RR'),null,'Provost','A','01','N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','2027',to_date('01-OCT-97','DD-MON-RR'),to_date('01-OCT-97','DD-MON-RR'),'DARDARMT',to_date('31-DEC-99','DD-MON-RR'),null,'Sch of Biomed Engr, Sci Health Sys','A','1006','N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','2028',to_date('28-FEB-01','DD-MON-RR'),to_date('28-FEB-01','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Sch of Envr Science, Engr Policy','A','1006','N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5275',to_date('01-OCT-97','DD-MON-RR'),to_date('02-JUL-99','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Administration','A','1006','N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5325',to_date('01-OCT-97','DD-MON-RR'),to_date('13-JAN-00','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Enrollment & Career Management','A','1006','N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5350',to_date('01-OCT-97','DD-MON-RR'),to_date('02-JUL-99','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Office of Education','A','1006','N',null); Insert into FTVORGN2 (FTVORGN_COAS_CODE,FTVORGN_ORGN_CODE,FTVORGN_EFF_DATE,FTVORGN_ACTIVITY_DATE,FTVORGN_USER_ID,FTVORGN_NCHG_DATE,FTVORGN_TERM_DATE,FTVORGN_TITLE,FTVORGN_STATUS_IND,FTVORGN_ORGN_CODE_PRED,FTVORGN_DATA_ENTRY_IND,FTVORGN_VPDI_CODE) values ('D','5365',to_date('01-OCT-97','DD-MON-RR'),to_date('02-JUL-99','DD-MON-RR'),'JMOORE',to_date('31-DEC-99','DD-MON-RR'),null,'Library','A','1006','N',null);
Select 'jam337', ', '1026', 'Q', to_date (January 30, 2008 "," MON-DD-YYYY'), 'P', null, null, ' n, null, null from union double all the
Select 'jam337', ', '1100', 'Q', to_date (January 30, 2008 "," MON-DD-YYYY'), 'P', null, null, ' n, null, null from the double
)
Select ftvorgn_orgn_code,
ftvorgn_data_entry_ind,
ftvorgn_title,
ftvorgn_status_ind,
-ftvorgn_orgn_code_nsf,
-ftvorgn_hierarchy_table_ind,
level,
ftvorgn_orgn_code_pred
of ftvorgn2
Start with ftvorgn_orgn_code in (select forusor_orgn_code
of forusor
where forusor_user_id_entered = 'jam337. '
- and forusor_coas_code = '
)
Connect prior ftvorgn_orgn_code = ftvorgn_orgn_code_pred
and ftvorgn_eff_date<=>=>
and ftvorgn_nchg_date > sysdate
FTVORGN_ORGN_CODE FTVORGN_DATA_ENTRY_IND FTVORGN_TITLE FTVORGN_STATUS_IND LEVEL FTVORGN_ORGN_CODE_PRED 1006 N Provost A 1 01 2027 N SCH of Biomed Engr, Sci health Sys A 2 1006 2028 N SCH of Science, political Engr. Envr A 2 1006 5275 N Administration A 2 1006 5325 N Registration & career management A 2 1006 5350 N Office of education A 2 1006 5365 N Library A 2 1006 Concerning
Etbin
-
The execution of several advanced actions?
I wonder if there is a way for an object or page to run more than one tip action, or have a call to action script advanced another script (I.e., nested scripts).
For example, let's say I have a tip called "Close_all" action that hides all objects on the page. When the user clicks A button, it executes Close_All.
Now I add button B who must do something else (for example, show a different object) in addition to fill the same function as Close_All.
Is there a way I can run Close_All in the action script Advanced button B without having to copy the script Close_All?
I don't want to have to create a copy of Close_All, because if I have to change something in this script, I have to also remember to make the same change in all copies.
The condition is in the part of the State, possible actions are at the TIME and the ELSE part. And thanks to a combination of several decisions, which are always evaluated in order. In your case, you have a (scenario A) sequence that should be executed regardless of the condition, in this case you put it in a standard simulated action:
First decision "Checkit".
IF page = X
Go to page X
ON THE OTHER
Continue
Second decision "always."
IF 1 is equal to 1
sequence of commands you have in the script
You see, no need to repeat the actions at all (and copy/paste works very quickly if you want a decision)
-
Reg: With the help of several tables of facts in the RPD!
Hi all
Can I get help with the following scenario?
We use OBIEE 11 g.
We have a report that uses 1 single fact table to retrieve data and it must be hell a lot of time to display the data in the report.
My question is is there a way to show the performance of the report if divide us the data in table 1 to 2 fact tables and the report uses them 2 made tables.
Are there other ways of finalization of the report for better performance.
Thanks for the help in advance!
Ajay.Hi Ajay,
Follow these steps for tuning;
1. try to adjust the SQL query generated first by the report, and then make the necessary changes. (Put index on the column that is required so that your query is scanning the index instead of the whole table)2. you can try to create the agg fact table and use agg navigation to improve performance. (This is to reduce the data set on which sql is triggered)
3. you can try to create partitions on the table of FACTS in the comic book, and so held the partitions are queried according to the filters.
4. in the last if all the foregoing does not resolve your query, you can try to divide the FACT table in two or more depending on your decision and then use fragmentation content in the MDB of the RPD layer if it will strike appropriate tables depending on whether you declare.
Mark Correct/utile so this can help.
Good luck
Kashi -
The combination of several tables: patent wise associates to a given laboratory
Oracle 10g
Ask your help to rewrite the query below correctly
I have the following tables
Now, I need a list of all patents sage associates for each laboratory.CREATE TABLE "ADDLAB" ( "VERSIONNO" NUMBER(*,0), "LABID" VARCHAR2(20), "LABNAME" VARCHAR2(60), "LABSTARTDATE" DATE, "LABSTATUS" VARCHAR2(20), "LABENDDATE" DATE, "OPERATOR" VARCHAR2(20), "FROMDATE" DATE, "TODATE" DATE, "SRCHFIELD" VARCHAR2(20), "PARENTLABID" VARCHAR2(20), "LABCLOSEREASON" VARCHAR2(1000), "LABHIDDENDATE" VARCHAR2(20), CONSTRAINT "PK_B34" PRIMARY KEY ("LABID", "LABHIDDENDATE") ENABLE ) CREATE TABLE "ADDPROJECT" ( "VERSIONNO" NUMBER(*,0), "PROJID" VARCHAR2(20), "PROJNAME" VARCHAR2(60), "PROJSTARTDATE" DATE, "PROJSTATUS" VARCHAR2(20), "PROJENDDATE" DATE, "PROJENDTYPE" VARCHAR2(20), "PROJENDREASON" VARCHAR2(1000), "UCPROJECTMANAGER" VARCHAR2(20), "FROMDATE" DATE, "TODATE" DATE, "SRCHFIELD" VARCHAR2(20), "OPERATOR" VARCHAR2(20), "PARENTPROJID" VARCHAR2(20), "PROJHIDDENDATE" VARCHAR2(20), CONSTRAINT "PK_B36" PRIMARY KEY ("PROJID", "PROJHIDDENDATE") ENABLE ) CREATE TABLE "PROJECTTOLABASSOCIATION" ( "VERSIONNO" NUMBER(*,0), "PROJLABASSOID" NUMBER(9,0), "PROJID" VARCHAR2(20), "LABID" VARCHAR2(20), "PROJLABSTARTDATE" DATE, "STATUS" VARCHAR2(20), "ENDDATE" DATE, "LABHIDDENDATE" VARCHAR2(20), "PROJLABHIDDENDATE" VARCHAR2(20), "PROJHIDDENDATE" VARCHAR2(20), CONSTRAINT "PK_B37" PRIMARY KEY ("LABID", "PROJID", "PROJLABHIDDENDATE") ENABLE ) CREATE TABLE "ADDPATENT" ( "VERSIONNO" NUMBER(*,0), "PATID" NUMBER(9,0), "PATTITLE" VARCHAR2(250), "PATSTATUS" VARCHAR2(20), "PATAPPDATE" DATE, "PATSTATUSDATE" DATE, "PATENTREJECTWITHDRAWNREASON" VARCHAR2(1000), "PATNO" VARCHAR2(20), "SRCHFIELD" VARCHAR2(20), "FROMDATE" DATE, "TODATE" DATE, "OPERATOR" VARCHAR2(20), "PATENTGEOGRAPHY" VARCHAR2(20), "PAPERTYPE" VARCHAR2(20) DEFAULT 'dummy', "PATENTURL" VARCHAR2(200), CONSTRAINT "PK_A67" PRIMARY KEY ("PATID") ENABLE, CONSTRAINT "UQ_PATENTTITLE" UNIQUE ("PATTITLE") ENABLE ) CREATE TABLE "PATENTTOPROJECTASSOCIATION" ( "VERSIONNO" NUMBER(*,0), "PATENTPROJASSOID" NUMBER(9,0), "PATID" NUMBER(9,0), "PROJID" VARCHAR2(20), "PATENTPROJHIDDENDATE" VARCHAR2(20), "STATUS" VARCHAR2(20), "STARTDATE" DATE, "ENDDATE" DATE, "PROJHIDDENDATE" VARCHAR2(20), CONSTRAINT "PK_A91" PRIMARY KEY ("PATID", "PROJID", "PATENTPROJHIDDENDATE") ENABLE ) CREATE TABLE "PATENTASSOCIATES" ( "VERSIONNO" NUMBER(*,0), "PATASSOID" NUMBER(9,0), "PATID" NUMBER(9,0), "ASSOCIATEID" NUMBER(9,0), CONSTRAINT "PK_B67" PRIMARY KEY ("ASSOCIATEID", "PATID") ENABLE ) CREATE TABLE "ADDASSOCIATE" ( "VERSIONNO" NUMBER(*,0), "ASSOCIATEID" NUMBER(9,0) NOT NULL ENABLE, "ASSOCIATENAME" VARCHAR2(100) NOT NULL ENABLE, "CTOJOINDATE" DATE, "STATUS" VARCHAR2(20), "ENDDATE" DATE, "SRCHFIELD" VARCHAR2(20), "OPERATOR" VARCHAR2(20), "FROMDATE" DATE, "TODATE" DATE, CONSTRAINT "PK_B23" PRIMARY KEY ("ASSOCIATEID") ENABLE )
I have wirtten the following query. If I get the correct results, I get duplicate values. Each record is displayed at least 10 times. So if there are 4 partners for a given patent, it's ateleast back 40 records. I tried SINGLE. No results displayed.
query2 = "SELECT tn1.associateName AS name " + "FROM AddLab al, AddProject ap, AddPatent p, ProjecttoLabAssociation pl, PatenttoProjectAssociation pp, " + "AddAssociate tn1, PatentAssociates tn2 " + "WHERE " + "al.labID=pl.labID " + "AND ap.projID=pl.projID " + "AND pl.projID=pp.projID " + "AND p.patID=pp.patID " + "AND pl.status = 'Active' " + "AND tn1.associateID = tn2.associateID " + "AND tn2.patID = '" + rs.getString("patID") + "' " + "order by al.labID"; try { stmt = conn.createStatement(); rs2 = stmt.executeQuery(query2); String associateNames = ""; while(rs2.next()) { associateNames += rs2.getString("ID") + ";\n"; }
Use the laureline or
Use can use the the tn1.associateName group
It seems that your use within java code here, I formatted as sql code. Fomat according to your requirement
SELECT t.name FROM (SELECT tn1.associateName AS name,count(*) FROM AddLab al, AddProject ap, AddPatent p, ProjecttoLabAssociation pl, PatenttoProjectAssociation pp, AddAssociate tn1, PatentAssociates tn2 WHERE al.labID=pl.labID AND ap.projID=pl.projID AND pl.projID=pp.projID AND p.patID=pp.patID AND pl.status = 'Active' AND tn1.associateID = tn2.associateID AND tn2.patID = ' rs.getString(patID) ' GROUP BY tn1.associateName order by al.labID) t;
-
Hello gurus,
I have about 25 tables in the ABC scheme
I want to give all privialges to the XYZ schema for all tables of 25 which is in the pattern ABC... So is there is SQL statement or a script, I can run to grant privileges to all tables.
Something similar to these...
SELECT 'create synonym ' || table_name || ' for ' || table_name FROM user_tables {code} So i get all the table names ....then i can run as a script.... U r help is greatly appriciated gurus!!! Thank you!!!
Administrator:
set head off set pages 0 set feed off spool myscript.sql Select 'grant select, insert, update, delete on abc.'||table_name||' to xyz;' from dba_tables where owner = 'ABC'; Select 'create synonym xyz.'||table_name||' for abc.'||table_name||';' from dba_tables where owner = 'ABC'; spool off;
Obviously this does not all new table that will be created in the future on ABC schema...
Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/] -
labview MATLAB script prevents the execution of several times.
I have a code for communication series in matlab, I want to use in labview for graphical interface easier and better design. for this I used the matlab script node in labview. It seems that labview continue executing the script of matlab, but I want to labview to execute only once.is he sort of to do?
I don't see how that can occur if you run the VI in "continuous" mode
-
Join the table orders from clause
Hi all
Who is the effective way to join the tables in from clause. I have two tables first with 20 lakh records and second containing 10 lakh recods.
Who is the effective query 1 or 2. Please suggest me if you have an idea to rewrite the query.QUERY 1: SELECT T4.ID,T4.ISO_NAME FROM T,T4 WHERE T4.ISO_NAME LIKE '%US%' AND T.ID=T4.ID; QUERY 2: SELECT T4.ID,T4.ISO_NAME FROM T4,T WHERE T4.ID=T.ID AND T4.ISO_NAME LIKE '%US%'; T(ID IS PRIMARY KEY) (20 lakh records) T4 (ID IS PRIMARY KEY ) (10 lakh records) --------------------- ID ISO_NAME 100 US,UK,IN,BR 101 UK,US,BR,IN 102 BR,UK,US,IN Note: No index on ISO_NAME .
Kind regards
Rajasekhar
Published by: SuNRiZz68 on January 29, 2009 04:22In practical terms, Alex is right. Sometimes it matter what table is selected first, but does the CBO generally a very good job of deciding what you need to select the first (assuming that your statistics are up to date) but this is the situation you are trying to avoid as much as possible.
If you specify a table main command tables in the clause is not reliable and should be used - but think before using advice and don't do that when necessary.
Which table to select depends firstly on the join method in the execution plan. Nested loops joins perform better by selecting in the smaller table first, make a loop on the largest table. Joins the smaller set hash table in memory first, and then go through the larger table, perform searches in memory. He can't make any difference, what table is read using first the merger joins and sort.
Back to your original question. Using the cost-based optimizer, both queries will probably roll the same because newer versions of Oracle (9i, 10g) often transform queries for efficiency before the execution anyway. According to what do you or do not request should probably run a nested loop or hash join. With a small set of data creaing index and using a search of nested loops will probably be faster to avoid full table scans. the '%' in the LIKE clause leader would ignore an index on the ISO_NAME column in any case if a main column may be used in a composite index. All this is based on the approximation using the information provided; Tuning questions should always be tested to unexpected developments.
-
A question about the count of several lines of table in a PL/SQL block
Hi all
I have a problem on counting the rows from several tables in a PL/SQL block, and I would be grateful if you could kindly give me a helping hand. Here's my problem: file in Microsoft Excel (one column) I have a list of several names of tables. For each table, when the number of rows is equal to 10000 I have to call a procedure. Here's how I tried to do:
I already checked this code with tables inividual and it works. The only problem isDECLARE CURSOR tb_cursor IS WITH my_table_names AS ( SELECT 'table1' AS tbname FROM DUAL UNION SELECT 'table2' AS tbname FROM DUAL UNION SELECT 'table3' AS tbname FROM DUAL UNION SELECT 'table4' AS tbname FROM DUAL UNION . . Here I continue writing one line for each table in order . to have the table names stored in my Excel file as a table to be queried by SELECT statement . ) SELECT * FROM my_table_names; BEGIN -- Here I verify that for each table having more than 10000 lines -- I call the specified procedure which is needed FOR I IN tb_cursor LOOP DECLARE -- Here I declare a cursor for counting the number of rows CURSOR currentTableRowCounter IS SELECT COUNT(*) AS rowsNum FROM I.tbname; numberOfRows currentTableRowCounter%ROWTYPE; BEGIN OPEN currentTableRowCounter; FETCH numberOfRows INTO numberOfRows; CLOSE currentTableRowCounter; IF (numberOfRows.rowsNum > 10000) THEN -- And here I will call the procedure which has to be run END IF; END; END LOOP; END; /
Indeed, oracle considers "I.tbname" as an unknown table name (although he refers to by its exact name).. . . SELECT COUNT(*) AS rowsNum FROM I.tbname; . . .
How can I solve this problem? I mean, how to use a variable (in my example, I.tbname) as the table name in the FROM clause to query a table instead of explicitly write the name of the table?SQL> @script.sql FROM I.tbname; * ERROR at line 99: ORA-06550: line 99, column 12: PL/SQL: ORA-00942: table or view does not exist
Thanks in advance,
DariyooshReplace the following code:
DECLARE -- Here I declare a cursor for counting the number of rows CURSOR currentTableRowCounter IS SELECT COUNT(*) AS rowsNum FROM I.tbname; numberOfRows currentTableRowCounter%ROWTYPE; BEGIN OPEN currentTableRowCounter; FETCH numberOfRows INTO numberOfRows; CLOSE currentTableRowCounter; IF (numberOfRows.rowsNum > 10000) THEN -- And here I will call the procedure which has to be run END IF; END;
By the following:
Declare numberOfRows number; begin EXECUTE IMMEDIATE 'select count(*) from '||I.tbname into numberOfRows; IF (numberOfRows.rowsNum > 10000) THEN -- And here I will call the procedure which has to be run END IF; end;
Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]Published by: Massimo Ruocchio, January 12, 2010 15:25
Added Variable Declaration
Maybe you are looking for
-
Cannot play the downloaded game
I recently downloaded a game, and every time I open it it will run for a few seconds and then send me right back to my home screen. I can't play the game and I have no idea why I can't. [Moved from comments]
-
Microsoft 3000 wireless keyboards; they will interact with each other
I have 2 PC and I would like to replace the wired keyboards for 2 sets of Microsoft 3000 keyboard, will they interact with each other and can I change Ch / Freq of the units
-
popup blocker has blocked a security program how it unlocked
popup blocker has blocked a security program how it unlocked
-
My 70 d suddenly started taking pictures with a PROMINENT white stripe! The largest aperture that's... that brought me to this could be a dust problem (even though I have never seen dust accumulate so) so I cleaned everything inside. It doesn't seem
-
Win 7 - missing video files to Mpeg, WMV and FLV thumbnails
The thumbnails are missing from video files (MPEG, WMV and FLV). It seems that the problems started afterinstallation, update the codec K-Lite and Windows 7 packs. There are a few videos that show a thumbnail, but they appear morethe choice video l