Query to find duplicate sql executed
What is the sql to find the duplicate sql executed and count of executions.
I need the query ( though we can get directly the results from OEM)
Please let me know.
Thanks
Naveen
>
What is the sql to find the duplicate sql executed and count of executions.
I need the query ( though we can get directly the results from OEM)Get to know V$SQL, V$SQL_AREA and V$SQL_TEXT.
Check out Christoper Lawson's Oracle performance tuning book - it's
very good on the basics of this subject.
HTH.
Paul...
Naveen--
When asking database related questions, please give other posters
some clues, like OS (with version), version of Oracle being used and DDL.
Other trivia such as CPU, RAM + Disk configuration might also be useful.
The exact text and/or number of error messages is useful (!= "it didn't work!"). Thanks.
Furthermore, as a courtesy to those who spend time analysing and attempting to help,
please do not top post and do try to trim your replies!
Similar Messages
-
Please advise what is the query to identify a SQL executed time
Hi all
Please advise what is the query to identify a SQL executed time.
eg, a DML executed at 16-Apr-2013 11:45hrsTry like..
select LAST_LOAD_TIME, ELAPSED_TIME, MODULE, SQL_TEXT elasped from v$sql order by LAST_LOAD_TIME desc -
Hi,
can any one help me the query to find the duplicate data from a column.maybe this example might be of some help.
SQL> select * from employees;
YEAR EM NAME PO
2001 04 Sarah 02
2001 05 Susie 06
2001 02 Scott 91
2001 02 Scott 01
2001 02 Scott 07
2001 03 Tom 81
2001 03 Tom 84
2001 03 Tom 87
8 rows selected.
SQL> -- based on the output above we know that there is duplicates on scott and tom
SQL> -- now we need to identified how many are duplicates by grouping into year, empcode, and name
SQL> select year, empcode, name, position,
2 row_number() over (partition by year, empcode, name
3 order by year, empcode, name, position) as rn,
4 count(*) over (partition by year, empcode, name) as cnt
5 from employees;
YEAR EM NAME PO RN CNT
2001 02 Scott 01 1 3
2001 02 Scott 07 2 3
2001 02 Scott 91 3 3
2001 03 Tom 81 1 3
2001 03 Tom 84 2 3
2001 03 Tom 87 3 3
2001 04 Sarah 02 1 1
2001 05 Susie 06 1 1
8 rows selected.
SQL> -- we have identified the duplicates on the above outputs by the counts
SQL> -- now we want to query only rows that has duplicates
SQL> select emp.year, emp.empcode, emp.name, emp.position, emp.cnt
2 from (select year, empcode, name, position,
3 row_number() over (partition by year, empcode, name
4 order by year, empcode, name, position) as rn,
5 count(*) over (partition by year, empcode, name) as cnt
6 from employees) emp
7 where rn = 1
8 and cnt > 1;
YEAR EM NAME PO CNT
2001 02 Scott 01 3
2001 03 Tom 81 3
SQL> -
Query to find Concurrent requests executed on each db node in RAC from in last 24 Hours
Hi
Could you please help me in getting the query to find total number of concurrent requests executed on each db node in Two DB Node RAC with PCP ( Two CM Nodes) in last 24 hours.c2670397-8171-480e-b9f8-8874e77ee0b4 wrote:
Hi
Could you please help me in getting the query to find total number of concurrent requests executed on each db node in Two DB Node RAC with PCP ( Two CM Nodes) in last 24 hours.
Query FND_CONCURRENT_REQUESTS table (ACTUAL_START_DATE and ACTUAL_COMPLETION_DATE columns) -- http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE
https://community.oracle.com/message/10780262#10780262
https://community.oracle.com/message/10589420#10589420
Thanks,
Hussein -
Dear all,
i have a table
create table attendance(dept_id number,att_date date,att_kind);
all the three columns i want to put as a primary key,
there is a data in the table.
how would i check through a query that the table has duplicate values or not?
in other words , i want to query just the duplicate records so i delete them manually.
thanks & RegardsYou do it like this.
SQL> select * from attendance;
DEPT_ID ATT_DATE ATT_KIND
100 20-FEB-10 1
100 20-FEB-10 1
200 20-FEB-10 1
200 20-FEB-10 2
SQL> create table exceptions(row_id rowid,
2 owner varchar2(30),
3 table_name varchar2(30),
4 constraint varchar2(30));
Table created.
SQL> alter table attendance add constraint att_pk primary key (dept_id, att_date, att_kind) exceptions into exceptions;
alter table attendance add constraint att_pk primary key (dept_id, att_date, att_kind) exceptions into exceptions
ERROR at line 1:
ORA-02437: cannot validate (TEST.ATT_PK) - primary key violated
SQL> select * from exceptions;
ROW_ID OWNER TABLE_NAME CONSTRAINT
AAAC/yAAGAAAAAOAAB TEST ATTENDANCE ATT_PK
AAAC/yAAGAAAAAOAAA TEST ATTENDANCE ATT_PK
SQL> select * from attendance where rowid in (select row_id from exceptions);
DEPT_ID ATT_DATE ATT_KIND
100 20-FEB-10 1
100 20-FEB-10 1
SQL>Asif Momen
http://momendba.blogspot.com -
Query to find duplicate records (Urgent!!!!)
Hi,
I have a to load data from a staging table to base table but I dont want to load data already present in the base table. Criteria to identify the duplicate data is thorugh a field say v_id and status_flag. If these two are the same in both staging and base table then that record must be rejected as a duplicate record.
Kindly help me with the SQL which i need to use in a Procedure.
ThanksHello
Another alternative would be to use MINUS if the table structures match:
--Source rows the first 5 are in the destination table
SQL> select * from dt_test_src;
OBJECT_ID OBJECT_NAME
101081 /1005bd30_LnkdConstant
90723 /10076b23_OraCustomDatumClosur
97393 /103a2e73_DefaultEditorKitEndP
106075 /1048734f_DefaultFolder
93337 /10501902_BasicFileChooserUINe
93013 /106faabc_BasicTreeUIKeyHandle
94929 /10744837_ObjectStreamClass2
100681 /1079c94d_NumberConstantData
90909 /10804ae7_Constants
102543 /108343f6_MultiColorChooserUI
92413 /10845320_TypeMapImpl
89593 /10948dc3_PermissionImpl
102545 /1095ce9b_MultiComboBoxUI
98065 /109cbb8e_SpanShapeRendererSim
103855 /10a45bfe_ProfilePrinterErrors
102145 /10a793fd_LocaleElements_iw
98955 /10b74838_SecurityManagerImpl
103841 /10c906a0_ProfilePrinterErrors
90259 /10dcd7b1_ProducerConsumerProd
100671 /10e48aa3_StringExpressionCons
20 rows selected.
Elapsed: 00:00:00.00
--Destination table contents
SQL> select * from dt_test_dest
2 /
OBJECT_ID OBJECT_NAME
101081 /1005bd30_LnkdConstant
90723 /10076b23_OraCustomDatumClosur
97393 /103a2e73_DefaultEditorKitEndP
106075 /1048734f_DefaultFolder
93337 /10501902_BasicFileChooserUINe
Elapsed: 00:00:00.00
--try inserting everything which will fail because of the duplicates
SQL> insert into dt_test_dest select * from dt_test_src;
insert into dt_test_dest select * from dt_test_src
ERROR at line 1:
ORA-00001: unique constraint (CHIPSDEVDL1.DT_TEST_PK) violated
Elapsed: 00:00:00.00
--now use the minus operator to "subtract" rows from the source set that are already in the destination set
SQL> insert into dt_test_dest select * from dt_test_src MINUS select * from dt_test_dest;
15 rows created.
Elapsed: 00:00:00.00
SQL> select * from dt_test_dest;
OBJECT_ID OBJECT_NAME
101081 /1005bd30_LnkdConstant
90723 /10076b23_OraCustomDatumClosur
97393 /103a2e73_DefaultEditorKitEndP
106075 /1048734f_DefaultFolder
93337 /10501902_BasicFileChooserUINe
89593 /10948dc3_PermissionImpl
90259 /10dcd7b1_ProducerConsumerProd
90909 /10804ae7_Constants
92413 /10845320_TypeMapImpl
93013 /106faabc_BasicTreeUIKeyHandle
94929 /10744837_ObjectStreamClass2
98065 /109cbb8e_SpanShapeRendererSim
98955 /10b74838_SecurityManagerImpl
100671 /10e48aa3_StringExpressionCons
100681 /1079c94d_NumberConstantData
102145 /10a793fd_LocaleElements_iw
102543 /108343f6_MultiColorChooserUI
102545 /1095ce9b_MultiComboBoxUI
103841 /10c906a0_ProfilePrinterErrors
103855 /10a45bfe_ProfilePrinterErrors
20 rows selected.You could use that in conjunction with the merge statement to exclude all trully duplicated rows and then update any rows that match on the id but have different statuses:
MERGE INTO dest_table dst
USING( SELECT
v_id,
col1,
col2 etc
FROM
staging_table
MINUS
SELECT
v_id,
col1,
col2 etc
FROM
destination_table
) stg
ON
(dts.v_id = stg.v_id)
WHEN MATCHED THEN....HTH -
How can I find an SQL executed and finished time?
Hi,
Could you please help me I would like to learn started and finished time for SQLs?
If is it possible?
db version: 9.2.0.8
thanks and regards
Edited by: OracleADay on May 12, 2011 4:23 PMIn what term you are asking give little more description
If in term of query executed last time then this link will be helpful
http://forums.oracle.com/forums/thread.jspa?threadID=927452 -
Query to Find what SQL Server services running, what status and with what service account
I need to check what SQL Server services are running(engine,agent,IS,AS,RS,browser and Full text) and what is the present status and what service accounts are been used by them on several servers in a single shot.
Could any one help me in finding a good script for the same.I have been looking for the same thing, the issue I am running into is finding the Actual Service Name. I know this question is old, and I personally do not understand the reply.
so Far I have the following:
DECLARE @ServiceAcount NVARCHAR(128);
SET @Service = 'No Return Value'
--MsDtsServer100 (SSIS)
EXEC master.dbo.xp_regread
'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\services\MsDtsServer100',
'ObjectName',
@ServiceAccount OUTPUT;
SELECT @ServiceAccount;
I am still looking for the correct service naming for Analysis Services, Distributed Replaay Client, Distributed Replay Controller -
Query to find duplicates, update appropriately, delete one of those duplicate
I have duplicate rows in below given table and need to cleanse it by observing another duplicate record.
I'd like to know various ways to achieve it. (I'm confused I should use UPDATE.. (CASE WHEN.. THEN).. or MERGE or something else)
Please find below DDL/DML.
create table MyTable
PKey int identity(1,1),
CustID int,
FirstName varchar(10),
LastName varchar(10),
Main varchar(10),
Department varchar(10)
Insert into MyTable
select 101, 'aaa','bbb','VM','Marketing' union
select 101, '', '','','' union
select 102, '', 'yyy', 'Main', 'Marketing' union
select 102, 'xxx','','','' union
select 103, 'ppp', 'qqq', '', 'HR' union
select 103, '', '', 'MF', '' union
select 104, 'mmm', 'nnn', 'f', 'dept'
select * from mytable
--PKey CustID FirstName LastName Main Department
--2 101 aaa bbb VM Marketing
--3 102 xxx yyy Main Marketing
--6 103 ppp qqq MF HR
--7 104 mmm nnn f dept
Cheers,
Vaibhav ChaudhariHi Vaibhav,
Manu's has copied as a part of the below code.
create table MyTable
PKey int identity(1,1),
CustID int,
FirstName varchar(10),
LastName varchar(10),
Main varchar(10),
Department varchar(10)
Insert into MyTable--(CustID,FirstName,LastName,Main,Department)
select 101, 'aaa','bbb','VM','Marketing' union
select 101, '', '','','' union
select 102, '', 'yyy', 'Main', 'Marketing' union
select 102, 'xxx','','','' union
select 103, 'ppp', 'qqq', '', 'HR' union
select 103, '', '', 'MF', '' union
select 104, 'mmm', 'nnn', 'f', 'dept'
SELECT * FROM MyTable;
;WITH cte AS
SELECT DISTINCT
MAX(PKey) PKey,
CustID,
MAX(FirstName) AS FirstName,
MAX(LastName)AS LastName,
MAX(Main) AS Main,
MAX(Department) AS Department
FROM mytable
GROUP BY CustID
MERGE mytable AS Tar
USING cte AS Src
ON Tar.PKey = Src.PKey
WHEN MATCHED THEN
UPDATE SET Tar.CustID = Src.CustID, Tar.FirstName = Src.FirstName,Tar.LastName = Src.LastName, Tar.Main = Src.Main,Tar.Department = Src.Department
WHEN NOT MATCHED BY SOURCE THEN
DELETE
SELECT * FROM MyTable
DROP TABLE MyTable;
If you do care about the Identity Pkey, as per the expected output, my understanding on your logic is like below.
;WITH cte AS
SELECT PKey, CustID,V1,V2,V3,V4,ROW_NUMBER() OVER(PARTITION BY CustID ORDER BY v1+v2+v3+v4 DESC) AS RN
FROM MyTable
CROSS APPLY(SELECT CASE WHEN FirstName ='' THEN 0 ELSE 1 END AS v1) AS cat1
CROSS APPLY(SELECT CASE WHEN LastName ='' THEN 0 ELSE 1 END AS v2) AS cat2
CROSS APPLY(SELECT CASE WHEN Main ='' THEN 0 ELSE 1 END AS v3) AS cat3
CROSS APPLY(SELECT CASE WHEN Department ='' THEN 0 ELSE 1 END AS v4) AS cat4
,cte2 AS
SELECT DISTINCT
CustID,
MAX(FirstName) AS FirstName,
MAX(LastName)AS LastName,
MAX(Main) AS Main,
MAX(Department) AS Department
FROM mytable
GROUP BY CustID
,cte3 AS
SELECT c2.CustID,c2.FirstName,c2.LastName,c2.Main,c2.Department,c.PKey FROM cte2 c2 JOIN cte c ON c.CustID = c2.CustID WHERE NOT EXISTS(SELECT 1 FROM cte WHERE RN<c.RN)
MERGE mytable AS Tar
USING cte3 AS Src
ON Tar.PKey = Src.PKey
WHEN MATCHED THEN
UPDATE SET Tar.CustID = Src.CustID, Tar.FirstName = Src.FirstName,Tar.LastName = Src.LastName, Tar.Main = Src.Main,Tar.Department = Src.Department
WHEN NOT MATCHED BY SOURCE THEN
DELETE
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Query to find duplicate referance numbers
Dear,
We have somehow managed to create the same sales order twice or more. In the field "Customer Ref. No." we always type in BP's ref. no. So what I need is a query which will show me all open sales orders which have more than one identical "Customer Ref. No." (ORDR.NumAtCard)
So what I got so far is:
SELECT T0.[DocNum], T0.[NumAtCard] FROM ORDR T0 WHERE T0.[DocStatus] <> 'C' AND ????
Hope anyone can help. Thanks.
BR
Kjetil SandvikHi Kjetil Sandvik,
If you want to block Sales Order with duplicare Customer Ref. No then
Try this SP.....
if (@object_type = '17')
and (@transaction_type= 'A' or @transaction_type= 'U')
begin
declare @Refno as varchar(100), @Cust as varchar(100)
if @object_type = '17'
begin
select @Refno = NumAtCard,
@Cust=CardCode
from ordr
where DocEntry =@list_of_cols_val_tab_del
if 1 != (select count(DocEntry) from ordr with(nolock) where NumAtCard = @Refno and CardCode=@Cust)
begin
select @error = 1
select @error_message = 'Customer Ref. No Should Not Be Repeated. ! '
end
end
end
Thanks,
Srujal Patel -
Finding duplicate values in a column with different values in a different c
I'm finding duplicate values in a column of my table:
select ba.CLAIM_NUMBER from bsi_auto_vw ba
group by ba.CLAIM_NUMBER
having count(*) > 1;
How can I modify this query to find duplicate values in that column where I DON'T have duplicate values in a different specific column in that table (the column CLMT_NO in my case can't have duplicates.)?Well, you can use analytics assuming you don't mind full scanning the table.....
select
count(owner) over (partition by object_type),
count(object_type) over (partition by owner)
from all_objects;You just need to intelligently (i didn't here) find your "window" (partition clause) to sort the data over, then make use of that (the analytics would be in a nested SQL and you'd then evaluate it in outside).
Should be applicable if i understand what you're after.
If you post some sample data we can mock up a SQL statement for you (if what i tried to convey wasn't understandable). -
Query to find the Views and synonyms that are accessing through db_link
HI all,
Oracle 10g
I need a Query to find the Views and synonyms that are accessing through db_link.
ie.
database A have the db_link to database B through a schema A
now i need to find what are the Synonyms and views that are accessing through db_link either directly or indirectly..
regards,
Deepak
Edited by: Deepak_DBA on Dec 10, 2010 5:38 PMOn the second database (B) use this query to find the SQL which used by the schema A (DB LINK USER). Check the SQL_FULLTEXT column.
select sql_fulltext,sql_id,module,parsing_schema_name,parsing_user_id,first_load_time,loads,users_executing,rows_processed,plsql_exec_time,sorts,fetches,invalidations,parse_calls,cpu_time,elapsed_time,disk_reads,buffer_gets
from V$sqlarea
where parsing_schema_name = 'A' --and to_char(first_load_time,'dd/mm/yyyy') like '%11/08/2007'
order by first_load_time desc;
Regards
Asif Kabir -
How to find duplicate row in sql query?
Hi All,
Please solve my query, find duplicate row and how to count its. your suggestion would be greatly appreciated.You can use group by and having.
SQL> WITH t
2 AS (SELECT LEVEL id
3 FROM DUAL
4 CONNECT BY LEVEL <= 5
5 UNION ALL
6 SELECT LEVEL + 2
7 FROM DUAL
8 CONNECT BY LEVEL <= 3)
9 SELECT *
10 FROM t;
ID
1
2
3
4
5
3
4
5
8 rows selected.
SQL> WITH t
2 AS (SELECT LEVEL id
3 FROM DUAL
4 CONNECT BY LEVEL <= 5
5 UNION ALL
6 SELECT LEVEL + 2
7 FROM DUAL
8 CONNECT BY LEVEL <= 3)
9 SELECT id, COUNT (*)
10 FROM t
11 GROUP BY id
12 HAVING COUNT (*) > 1;
ID COUNT(*)
3 2
4 2
5 2
SQL> -
SQL Query to find Receipt No.s which are not matched to AP Invoices
Hi
Please help me to frame a query to find list of Receipt No.s which are not matched with AP Invoices.
Please refer to the below query .
SELECT
poh.segment1 "PO No.",
aps.vendor_name "Supplier Name",
pol.item_description "Item Description",
rcvh.receipt_num "GRV No.s",
rcvl.quantity_received "Quantity",
pol.unit_price "Rate/Unit",
rcvtl.tax_name||' - '||initcap(rcvtl.tax_type) "Tax",
(rcvl.quantity_received * pol.unit_price) + nvl(rcvtl.tax_amount,0) "Amount"
FROM
po_headers_all poh,
po_lines_all pol,
po_distributions_all pod,
ap_suppliers aps,
rcv_shipment_headers rcvh,
rcv_shipment_lines rcvl,
rcv_transactions rcvt,
jai_rcv_line_taxes rcvtl
WHERE
poh.po_header_id = pol.po_header_id
AND poh.po_header_id = pod.po_header_id
AND pol.po_line_id = pod.po_line_id
AND aps.vendor_id = poh.vendor_id
AND aps.vendor_id = rcvh.vendor_id
AND rcvh.shipment_header_id = rcvl.shipment_header_id
AND poh.po_header_id = rcvl.po_header_id
AND pol.po_line_id = rcvl.po_line_id
AND rcvh.shipment_header_id = rcvt.shipment_header_id
AND rcvl.shipment_line_id = rcvt.shipment_line_id
AND poh.po_header_id = rcvt.po_header_id
AND pol.po_line_id = rcvt.po_line_id
AND aps.vendor_id = rcvt.vendor_id
AND rcvh.shipment_header_id = rcvtl.shipment_header_id
AND rcvl.shipment_line_id = rcvtl.shipment_line_id
AND rcvt.transaction_id = rcvtl.transaction_id
AND aps.vendor_id = rcvtl.vendor_id
AND rcvt.transaction_type = 'RECEIVE'
AND poh.authorization_status = 'APPROVED'
AND poh.segment1 = '210001079'
I have'nt included the Invoice Tables in the above query.
Please help me in that area.
This is bit urgent.
Please help me.
Regards
Nakul VenkatramanI am using ORACLE 11gR2 If you're licensed for Diangnostics pack then you might want to look at the AWR tables, e.g. DBA_HIST_SQLSTAT and cross-reference with DBA_HIST_SNAPSHOT.
By this will i get the top 5 consumed queries of DEV user in the whole session or its just the top 5 queries at that particular time. The "executions" columns in this query, does it mean that the no. of. times the query has executed... This will get you a random 5 queries that were first parsed by DEV. Depending on your application code/structure, it may well be that all code (except for system-recursive sql) executed by DEV is parsed by DEV, and all code parsed by DEV is executed by DEV but this isn't true for all.
In terms of top N queries, you need to ORDER BY and then restrict by ROWNUM at an outer level to the ROWNUM otherwise the ROWNUM filter is applied before the ORDER BY.
i.e.
SELECT *
FROM
(SELECT ...
FROM ...
WHERE
ORDER BY...)
WHERE ROWNUM <= ....
The "executions" columns in this query, does it mean that the no. of. times the query has executedYes.
http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/dynviews_3064.htm#REFRN30259
Edited by: Dom Brooks on Oct 24, 2011 9:45 AM -
How to find out all SQLs executed by a procedure
I need to find out all SQLs executed by a procedure. I can trace and check but in my case the issue happened 4 hours back and i know what procedure was causing it. There are multiple dynamic queries fired from this procedure. I need to track down all SQLs fired by this procedure constructed dynamically during the time issue was happening.
I have the sql_id of the statement which was executing the procedure. How do I track down all "child" SQLs using this sql_id?
Will appreciate any pointers.
-raviThanks for your suggestion and looking into this.
We already have that functionality built in. Version is 10.2.0.3...But the issue is the proc is called thousands of time in a day and we can not keep the tracking of sqls and parameters passed on all the time. When the issue happened we were not tracking. The bind variables are not captured as the SQL is constructed within the proc by looking up the values dynamically from secondary tables dynamically based on the parameters passed to the procedure. Now the SQLs which are generated from the proc will have the bind variables captured as they will come as predicates and will have no clob types (condition for the binds to be captured).
I need a query to track down all "child" SQLs by using the sql_id of the parent process which is the procedure's sql_id.
Maybe you are looking for
-
How can I reinstall iTunes without losing tune content of my iPod
I had a major Windows system 32 problem and had to reformat my hard drive. (Computer was backed up before incident.) Later, I got a message about a corrupt iTunes driver and found iPod and iTunes in recycle bin. Long story short: I have installed upd
-
Trying to add metadata to a live stream completely fails
Hi. I've been following this document http://help.adobe.com/en_US/flashmediaserver/devguide/WS5b3ccc516d4fbf351e63e3d11a0773d56e -7ff6Dev.html for adding metadata to an FMS live stream from a Flash widget. I've created a stripped-down version of the
-
This is one of those doesnt fit anywhere questions
One of my close friends said she has to move and quit her job and asked me if i wanted to take it over.She is a vendor at the local AAFES Post Exchange.I need to know how many apple classes i must take to become a mac vendor. I am surely overqualifie
-
Buying used MacBook Air @craigslist
Hi there, I plan on buying an MBA from craigslist and would like to know if you folks have any advice on buying a used MBA. I'm making a check list on what to inspect when I see the MBA. Obviously, google is gold, but there is so much content there t
-
How to integrate Sharepoint into EP7.0?
Experts: We have a requirement to make our company portal as the entry point of Sharepoint where tons of documentation resides. At the same time, we want that the Trex on our EP can index the document on Sharepoint. Could you direct me to some how-to