oracle11g

how to find number of times query executed?

余生颓废 提交于 2019-12-08 05:30:06
问题 I have few queries running in Oracle 11g database from application those are repeatable queries. I want to find number of times the query executed for the day and time it took for each execution based on sql_id or sql_text? Is there a way to find this? 回答1: The number of executions is in the AWR reports. Which means it can probably also be derived from a DBA_HIST_ table but I don't know which one. Based on your previous question I assume you have AWR licensed. --Find the SQL_ID. If not in

ORA-02253: constraint specification not allowed here

半城伤御伤魂 提交于 2019-12-08 05:11:15
问题 create table log_table( log_id varchar2(1000) primary key, voter_ID varchar2(1000), date_logged date CONSTRAINT abc FOREIGN KEY (voter_ID) REFERENCES voters(voter_ID) ) The table works when i create it without date element. But when i add the date element to it says: ORA-02253: constraint specification not allowed here 回答1: The table works when i create it without date element create table log_table( log_id varchar2(1000) primary key, voter_ID varchar2(1000), -- comma CONSTRAINT abc FOREIGN

Oracle issue with reporting SQL

£可爱£侵袭症+ 提交于 2019-12-08 04:57:28
问题 I have a reporting SQL in Oracle which is using the SUM function. Table Y CLIENT_NUM LOCATION_CODE EFFECTIVE_DATE EXPIRY_DATE 1234 AB01 1/1/2011 6/30/2014 1234 AB01 7/1/2014 8/31/2014 1234 AB01 9/1/2014 6/30/2015 1234 AB66 1/1/2011 6/30/2014 1234 AB66 7/1/2014 8/31/2014 1234 AB66 9/1/2014 6/30/2015 Table X CLIENT_NUM LOCATION_CODE EMPLOYEE_COUNT TOTAL_HOURS_WORKED REPORTING_YEAR 1234 AB01 600 12000 2014 1234 AB66 50 11000 2014 SQL: SELECT SUM(x.EMPLOYEE_COUNT) OVER (PARTITION BY CASE ':input

ORA-24778: cannot open connections

限于喜欢 提交于 2019-12-08 04:52:43
问题 I am getting the ORA-24778: cannot open connections , what are the possible causes? We have a number of applications deployed in WAS7 profile and they connect to a number of schemas in Oracle 11g. One of the schema is connecting through other schema via public DB link. I cannot identify a solution for this cause. After restarting the WAS7 profile, it is ok for a while and again start hitting the error. Pls help!! 回答1: I assume you missed to tell us a few details: You are using XA You are

Union causing an ORA-01790: expression must have same datatype as corresponding expression

ⅰ亾dé卋堺 提交于 2019-12-08 04:42:30
With the following query as an example: select p.product_id, p.product_name, product_type as product_type, from products group by p.product_id, p.product_name union select p.product_id, p.product_name, cast(collect(coalesce(product_type, decode(product_description,null,'DESCR' || '-' product_description) as my_type) as product_type, from products group by p.product_id, p.product_name The select statement in the first query returns product_type as a varchar and on the second query product_type is of type my_type. This is causing and ORA-01790: expression must have same datatype as corresponding

JPA and 1000 ID use in Oracle IN Operator

时间秒杀一切 提交于 2019-12-08 04:11:10
问题 I use NamedNativeQuery for delete rows, and it's somthing like this: DELETE from FAKTOR where ID IN ( select fa.ID from FAKTOR fa left join FAKTOR_REASON fars on fa.FARS_ID = fars.ID where fars.ID = 63 and fa.USER_ID in (:userIds)) But How i can use more that 1000 userIds with IN Operator at Oracle where clues? P.S: I'm looking for a solution to handle it in one commit; 回答1: Working around the IN limit is inefficient and JPA is not always the right tool for the job. Consider the following:

Will moving a table/partition to a different tablespace interrupt queries accessing said table/partition?

梦想的初衷 提交于 2019-12-08 03:54:50
问题 As the title says: will moving (without renaming) a table/partition while it's being accessed have negative consequences on any queries accessing it? For example, say there's a long-running SELECT COUNT(*) FROM some_table . If I were to ALTER TABLE some_table MOVE TABLESPACE some_other_tablespace , would the SELECT fail? Would it complete, but have incorrect results? Maybe something else entirely? The only info I could find was that moving the table to a different tablespace would require

Oracle stored procedure, returning ref cursor vs associative arrays

♀尐吖头ヾ 提交于 2019-12-08 03:45:15
问题 Our DBA requires us to return all tabular data from stored procedures in a set of associative arrays rather than using a ref cursor which is what I see in most examples on the web. He says this is because it is much faster for Oracle to do things this way, but it seems counter intuitive to me because the data needs to be looped over twice, once in the stored procedure and then again in the application when it is processes. Also, values often need to be casted from their native types to

Finding Duplicate Data in Oracle

…衆ロ難τιáo~ 提交于 2019-12-08 03:39:56
问题 I have a table with 500,000+ records, and fields for ID, first name, last name, and email address. What I'm trying to do is find rows where the first name AND last name are both duplicates (as in the same person has two separate IDs, email addresses, or whatever, they're in the table more than once). I think I know how to find the duplicates using GROUP BY, this is what I have: SELECT first_name, last_name, COUNT(*) FROM person_table GROUP BY first_name, last_name HAVING COUNT(*) > 1 The

compiling invalid oracle procedures

雨燕双飞 提交于 2019-12-08 03:26:16
问题 I have a wrapper procedure(proc_main) that calls some procedures within. create or replace Procedure proc_main as begin proc_child1; proc_child2; proc_child3; proc_compile_invalids; -- This invokes "alter procedure <procedure_name> compile" statement for all the invalids. end; / proc_child procedures apply some processing logic that involves some steps to rename the tables within. This invalidates the procedures which is the reason why I have the proc_compile_invalids procedure to set them to