oracle11gr2

Desired output with given table data

混江龙づ霸主 提交于 2019-12-01 06:14:41
问题 Hi I have a table test its structure is given below: **Testing** PK C1 c2 --------------- 1 v11 v12 2 v21 v23 3 v31 v32 Now I need to query this table (testing) such that I get the below output. Pk Key value --------------- 1 c1 v11 1 c1 v12 2 c2 v21 2 c2 v22 3 c3 v31 3 c3 v32 Can this been possible with sql query in Oracle 11g ,Is it possible with PIVOT feature in 11g? 回答1: No, it can't be done with PIVOT , but it can be done with UN PIVOT: SELECT Pk, "Key", value FROM Testing UNPIVOT (

Oracle 11G - Performance effect of indexing at insert

ぐ巨炮叔叔 提交于 2019-11-30 22:53:35
Objective Verify if it is true that insert records without PK/index plus create thme later is faster than insert with PK/Index. Note The point here is not about indexing takes more time (it is obvious), but the total cost (Insert without index + create index) is higher than (Insert with index). Because I was taught to insert without index and create index later as it should be faster. Environment Windows 7 64 bit on DELL Latitude core i7 2.8GHz 8G memory & SSD HDD Oracle 11G R2 64 bit Background I was taught that insert records without PK/Index and create them after insert would be faster than

Oracle 11G - Performance effect of indexing at insert

非 Y 不嫁゛ 提交于 2019-11-30 17:53:37
问题 Objective Verify if it is true that insert records without PK/index plus create thme later is faster than insert with PK/Index. Note The point here is not about indexing takes more time (it is obvious), but the total cost (Insert without index + create index) is higher than (Insert with index). Because I was taught to insert without index and create index later as it should be faster. Environment Windows 7 64 bit on DELL Latitude core i7 2.8GHz 8G memory & SSD HDD Oracle 11G R2 64 bit

Oracle Shutdown error ORA-01033

拟墨画扇 提交于 2019-11-28 14:25:02
I had installed Oracle 11g on windows 07,everything was working fine.But today it is giving me an error saaying ORA-01033: ORACLE initialization or shutdown in progress . I followed the steps mentioned in the different communities but unable to solve the error. After connecting as sqlplus sys/sys as sysdba . and executing below statement,i got following error. How to solve this error? SQL> recover database; ORA-00283: recovery session canceled due to errors ORA-01110: data file 9: 'C:\APP\MKHATAL\ORADATA\ORCL\VELODBDATA.DBF' ORA-01157: cannot identify/lock data file 9 - see DBWR trace file ORA

issue with to_date function with sysdate

被刻印的时光 ゝ 提交于 2019-11-28 14:12:14
I saw this question so I've one doubt regarding this question: I am getting different result with the same date on the following query. SELECT TO_CHAR(to_date(sysdate, 'DD-MON-yy'), 'DAY'), TO_CHAR(to_date(sysdate, 'DD-MON-yyyy'), 'DAY'), TO_CHAR(to_date(sysdate, 'DD-MON-rr'), 'DAY'), TO_CHAR(to_date(sysdate, 'DD-MON-rrrr'), 'DAY') FROM dual; output as column-wise: TUESDAY SUNDAY TUESDAY TUESDAY please help me, Thanks in advance. EDIT I wrote a simple procedure which passing date for finding the day given below: SET serveroutput ON; CREATE OR REPLACE PROCEDURE simple_test ( date_in IN VARCHAR2

How to create an oracle.sql.ARRAY object?

笑着哭i 提交于 2019-11-28 12:21:09
This question is related to my original issue How to return an array from Java to PL/SQL ? , but is a more specific. I have been reading Oracle Database JDBC Developer's Guide and Creating ARRAY objects Server-Side Internal Driver oracle.jdbc.OracleConnection oracle.jdbc.OracleDriver but I still fail to write a minimum code where I can create ARRAY using ARRAY array = oracle.jdbc.OracleConnection.createARRAY(sql_type_name, elements); as instructed in Creating ARRAY objects . I'm using Oracle Database JVM. I have tried following: Example 1 create or replace type widgets_t is table of varchar2

Setting a value for LIMIT while using bulk collect

a 夏天 提交于 2019-11-28 10:36:16
I wanted to know if we have any technique by which we can calculate the value which needed to be set for a LIMIT clause of bulk collect operation. For example below, lets say our cursor has 10 Million records..What is the value which we can set for LIMIT clause to have optimum performance. Is there any way we can calculate it. decalre cursor c_emp is <some select query> var <variable> ; begin open c_emp; loop fetch c_emp bulk collect into var limit 2; exit when c_emp%NOTFOUND; end loop; close c_emp; end; Use an implicit cursor in a cursor FOR LOOP. It makes the code simpler and the default

How to pass date/timestamp as lowerBound/upperBound in spark-sql-2.4.1v with ojdbc14.jar?

a 夏天 提交于 2019-11-28 10:08:09
问题 I'm using spark-sql-2.4.1v and ojdbc6.jar to read data from oracle. Have oracle table as below create table schema1.modal_vals( FAMILY_ID NOT NULL NUMBER, INSERTION_DATE NOT NULL DATE, ITEM_VALUE VARCHAR2(4000), YEAR NUMBER, QUARTER NUMBER, LAST_UPDATE_DATE DATE ) Load sample data : insert into modal_vals(FAMILY_ID,INSERTION_DATE,ITEM_VALUE,YEAR,QUARTER,LAST_UPDATE_DATE) values(2,"30-JUN-02","bbb-",2013,2,null); insert into modal_vals(FAMILY_ID,INSERTION_DATE,ITEM_VALUE,YEAR,QUARTER,LAST

passing table and column name dynamically using bind variables

淺唱寂寞╮ 提交于 2019-11-27 15:22:58
Is there a way to pass column and table names dynamically to a query using bind variables? This could be done by using a simple concatenation operator || , but I would like a different approach by which this can be achieved. EDIT OPEN abc_cur FOR 'Select :column_name from :table_name' USING column_name,table_name; In this example I am passing column_name as empno,ename and table_name as emp But this approach is not working for me. Is it possible to have a different approach other that the traditional approach of concatenation? Table and column names cannot be passed as bind variables, no. The

Oracle Shutdown error ORA-01033

混江龙づ霸主 提交于 2019-11-27 08:40:46
问题 I had installed Oracle 11g on windows 07,everything was working fine.But today it is giving me an error saaying ORA-01033: ORACLE initialization or shutdown in progress . I followed the steps mentioned in the different communities but unable to solve the error. After connecting as sqlplus sys/sys as sysdba . and executing below statement,i got following error. How to solve this error? SQL> recover database; ORA-00283: recovery session canceled due to errors ORA-01110: data file 9: 'C:\APP