oracle10g

Oracle - Materialized View alter structure so slow

社会主义新天地 提交于 2019-12-04 03:59:04
问题 I have a huge materailized view that I have to adjust. It's a simple adjustment as I'm just adding an NVL function to the select statement. I.e. Original... Select this, that..... I.e. Modified Select NVL(this, orThat) as this, NVL(That, orThis) as that The query takes 26 seconds to run, but due to the amount of rows retrieved (2.3 million) it is dead slow. It ran for almost 5 days straight and then I stopped it. This is a problem, especially since I need to deliver this to a client, and they

Sorting records from Oracle with multiple decimal points (.)

不羁岁月 提交于 2019-12-04 03:50:24
UPDATE: ORACLE VERSION 10G I have a list of records in Oracle as follows, these are actually sections of various books The records are generated in the below format [main topic].[sub topic].[first level section] ..... .[last level section] Sections -------- 1 7.1 6.2 7.1 7.4 6.8.3 6.8.2 10 1.1 7.6 6.1 11 8.3 8.5 1.1.2 6.4 6.6 8.4 1.1.6 6.8.1 7.7.1 7.5 7.3 I want to order this like as follows 1 1.1 1.1.2 1.1.6 6.2 6.4 6.5 6.6 6.7 6.8.1 6.8.2 6.8.3 7.2 7.3 7.4 7.5 7.6 7.7.1 7.7.2 8.3 8.4 8.5 10 But as the field is not a numeric datatype the sorting results in something like this 1 10 1.1 1.1.2 1

Foreign Key with NO primary key to refer

时间秒杀一切 提交于 2019-12-04 03:47:47
问题 I have following two tables. CREATE TABLE parent ( c1 INTEGER ); CREATE TABLE child ( c1 INTEGER, c2 INTEGER, c3 INTEGER, CONSTRAINT fk_c3 FOREIGN KEY(c3) REFERENCES parent(c1) ); You must have noticed that column c1 is NOT a primary key in Parent table. Is there any way to refer it in Child table without making c1 as a primary key? 回答1: Is there any way to refer it in Child table without making 'c1' as a primary key? Yes. A foreign key needs only to refer to a unique constraint - it does not

How to sort an associative array in PL/SQL?

て烟熏妆下的殇ゞ 提交于 2019-12-04 03:33:12
问题 I have an associative array like this: continent_population('Australia') := 30; continent_population('Antarctica') := 90; continent_population('UK') := 50; How do I sort this array after values in PL/SQL? Thanks! 回答1: You can't sort an associative array by values, but you have to convert the data to some other data structure and make the sorting there. The easiest way would have been to convert to another associative array where keys and values swap places, but that requires your key values

display select results inside anonymous block

橙三吉。 提交于 2019-12-04 03:11:55
I'm trying to debug a SELECT inside a procedure, and I'm trying to this using a anonymous block. I would like that SQL Developer simply return the last SELECT statement, but I get the error: ORA-06550: line 21, column 5: PLS-00428: an INTO clause is expected in this SELECT statement Inside the procedure, I have an INTO for that select, but is there a simple way that I can simply get the results for the last SELECT statement for my debugging? I'm using anonymous block and variables so that the code is as similar as possible from what's actually inside the procedure, so that I don't have to

Oracle query using 'like' on indexed number column, poor performance

落花浮王杯 提交于 2019-12-04 03:08:46
On Query 1 a full table scan is being performed even though the id is an indexed column. Query 2 achieves the same result but much faster. If Query 1 is run returning an indexed column then it returns quickly but if non-indexed columns are returned or the entire row is then the query takes longer. In Query 3 it runs fast but the column 'code' is a VARCHAR2(10) in stead of a NUMBER(12) and is indexed the same way as 'id'. Why does Query 1 not pick up that it should use the index? Is there something that should be changed to allow indexed number columns to perform quicker? [Query 1] select a1.*

Granting “Create Directory” Privileges in Oracle

久未见 提交于 2019-12-04 02:41:01
I want to run a CREATE DIRECTORY query in Oracle 10, but it's giving me an insufficient privileges error. Can anybody tell me how to grant this privilege to my user through the system as a user? From the Oracle 10gR2 documentation : You must have CREATE ANY DIRECTORY system privilege to create directories. You would use the following command to grant the privilege to the schema that will create the directory: SQL> GRANT CREATE ANY DIRECTORY TO vnz; Grant succeeded As always with the privileges ANY , be careful who you will grant them to. It is indeed a powerful privilege best left to DBAs.

SQL - Multiple Values comma separated when using GROUP BY [duplicate]

大城市里の小女人 提交于 2019-12-04 02:29:32
This question already has answers here : Closed 5 years ago . How can I combine multiple rows into a comma-delimited list in Oracle? [duplicate] (11 answers) I have data that looks like CUSTOMER, CUSTOMER_ID, PRODUCT ABC INC 1 XYX ABC INC 1 ZZZ DEF CO 2 XYX DEF CO 2 ZZZ DEF CO 2 WWW GHI LLC 3 ZYX I'd like to write a query that'd make the data look like this: CUSTOMER, CUSTOMER_ID, PRODUCTS ABC INC 1 XYX, ZZZ DEF CO 2 XYX, ZZZ, WWW GHI LLC 3 ZYX Using Oracle 10g if helps. I saw something that would work using MYSQL, but I need a plain SQL or ORACLE equivalent. I've also seen examples of stored

Why do I get PLS-00302: component must be declared when it exists?

喜你入骨 提交于 2019-12-04 02:02:28
I am using Oracle 10.2. I am working in some scripts to move some ORACLE Objects from one SCHEMA (S1) to another (S2). I am creating the functions with DBA role. When moved, one of my functions becomes invalid, but I don't understand why. Its code goes along these lines: MY_FUNC CREATE OR REPLACE FUNCTION S2."MY_FUNC" RETURN VARCHAR2 IS something VARCHAR2; othervar VARCHAR2 (50):= 'TEST'; BEGIN something := S2.MY_FUNC2(); /*some code*/ return othervar; END; / If I use MY_FUNC2 without the schema, It works: something := MY_FUNC2(); instead of something := S2.MY_FUNC2(); My_FUNC2 CREATE OR

PL/SQL use VARRAY in IN CLAUSE

醉酒当歌 提交于 2019-12-04 01:00:05
问题 Is it possible to use VARRAY in IN CLAUSE of pl/sql? 回答1: Yes, you can, provided that the VARRAY type is a global type (and not local to some PL/SQL code): CREATE OR REPLACE TYPE str_tab_type IS VARRAY(10) OF VARCHAR2(200); DECLARE l_str_tab str_tab_type; l_count NUMBER; BEGIN l_str_tab := str_tab_type(); l_str_tab.extend(2); l_str_tab(1) := 'TABLE'; l_str_tab(2) := 'INDEX'; SELECT COUNT(*) INTO l_count FROM all_objects WHERE object_type IN (SELECT COLUMN_VALUE FROM TABLE(l_str_tab)); END; /