dbTalk Databases Forums  

usage of calculated index with a synonym for the function

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss usage of calculated index with a synonym for the function in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Norbert Winkler
 
Posts: n/a

Default usage of calculated index with a synonym for the function - 12-14-2009 , 09:33 AM






Hi,

in a large table OUR_TABLE we have a calculated index for a persons-name
with a simple soundex function OUR_SOUNDEX in the same schema (OUR_SCHEMA)
like the table, thats different to my "select"-schema (WORK_SCHEMA):
....
from OUR_SCHEMA.OUR_TABLE d
where OUR_SCHEMA.OUR_SOUNDEX(d.PERSON_NAME) =
OUR_SCHEMA.OUR_SOUNDEX('Meier, Hans');

But for building a testing environment schema-names are different
(OUR_SCHEMA --> TEST_SCHEMA, WORK_SCHEMA --> WORK_TEST)

Now I'm trying to create universal scripts with synonyms:

in WORK_SCHEMA
CREATE OR REPLACE SYNONYM OUR_SCHEMA_OUR_SOUNDEX
FOR OUR_SCHEMA.OUR_SOUNDEX;

in WORK_TEST
CREATE OR REPLACE SYNONYM OUR_SCHEMA_OUR_SOUNDEX
FOR TEST_SCHEMA.OUR_SOUNDEX;

But
...
from OUR_SCHEMA_OUR_TABLE d
where OUR_SCHEMA_OUR_SOUNDEX(d.PERSON_NAME) =
OUR_SCHEMA_OUR_SOUNDEX('Meier, Hans');

uses a full table scan in WORK_SCHEMA and TEST_SCHEMA.

Is there another way to create universal scripts.

--
Norbert
Oracle9i Enterprise Edition Release 11.2 64Bit

Reply With Quote
  #2  
Old   
Lisa
 
Posts: n/a

Default Re: usage of calculated index with a synonym for the function - 12-22-2009 , 01:09 PM






On Dec 14, 10:33*am, Norbert Winkler <norbert.winkl... (AT) gmx (DOT) de> wrote:
Quote:
Hi,

in a large table OUR_TABLE we have a calculated index for a persons-name
with a simple soundex function OUR_SOUNDEX in the same schema (OUR_SCHEMA)
like the table, thats different to my "select"-schema (WORK_SCHEMA):
...
from OUR_SCHEMA.OUR_TABLE d
where OUR_SCHEMA.OUR_SOUNDEX(d.PERSON_NAME) =
* * * OUR_SCHEMA.OUR_SOUNDEX('Meier, Hans');

But for building a testing environment schema-names are different
(OUR_SCHEMA --> TEST_SCHEMA, WORK_SCHEMA --> WORK_TEST)

Now I'm trying to create universal scripts with synonyms:

in WORK_SCHEMA
CREATE OR REPLACE SYNONYM OUR_SCHEMA_OUR_SOUNDEX
* FOR OUR_SCHEMA.OUR_SOUNDEX;

in WORK_TEST
CREATE OR REPLACE SYNONYM OUR_SCHEMA_OUR_SOUNDEX
* FOR TEST_SCHEMA.OUR_SOUNDEX;

But
..
from OUR_SCHEMA_OUR_TABLE d
where OUR_SCHEMA_OUR_SOUNDEX(d.PERSON_NAME) =
* * * OUR_SCHEMA_OUR_SOUNDEX('Meier, Hans');

uses a full table scan in WORK_SCHEMA and TEST_SCHEMA.

Is there another way to create universal scripts.

--
Norbert
Oracle9i Enterprise Edition Release 11.2 64Bit
Wooooooooow nobody answered you!
You could use this SQL to find out what schema you're in:
SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual;

(that'll tell if youre in work_schema or test_schema)

Then you can do an execute immediate and create the index.
Here's the code:
declare
v_name varchar2(100);
v_sql varchar2(200);
begin
SELECT sys_context('USERENV', 'CURRENT_SCHEMA') into v_name FROM dual;
v_sql := 'CREATE OR REPLACE SYNONYM OUR_SCHEMA_OUR_SOUNDEX FOR ' ||
v_name || '.OUR_SOUNDEX;' ;
dbms_output.put_line (v_sql);
execute immediate v_sql;
end;

Hope that helps.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.