oracle11g

Window functions SORT costly, can we overcome it?

若如初见. 提交于 2019-12-06 06:18:22
问题 My Requirement: Identify top 10 accounts of a DEPT_NUM , ordered by the account number in ascending order. Query: SELECT * FROM ( select acctnum,dept_num,row_number() OVER (PARTITION BY DEPT_NUM ORDER BY ACCTNUM) as row_identifier FROM MYTABLE ) WHERE row_identifier between 1 and 10; Trace: 7532 rows selected. Execution Plan ---------------------------------------------------------- Plan hash value: 1480074522 -----------------------------------------------------------------------------------

Query which will give a list of dates between two date ranges

风格不统一 提交于 2019-12-06 05:56:22
问题 My question is similar to following question: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:14582643282111 The difference is my inner query returns two records and I have outer query. I need to write inner query something like this which will give me a list of dates between two date ranges (I am trying this query whcih does not execute). Select * from outerTable where my_date in ( select to_date(r.REQ_DATE) + rownum -1 from all_objects, (MY_INNER_QUERY Where ID =100) r

Oracle specific timestamp format 'DD-MON-RR HH.MI.SSXFF AM'

廉价感情. 提交于 2019-12-06 05:54:20
问题 I have a problem with Oracle 11g specific timestamp format. This is what I have: select to_timestamp('21-OCT-15 08.24.30.000000000 PM','DD-MON-RR HH.MI.SSXFF AM') from dual; Response from database: ORA-01855: AM/A.M. or PM/P.M. required 01855. 00000 - "AM/A.M. or PM/P.M. required" I have also tried to alter session settings with several commands and still nothing. alter session set NLS_LANGUAGE='ENGLISH'; alter session set NLS_DATE_LANGUAGE='ENGLISH'; alter session set NLS_TIMESTAMP_FORMAT =

Spring Batch DataSourceTransactionManager fails on Oracle

六眼飞鱼酱① 提交于 2019-12-06 05:40:28
I'm using WebLogic 10.3.3 with Oracle 11g and face a weird problem with Spring Batch as soon as I'm switching from Spring ResourcelessTransactionManager (which is mainly for testing) to the productive DataSourceTransactionManager . First I used WebLogics default driver oracle.jdbc.xa.client.OracleXADataSource but this one fails because Spring can't set the isolation level - this is also documented here . I'm fine with that since I don't need global transactions anyway so I switched to oracle.jdbc.driver.OracleDriver . Now I'm getting the error message ORA-01453: SET TRANSACTION must be first

Oracle — Import data into a table with a different name?

烈酒焚心 提交于 2019-12-06 05:25:02
问题 I have a large (multi-GB) data file exported from an Oracle table. I want to import this data into another Oracle instance, but I want the table name to be different from the original table. Is this possible? How? Both importing and exporting systems are Oracle 11g. The table includes a BLOB column, if this makes any difference. Thanks! UPDATES : The idea here was to update a table while keeping the downtime on the system that's using it to a minimum. The solution (based on Vincent Malgrat's

join condition “ON” vs in “WHERE”

橙三吉。 提交于 2019-12-06 05:00:17
SELECT * FROM Customers c INNER JOIN CustomerAccounts ca ON ca.CustomerID = c.CustomerID AND c.State = 'NY' INNER JOIN Accounts a ON ca.AccountID = a.AccountID AND a.Status = 1 Equivalent: SELECT * FROM Customers c INNER JOIN CustomerAccounts ca ON ca.CustomerID = c.CustomerID INNER JOIN Accounts a ON ca.AccountID = a.AccountID WHERE c.State = 'NY' AND a.Status = 1 Left Join: SELECT * FROM Customers c LEFT JOIN CustomerAccounts ca ON ca.CustomerID = c.CustomerID AND c.State = 'NY' LEFT JOIN Accounts a ON ca.AccountID = a.AccountID AND a.Status = 1 Equivalent: SELECT * FROM Customers c LEFT

Deleting a large number of records using PL/SQL

流过昼夜 提交于 2019-12-06 04:48:36
I want to delete a large number of records using PL/SQL. The records are identified by a DATE field that identifies the last time the record was modified. I don't want to consume too many resources, so I thought that I should limit the number of records that were being deleted and it seemed to me that the pseudo column ROWNUM could server that purpose. I then check the number of rows effected by the update and repeat until the number of rows effected is 0. I'm looking for a recommendation for the best practice in doing this. I am also concerned about the warning that I am getting: "A loop that

How to order by case insensitive ASC or DESC, with DISTINCT and UNION

ε祈祈猫儿з 提交于 2019-12-06 04:43:28
问题 How to order by case insensitive ASC or DESC for P/L sql 11g. this p/l sql basic question but i can't find good answer in Google please tell how to sort the select result case insensitive this what i tried SELECT DISTINCT asssss, saas_acc FROM DUAL UNION SELECT '--ALL--','ALL' FROM DUAL ORDER BY upper(asssss) ASC ; that gave to me ORA-01785: ORDER BY item must be the number of a SELECT-list expression 回答1: DISTINCT actually filtered the UNIQUE content in the result set, with whatever

Switching users on a JDBC Connection

▼魔方 西西 提交于 2019-12-06 04:42:46
问题 I am writing a Java JDBC database application that connects to an Oracle 11g database and am using a c3p0 connection pool. For the purposes of an example, I have 3 database users DEFAULT, TOM, and BILL. c3p0 opens all of the pooled Connections with the DEFAULT database user. I would like to retrieve one of the pooled Connections from c3p0 and change the user for the Connection to be BILL instead of DEFAULT. Is it possible to do this in JDBC without establishing a new connection with the

Get last insert id with Oracle 11g using JDBC

删除回忆录丶 提交于 2019-12-06 04:36:37
问题 I'm new to using Oracle so I'm going off what has already been previously answered in this SO question. I just can't seem to get it to work. Here's the statement that I'm using: declare lastId number; begin INSERT INTO "DB_OWNER"."FOO" (ID, DEPARTMENT, BUSINESS) VALUES (FOO_ID_SEQ.NEXTVAL, 'Database Management', 'Oracle') RETURNING ID INTO lastId; end; When I call executeQuery the PreparedStatement that I have made, it inserts everything into the database just fine. However, I cannot seem to