Oracle 11g spatial query

An Oracle 11g spatial database with 5 features in it. A doughnut, triangle, line, trapezium, pentagon.
I want to query what coordinates of features exist in a rectange box including the last point that intersects the rectangle box.
It really difficult to explain without pictures. Please look at this page.
http://www.h2ss.co.uk/q/question.jsp
Thanks, I appreciate it.

Thanks for the replies.
I acknowledge that what bkzar and jsharma say will work. But in real terms it is impractical for me to create a new table with the SDO_GEOMETRY's. I have over a thousand polygons, each with over 5000 points in my spatial table.
Let me give you a background to what I am trying to achieve.
I am trying to extract features from 11g and render them on Google Maps. However some of my polygons are huge and have over 5000 points, Google cannot render them effectively, however Google does give me the coordinates of the visible view, i.e the current rectangle view.
My idea was that if you are zoomed right into Google Map and a particular feature intersects the rectangle view than I can query for a portion of the feature, including the first and last points that fall outside of the rectangle box.
I need to be able to somehow filter the SDO_GEOMETRY that don't exist in the rectangle box.
Thanks

Similar Messages

  • Oracle 11g unpivot query help

    Hello,
    I have a single row of data showing school term start and end dates in 2011/12. I need to convert this single row of data (containing 16 columns) into 5 rows comprised of just 4 columns (year, term, term_start, term_end).
    Is it possible to use just Oracle 11g's unpivot function_ to convert the following 16 columns of data:
    select * from
    (select 2012 as terms_year,
    1 as T1,'05-SEP-2011' as T1_SD, '21-OCT-2011' as T1_ED,
    2 as T2,'31-OCT-2011' as T2_SD, '16-DEC-2011' as T2_ED,
    3 as T3,'03-JAN-2012' as T3_SD, '10-FEB-2012' as T3_ED,
    4 as T4,'20-FEB-2012' as T4_SD, '30-APR-2012' as T4_ED,
    5 as T5,'16-APR-2012' as T5_SD, '01-JUN-2012' as T5_ED
    from dual) mytable
    aka
    TERMS_YEAR             T1                     T1_SD       T1_ED       T2                     T2_SD       T2_ED       T3                     T3_SD       T3_ED       T4                     T4_SD       T4_ED       T5                     T5_SD       T5_ED      
    2012                   1                      05-SEP-2011 21-OCT-2011 2                      31-OCT-2011 16-DEC-2011 3                      03-JAN-2012 10-FEB-2012 4                      20-FEB-2012 30-APR-2012 5                      16-APR-2012 01-JUN-2012 into the following 4 columns of data (year, term, term_start, term_end):
    select terms_year, term, t1_sd as term_start, t1_ed as term_end from
    (select 2012 as terms_year, 1 as term, '05-SEP-2011' as T1_SD, '21-OCT-2011' as T1_ED from dual union all
    select 2012 as terms_year, 2 as term, '31-OCT-2011' as T2_SD, '16-DEC-2011' as T2_ED from dual union all
    select 2012 as terms_year, 3 as term, '03-JAN-2012' as T3_SD, '10-FEB-2012' as T3_ED from dual union all
    select 2012 as terms_year, 4 as term, '20-FEB-2012' as T4_SD, '30-APR-2012' as T4_ED from dual union all
    select 2012 as terms_year, 5 as term, '16-APR-2012' as T5_SD, '01-JUN-2012' as T5_ED from dual) mytable
    aka
    TERMS_YEAR             TERM                   TERM_START  TERM_END   
    2012                   1                      05-SEP-2011 21-OCT-2011
    2012                   2                      31-OCT-2011 16-DEC-2011
    2012                   3                      03-JAN-2012 10-FEB-2012
    2012                   4                      20-FEB-2012 30-APR-2012
    2012                   5                      16-APR-2012 01-JUN-2012 Much obliged if anyone can teach me how - I can't get my head around the pivot/unpivot syntax! E.g.
    Select *
    From mytable
    UNPIVOT (
    unpivot_clause
    unpivot_for_clause
    unpivot_in_clause)
    Thanks,
    TP.

    Hi,
    Using the SELECT ... PIVOT feature:
    SELECT       terms_year
    ,       term
    ,       term_start
    ,       term_end
    FROM       mytable
    UNPIVOT       (  ( term
              , term_start
              , term_end
              )     FOR num_col
                 IN ( (t1, t1_sd, t1_ed)     AS 1
                 , (t2, t2_sd, t2_ed)     AS 2
                 , (t3, t3_sd, t3_ed)     AS 3
                 , (t4, t4_sd, t4_ed)     AS 4
                 , (t5, t5_sd, t5_ed)     AS 5
    ORDER BY  terms_year     -- If needed
    ,            num_col
    ;The basic syntax for UNPIVOTing to 1 column (plus a label column) is
    UNPIVOT (    outcol
         FOR  label     IN ( incol_1  AS label_val_1
                           , incol_2  AS label_val_2
                      , incol_n  AS label_val_n
         )where
    outcol       is the pivoted output column, containing values from the original table,
    label       is a label column, which will contain values hard-coded in the query,
    incol_1, incol_2, ..., incol_n       are the columns from the origianl table to be unpivoted
    label_val_1, label_val_2, ..., label_val_n       are the hard-coded values that will go in the label column.
    The syntax for pivoting to m columns (m > 1) is like that for pivoting 1 column, but
    instead of outcol, you give a comma-delimited list of m outcols, enclosed in parentheses, and
    instead of incol_1, incol_2, ... incol_n, you give a comma-delimited list of m columns, enclosed in parentheses.
    By the way, storing dates in VARCHAR2 columns is not a very good idea. Use DATE columns instead.
    Edited by: Frank Kulash on Jul 16, 2012 6:11 PM

  • Oracle 11g/R2 Query Result Cache - Incremental Update

    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AM

    965300 wrote:
    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AMNo, the RESULT CACHE operation doesn't necessarily mean that the results are retrieved from there. It could be being
    written to there.
    Look at the number of consistent gets: it's zero in the first step (I assume you had already run this query before) and I would
    conclude that the data is being read from the result cache.
    In the third step there are 4 consistent gets. I would conclude that the data is being written to the result cache, a fourth step repeating
    the SQL should show zero consistent gets and that would be the results being read.

  • Oracle 11g : UTL_FILE query

    Hi,
    I am having 2 server. One server has oracle database while on another one is application server where all the data files and application specific shell scripts are kept. We are connecting to database via the application server.
    I am using Oracle 11g:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE 11.1.0.6.0 Production
    TNS for HPUX: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    I know that using UTL_FILE in PL/SQL procedure we can create file on the server (where oracle is installed).
    My requirement is generated some report which will involve writing to more than 2 files simultaneously. I know I can easily do this in PL/SQL procedure.
    But my issue is that due to space issue I cannot generate the files on database server and need to generate the same on the application one (client side)
    Queries:
    1] Is it also possible to create file on client machince instead of server in my case the application server via PL/SQL because I read that in Oracle 11g
    UTL_FILE provides file access both on the client side and on the server side.
    2] If yes any idea, how is this possible?
    3] If not, is there any way by which I can write to 2 or more file simultaneously on the client using oralce. I know SQL*Plus can spool file on client. But it is only one file at a time.
    Rgds,
    Amol

    Looking at the 11g documentation you are probably referring to:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/u_file.htm#BABDEJDH
    where it says...
    >
    UTL_FILE provides file access both on the client side and on the server side. When run on the server, UTL_FILE provides access to all operating system files that are accessible from the server. On the client side, as in the case for Forms applications, UTL_FILE provides access to operating system files that are accessible from the client.
    >
    This is referring to client installed forms applications where it provides a local UTL_FILE functionality that accesses the local file system. It doesn't mean that UTL_FILE within PL/SQL that is running on the database server can access the client machine's file system as this would also be a breach of network security.

  • Oracle 11g Certification Query

    Hi all,
    I have given my Oracle 11g exams for OCP certification. Now, i need to take one of the mandatory training to fulfill the requirements for certification. I am in Kuwait and when i select the country as Kuwait, the cheapest training course is of $1230. I am an indian, so when i select the country as India on the oracle site, the price reduces down to $540 for the same course. This is for the Live Virtual Class (LVC) rates. Can i book the LVC with India as country. Do I have to be present in India for the LVC training or only taking a course is compulsion.
    Kindly advice.

    Zuzar Sajjad Tutawala wrote:
    Hi all,
    I have given my Oracle 11g exams for OCP certification. Now, i need to take one of the mandatory training to fulfill the requirements for certification. I am in Kuwait and when i select the country as Kuwait, the cheapest training course is of $1230. I am an indian, so when i select the country as India on the oracle site, the price reduces down to $540 for the same course. This is for the Live Virtual Class (LVC) rates. Can i book the LVC with India as country. Do I have to be present in India for the LVC training or only taking a course is compulsion.
    Kindly advice.If you take LVC training my understanding, and it has been discussed in previous threads, if you need to be prsent in the country from which hte LVC is being presented. So if you want to take it in India you will need to travel back there.

  • ORACLE 11g Spatial and GRS 80

    Hi,
    I am working on a project that will require both projected coordinates and geographic coordinates for different product files coming in. I have no issues defining, storing, extracting or matching the geographic coordinates. My columns for those coordinates with SRID 8307 are defined in the user_sdo_geom_metadata table as follows:
    INSERT INTO
    USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES
    ('INVENTORYGEOMETRY','INVGEO',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, .05),MDSYS.SDO_DIM_ELEMENT('Latitude', -90, 90, .05)),8307);
    the index:
    create index "MYDB"."INVGEO_IDX" on "MYDB"."INVENTORYGEOMETRY"("INVGEO") indextype is MDSYS.SPATIAL_INDEX;
    However, I am confused as to how I am going to have a column that has both Geographic and Projected coordinates. Am I allowed to define more SDO_DIM_ELEMENT(s) fro the SDO_DIM_ARRAY with different min/max values. As an example, would I be able to still use an SRID of 8307 for both WGS 84 and GRS80 data (ellipsoid), something like the following:
    INSERT INTO
    USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES
    ('INVENTORYGEOMETRY','INVGEO',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, .05),MDSYS.SDO_DIM_ELEMENT('Latitude', -90, 90, .05),
    (MDSYS.SDO_DIM_ELEMENT('FIXEDGRID_.5Resolution', 0, 26916, .5)),8307);
    Is that possible or do i have to create a new column in the database?
    Also, I don't know the relationship between the SDO_ELLIPSOIDS table and the SDO_GEOMETRY table. Will you please explain it to me?
    I thank you for any help you can give. I'm confused as to how I'm going to make this work for both the geographic and projected coordinates or if I'm going to be able to make it work.
    Thank you,
    Erica

    Erica,
    You can have geodetic and projected data in a single column of a table BUT you can't spatially index them as the index can't work on both projections.
    You have to, as Bryan says, create two columns:
    create table INVENTORYGEOMETRY (
      fid integer,
      INVGEO sdo_geometry, /* For the geodetic data */
      INVPROJ sdo_geometry /* for the projected data */
    );If you do this you need to create two user_sdo_geom_metadata entries. One as you have already done, and the other for the projected data:
    INSERT INTO
    USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
    VALUES ('INVENTORYGEOMETRY','INVPROJ',
    MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',0,1000, .05),MDSYS.SDO_DIM_ELEMENT('Y',0,1000, .05)),XXXXX);Where you replace 0,1000 ranges with your actual data range and XXXXX with your actual projected SRID (eg 28355 as in the example below).
    Now, assuming this table gets the INVGEO column populated first (via some external dynamic feed) you could synchronise the projected column via a trigger such as the following:
    create trigger inventorygeometry_proj_bi
    before insert
    on inventorygeometry
    FOR EACH ROW
    begin
       if (:new.invgeo is not null) then
         :new.invproj := mdsys.sdo_cs.transform(:new.invgeo,28355);
       end if;
    end;
    /Finally....
    Also, I don't know the relationship between the SDO_ELLIPSOIDS table and the SDO_GEOMETRY table. Will you please explain it to me?The SDO_ELLIPSOIDS table is part of the implementation of projections within the Oracle Spatial package. When you use a SRID in an SDO_GEOMETRY, Oracle uses that SRID to query the underlying tables (of which SDO_ELLIPSOIDS is only one member) to get the properties of the projection eg the definition of the ellipsoid being one.
    I hope this all helps.
    Don't forget to award points as you see fit if our answers are deemed correct or helpful.
    regards
    Simon

  • Oracle 11g spatial database

    Am new to spatial data of oracle... the oracle manual mentions the following steps in order :
    1)Creates a table to hold the spatial data.
    2) Inserts rows for areas of interest.
    3) Updates the USER_SDO_GEOM_METADATA view to reflect the dimensional information for the areas.
    4) Creates a spatial index.
    5) Performs some spatial queries.
    My question is : is it necessary to follow this order ? can i do order 1),3),4) and then 2) and 5) ??

    Why what difference does it make if I update user metadata and spatial index before doing DMLs ?? Also if it does make a difference do I need to update both of them after each DML transaction ??
    Edited by: 919436 on Oct 27, 2012 5:35 PM

  • Oracle 11g :SELECT query blocked..??

    Hi Experts,
    could you please explain why the below SQL query is blocked?
    SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=469 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
    SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=367 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
    I am scratching my head without any solution when I had a look at the db today. Thanks in advance for your help.
    Regards,
    Boris
    Edited by: user12075620 on Dec 4, 2012 8:58 AM

    The SELECT statement is not blocking the UPDATE. As I said in the previous reply, the string that this query produces does not match the logic.
    This query is (at least on the surface) correctly identifying that session 1 is blocking session 2. Session 1 holds some lock that session 2 is waiting on. So far, so good. Since session 2 is waiting on the lock, we can easily enough see what session 2 is running (the UPDATE statement). But since session 1 is not blocked, it is potentially off running a ton of other SQL statements (or no SQL statement at all). The query is looking to see what session 1 is running currently. It has no way of determining what session 1 ran at some point in the past to acquire the lock in the first place.
    Going back to my KING example,
    At noon, session 1 runs
    UPDATE emp
       SET sal = sal * 2
    WHERE ename = 'KING'Session 1 now has a lock on the KING row in the EMP table. But session 1 neither commits nor rolls back, it is still in a transaction. Session 1 might not have any more activity for a long time-- the user might go off to lunch, for example (obviously, applications should not be designed to allow users to maintain open transactions indefinitely, but not all applications are designed correctly). Or it might start running other queries. Let's say that session 1 now runs a query that is going to go for an hour
    SELECT *
      FROM giant_view_with_lots_of_computationsNow, at 12:45, session 2 comes in and runs
    UPDATE emp
       SET bonus = 100
    WHERE ename = 'KING'Session 2 is blocked. Session 2 is running the UPDATE statement. Session 1 still holds the lock but it is running some completely unrelated SQL statement.
    If we run the query you posted, the query will correctly report that session 1 is running the query against the GIANT_VIEW_WITH_LOTS_OF_COMPUTATIONS but incorrectly imply that this SELECT query is the source of the lock. It is not. It simply happens to be the query that the session that does hold the lock happens to be executing at the current moment (why the application seems to be running a lot of queries that select a constant from dual is a separate question).
    Justin

  • TIN Creation algorithms in Oracle 11g

    In the Oracle 11g Developers Guide http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_intro.htm#sthref99 it mentions that "Oracle TIN generation software uses the Delaunay triangulation algorithm, but it is not required that TIN data be formed using only Delaunay triangulation techniques." I was wondering how would one go about implementing other TIN Algorithms such as Bowyer-Watson for the updating of existing TIN data in the SDO_TIN feature type.
    The fact that other Algorithms can be selected is also mentioned in the Oracle 11g Spatial book but no guideance on how. Has anyone implemented this either for 2.5D TIN or for full 3D TINs
    Regards
    Sean

    If you have different databases on same node you could choose to not set ORACLE_SID in shell init file but use instead interactive oraenv Oracle script to set the right ORACLE_SID.
    Please read Configuring the Operating System Environment Variables in http://download.oracle.com/docs/cd/E11882_01/server.112/e10897/em_manage.htm#ADMQS12369
    To create easily a database (ie without using your own scripts) try to use DBCA that will automatically take care of database initialization file: http://download.oracle.com/docs/cd/E11882_01/server.112/e10897/install.htm#BABEIAID
    Edited by: P. Forstmann on 5 août 2011 12:01

  • Very slow simple spatial query on 11g

    I've created two spatial tables as following:
    CREATE TABLE usregions
    region_code NUMBER(1,0) NOT NULL,
    shape ST_GEOMETRY,
    CONSTRAINT usregions_pk PRIMARY KEY usregions(region_code)
    INSERT INTO MDSYS.user_sdo_geom_metadata
    (table_name, column_name, diminfo, srid)
    VALUES ('USREGIONS', 'SHAPE',
    sdo_dim_array (sdo_dim_element ('X', -180, 180, 0.5),
    sdo_dim_element ('Y', -90, 90, 0.5)),
    4269);
    CREATE INDEX usregions_dx ON usregions (shape)
    INDEXTYPE IS MDSYS.spatial_index;
    CREATE TABLE usstates
    state_code NUMBER(1,0) NOT NULL,
    state_name VARCHAR2(30),
    shape ST_GEOMETRY,
    CONSTRAINT usstates_pk PRIMARY KEY usstates(state_code)
    INSERT INTO MDSYS.user_sdo_geom_metadata
    (table_name, column_name, diminfo, srid)
    VALUES ('USSTATES', 'SHAPE',
    sdo_dim_array (sdo_dim_element ('X', -180, 180, 0.5),
    sdo_dim_element ('Y', -90, 90, 0.5)),
    4269);
    CREATE INDEX usstates_dx ON usstates (shape)
    INDEXTYPE IS MDSYS.spatial_index;
    I then loaded both tables with data from a shapefile.
    The state shapefile is just the US map with all the states.
    The region shapefile is the same US map with only 5 regions (Northeast, mid atlantic, mid west, south, and west).
    I created the region shapefile from the state shapefile using ESRI ArcMap to dissolve the States border. So Pennsylvania, Virginia, Maryland, and DC is one polygon; New York and up is another polygon, etc.
    I also created the same two tables, with the same data in SQL Server 2008 (KatMai), as well as in PostGRE 8.3.
    Then I ran the following query:
    SELECT s.state_name
    FROM usstates s
    WHERE s.shape.ST_Within((SELECT shape
    FROM usregions
    WHERE region_code=2))=1;
    Region 2 is Mid Atlantic and I was expecting to see:
    STATE_NAME
    District of Columbia
    Maryland
    Pennsylvania
    Virgina
    Instead, Oracle 11g only returned "District of Columbia"
    The query took 6.4 seconds to run.
    On SQL Server 2008, I got the expected result and it took 0.4 seconds to execute.
    On PostGRE 8.3, I also got the expected result and it took 0.5 seconds to execute.
    Why is Oracle not returning all the States? Is this a bug?
    Am I doing something wrong???
    Thanks.

    save data into internal backup format ???backup format doesn't matter, program is just reading rows from backup file and inserting them into database - so is generating SQL insert commands
    >
    and then it will restore it back to database. It isdone by inserts, each 500 row commit
    I can't follow your post, but...yuck.program is just inserting records into T2 table, but on T2 table is trigger and inside trigger is SQL command "UPDATE TABLE T3 ..... where ......". In this time is T3 already filled with 60569 records.
    And inserting going slower and slower. Without trigger is speed ok. But on oracle 10g speed is ok with this trigger. So I am concern about what could changed in oracle 11g and cause such behavior.
    I will try produce some simple test example

  • Poor performance with Oracle Spatial when spatial query invoked remotely

    Is anyone aware of any problems with Oracle Spatial (10.2.0.4 with patches 6989483 and 7003151 on Red Hat Linux 4) which might explain why a spatial query (SDO_WITHIN_DISTANCE) would perform 20 times worse when it was invoked remotely from another computer (using SQLplus) vs. invoking the very same query from the database server itself (also using SQLplus)?
    Does Oracle Spatial have any known problems with servers which use SAN disk storage? That is the primary difference between a server in which I see this poor performance and another server where the performance is fine.
    Thank you in advance for any thoughts you might share.

    OK, that's clearer.
    Are you sure it is the SQL inside the procedure that is causing the problem? To check, try extracting the SQL from inside the procedure and run it in SQLPLUS with
    set autotrace on
    set timing on
    SELECT ....If the plans and performance are the same then it may be something inside the procedure itself.
    Have you profiled the procedure? Here is an example of how to do it:
    Prompt Firstly, create PL/SQL profiler table
    @$ORACLE_HOME/rdbms/admin/proftab.sql
    Prompt Secondly, use the profiler to gather stats on execution characteristics
    DECLARE
      l_run_num PLS_INTEGER := 1;
      l_max_num PLS_INTEGER := 1;
      v_geom    mdsys.sdo_geometry := mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,45,45,90,0,135,45,180,0,180,-45,45,-45,0,0));
    BEGIN
      dbms_output.put_line('Start Profiler Result = ' || DBMS_PROFILER.START_PROFILER(run_comment => 'PARALLEL PROFILE'));  -- The comment name can be anything: here it is related to the Parallel procedure I am testing.
      v_geom := Parallel(v_geom,10,0.05,1);  -- Put your procedure call here
      dbms_output.put_line('Stop Profiler Result = ' || DBMS_PROFILER.STOP_PROFILER );
    END;
    SHOW ERRORS
    Prompt Finally, report activity
    COLUMN runid FORMAT 99999
    COLUMN run_comment FORMAT A40
    SELECT runid || ',' || run_date || ',' || run_comment || ',' || run_total_time
      FROM plsql_profiler_runs
      ORDER BY runid;
    COLUMN runid       FORMAT 99999
    COLUMN unit_number FORMAT 99999
    COLUMN unit_type   FORMAT A20
    COLUMN unit_owner  FORMAT A20
    COLUMN text        FORMAT A100
    compute sum label 'Total_Time' of total_time on runid
    break on runid skip 1
    set linesize 200
    SELECT u.runid || ',' ||
           u.unit_name,
           d.line#,
           d.total_occur,
           d.total_time,
           text
    FROM   plsql_profiler_units u
           JOIN plsql_profiler_data d ON u.runid = d.runid
                                         AND
                                         u.unit_number = d.unit_number
           JOIN all_source als ON ( als.owner = 'CODESYS'
                                   AND als.type = u.unit_type
                                   AND als.name = u.unit_name
                                AND als.line = d.line# )
    WHERE  u.runid = (SELECT max(runid) FROM plsql_profiler_runs)
    ORDER BY d.total_time desc;Run the profiler in both environments and see if you can see where the slowdown exists.
    regards
    Simon

  • Oracle 9i 10g slow spatial query

    I have been using the following spatial query in oracle 9i to assign jurisdictions to spatial points.
    SELECT /*+ordered*/ L.TCH_X_COORD, L.TCH_Y_COORD, T.NAME
    FROM tis.tis_coordinates_hold_on L,
    geospatial.mdt_admin_districts T
    WHERE SDO_RELATE(T.GEOMETRY,
    MDSYS.SDO_GEOMETRY(2001,41079,MDSYS.SDO_POINT_TYPE(tch_x_coord,tch_y_coord,NULL),
    NULL,NULL),'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'
    AND tch_assigned_base_rte='M00001N'
    By using the ordered hint I was able to double the retrieval rate.  My problem is this: We are now migrating to oracle 10g, and the use of the ordered returns no rows (different incorrect results). If I remove the + ordered the results are correct, but I no longer get the increased speed of retrieval. Has anyone run into this problem, and can you suggest a way that I could speed up this query. As it stands now it takes more than 1/2 sec for each record retrieved, and I have millions of records !! Thanks.

    We're using 10.2.4.0 I believe I have found the reason the queries were different. When I dropped the spatial index and re-created it, the query returned the same rows as 9i. However, I still have an issue with the speed. 10g appears to be about 1/3 as fast as 9i was. It doesn't seem to make any difference whether I put in the +ordered or not.  Our dba says just based on cpu and processing speed the server that has 10g should be significantly faster.  Any comments?  Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Query not considering function based index in oracle 11g

    I have a query which used Function Based Index when run in oracle 9i but when I run the same query
    without any changes, it does not consider index. Below is the query:
    SELECT distinct patient_role.domain_key, patient_role.patient_role_key,
    patient_role.emergency_contact_name,
    patient_role.emergency_contact_phone, patient_role.emergency_contact_note,
    patient_role.emergency_contact_relation_id,
    patient_role.financial_class_desc_id, no_known_allergies, patient_role.CREATED_BY,
    patient_role.CREATED_TIMESTAMP,
    patient_role.CREATED_TIMESTAMP_TZ, patient_role.UPDATED_BY, patient_role.UPDATED_TIMESTAMP,
    patient_role.UPDATED_TIMESTAMP_TZ,
    patient_role.discontinued_date
    FROM encounter, patient_role
    WHERE patient_role.patient_role_key = encounter.patient_role_key
    AND UPPER(TRIM(leading :SYS_B_0 from encounter.account_number)) = UPPER(TRIM(leading :SYS_B_1 from
    :SYS_B_2))
    AND patient_role.discontinued_date IS null
    AND encounter.discontinued_date IS null ;
    Index definition:
    CREATE INDEX "user1"."IX_TRIM_ACCOUNT_NUMBER" ON "user1."ENCOUNTER" (UPPER(TRIM(LEADING
    '0' FROM "ACCOUNT_NUMBER")), "PATIENT_ROLE_KEY", "DOMAIN_KEY", "DISCONTINUED_DATE")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
    BUFFER_POOL DEFAULT)
    TABLESPACE "user1"
    Database : Oracle 11g (11.2.0.3)
    O/S : Linux 64 bit (the query does not consider index even on windows os)
    Any suggestions?
    -Onkar
    Edited by: onkar.nath on Jul 2, 2012 3:32 PM

    Onkar,
    I don't appreciate you posting this question in several forums at the same time.
    If I would know you also posted this on Asktom, I wouldn't even have bothered.
    As to your 'issue':
    First of all: somehow cursor_sharing MUST have been set to FORCE. Oracle is a predictable system, not a fruitmachine.
    Your statement the '0' is replaced by a bind variable anyway is simply false. If you really believe it is not false, SUBMIT a SR.
    But your real issue is not Oracle: it is your 'application', which is a mess anyway. Allowing for alphanumeric numbers is a really bad idea.
    Right now you are already putting workaround on workaround on workaround on workaround.
    Issue is the application: it is terminal., and you either need to kill it, or to replace it.
    Sybrand Bakker
    Senior Oracle DBA

  • 11G Pivot Query with Oracle EBS

    Hello all,
    We are trying to use the 11G pivot query function with data from Oracle E-Business Suite. We have an 11G database installed with our Oracle APEX. We cannot seem to get the pivot function to work. At a glance, would anyone be able to see any glaring errors in our syntax. I am not certain it is possible to provide test data so...
    We are trying to have column headings with the Period Names SEP-08 OCT-08 NOV-08, with rows of segment2 007751 and accounted_dr as the dataset.
    When we run the sql we get an error ORA-00904: "PERIOD_NAME": invalid identifier.
    Any help or insight would be greatly appreciated.
    select * from (
    select segment2, accounted_dr, period_name
    from gl_je_lines a, gl_code_combinations b
    where b.code_combination_id = a.code_combination_id
    and segment2 = '007751')
    pivot
    sum(accounted_dr)
    for period_name in ('SEP-08','OCT-08','NOV-08')
    group by segment2, period_name

    lilhelp wrote:
    Hello all,
    We are trying to use the 11G pivot query function with data from Oracle E-Business Suite. We have an 11G database installed with our Oracle APEX. We cannot seem to get the pivot function to work. At a glance, would anyone be able to see any glaring errors in our syntax. I am not certain it is possible to provide test data Why not?
    >
    We are trying to have column headings with the Period Names SEP-08 OCT-08 NOV-08, with rows of segment2 007751 and accounted_dr as the dataset.
    When we run the sql we get an error ORA-00904: "PERIOD_NAME": invalid identifier.
    Any help or insight would be greatly appreciated.
    select * from (
    select segment2, accounted_dr, period_name
    from gl_je_lines a, gl_code_combinations b
    where b.code_combination_id = a.code_combination_id
    and segment2 = '007751')
    pivot
    sum(accounted_dr)
    for period_name in ('SEP-08','OCT-08','NOV-08')
    group by segment2, period_nameDon't use GROUP BY. When you use PIVOT, the grouping is implied by what is in the PIVOT clause and what is not.
    Try this:
    select    *
    from        (
           select  segment2
           ,       accounted_dr
           ,       period_name
           from       gl_je_lines          a
           ,       gl_code_combinations     b
           where       b.code_combination_id = a.code_combination_id
           and       segment2 = '007751'
    pivot       (
           sum (accounted_dr)
           for period_name in ('SEP-08','OCT-08','NOV-08')
    ;which is just your posted query without the GROUP BY clause.

  • Oracle 11G - Oracle AWR export import Query Statistics.

    I have Oracle 11G, i have seen the sql statements through Historical AWR option from Top Activites in performance tab. Can i export all AWR query statistics from production machine so that i can analyze all logs after importing it.
    How can i know all statistical sql ( information ) and performace of production machine ?
    any help ?

    Hello,
    have you checked the DBA_HIST* objects to see what / how was imported?
    If the awr export dosn't get the contents of the rolling buffer, then you won't see any session statistics that are only there. If you want to get the contents of the rolling buffer you have to dump the contents of it with :
    oradebug setmypid
    oradebug dump ashdump 10
    and load it into your "test" database.
    But before doing this I suggest you read the related metalink documentation if any!!!
    Regards,
    Franky

Maybe you are looking for