Oracle Spatial Index on a column NOT NULL

I'm using the Oracle 11 g with data space init.

I have a SDO_GEOM column in a table that has NULL values for some records. I have to run spatial query based on this column so the need of a spatial index on it. Is it possible to create a Spatial Index on a column SDO_GEOM even if some of them have the NULL value and results of spatial query?


Thank you
Alan

Published by: user3883362 on 29 April 2013 05:59

Alan,

Is it possible to create a Spatial Index on a column SDO_GEOM even if some of them are NULL

Yes.

SQL> CREATE TABLE test (ID NUMBER PRIMARY KEY, geom MDSYS.SDO_GEOMETRY);

Table created.

-- "insert a row with non-NULL geometry"
SQL> INSERT INTO test VALUES (1, SDO_GEOMETRY('POINT (6000000 2100000)', 40986));

1 row created.

-- "insert a row with NULL geometry"
SQL> INSERT INTO test VALUES (2, NULL);

1 row created.

SQL> CREATE INDEX test_spx ON test (geom) INDEXTYPE IS MDSYS.SPATIAL_INDEX;

Index created.

.. .and getting results of spatial query

Yes, assuming that your data is valid.

-- "Creates a 10' buffer around the point we previsouly inserted then applies SDO_INSIDE"
SQL> SELECT ID, SDO_INSIDE(geom, SDO_GEOM.SDO_BUFFER(geom, 10, 1)) FROM test;
1 TRUE --"our point geometry"
2 FALSE --"our NULL"

2 rows selected.

If you encounter problems here, I think you can use the functions that are choking in NULL values, for example, the conversion of NULL in WKT geometry.

How do you access data (sqlplus, application, custom, etc.)? What is the query, and we see a few examples of data?

Kind regards
Noel

Tags: Database

Similar Questions

  • Change the default value of column NOT NULL to NULL

    Hi all
    How can I change the default value of column not NULL to NULL?
    Suppose I have run the following commands:
    SQL> alter table hr.test modify temp_num2 default null;
    
    Table altered.
    
    SQL> desc hr.test;
     Name                            Null?    Type
     ----------------------------------------- -------- ----------------------------
     TEMP_NUM                             NUMBER
     TEMP_NUM2                       NOT NULL NUMBER
    Why forced temp_num2 has not changed with the NULL value? I'm under 11.g rel2

    Best regards
    Valerie

    You can NOT change the column constraint NULL to contain NULL values by:

    alter table table_name modify column_name null; 
    

    After this change, the column can contain null values. In Oracle, not null constraints are created automatically when not null is specified for a column. Similarly, they are deleted automatically when the column is changed to allow NULL values.

  • Columns not null showing that nullable in the table grid

    I use 2.1.0.63 sql developer.
    I ran the following in my diagram
      CREATE TABLE EXCLUDE_DATA 
       (OWNER       VARCHAR2(30), 
        TABLE_NAME  VARCHAR2(30), 
           COLUMN_NAME VARCHAR2(30), 
           CONSTRAINT CK_OWNER CHECK (owner IS NOT NULL) ENABLE, 
           CONSTRAINT CK_TABLE_NAME CHECK (table_name IS NOT NULL) ENABLE
       );
     
     COMMENT ON TABLE EXCLUDE_DATA IS 'Tables and Columns to exclude from the column checker';
     COMMENT ON COLUMN EXCLUDE_DATA.OWNER IS 'The schema that contains the table';
     COMMENT ON COLUMN EXCLUDE_DATA.TABLE_NAME IS 'The table name to be excluded from the column checker';
     COMMENT ON COLUMN EXCLUDE_DATA.COLUMN_NAME IS 'The column on the table to be excluded.  If null then the whole table is excluded';
    
      CREATE UNIQUE INDEX UK_EXCLUDE_DATA ON EXCLUDE_DATA (OWNER, TABLE_NAME, COLUMN_NAME);
    When the name of the table is selected, and the tab for the column that is selected in the main window it's showng columns as nullable (see below)
    OWNER     VARCHAR2(30 BYTE)     Yes          1     The schema that contains the table
    TABLE_NAME     VARCHAR2(30 BYTE)     Yes          2     The table name to be excluded from the column checker
    COLUMN_NAME     VARCHAR2(30 BYTE)     Yes          3     The column on the table to be excluded.  If null then the whole table is excluded
    The constraints are there however, it looks like a potential problem with just this window.

    CeeJay

    Adding a not null to a column check constraint does not have the non-nullable column.

    Try instead this statement

    CREATE TABLE EXCLUDE_DATA
    (THE VARCHAR2 (30) IN OWNER NOT NULL,)
    TABLE-NAME VARCHAR2 (30) NOT NULL,
    COLUMN_NAME VARCHAR2 (30)
    );

    COMMENT on TABLE EXCLUDE_DATA IS "Tables and columns to exclude from the audit of the column;
    COMMENT ON THE EXCLUDE_DATA COLUMN. OWNER IS 'of the schema that contains the table.
    COMMENT ON THE EXCLUDE_DATA COLUMN. Table_name IS "the name of table to be excluded from the audit of the column;
    COMMENT ON THE EXCLUDE_DATA COLUMN. Column_name IS ' column on the table to be excluded. If set to null, then the entire table is excluded. "

    CREATE A UNIQUE UK_EXCLUDE_DATA ON EXCLUDE_DATA (OWNER, TABLE_NAME, COLUMN_NAME) INDEX;

    The database AUTOMATICALLY adds check for columns NOT NULL constraints.

    Hope this helps

    Concerning
    Chris

  • Adding column not null in the existing table.

    How to add a column not null in the existing table?
    explain.
    Thank you
    create table abc_ex(a number);
    
    alter table abc_ex add(b number not null);
    
    desc abc_ex
    

    If for use then change to ALTER column extising

    Published by: nkvkashyap on May 27, 2013 21:49

  • force a view column not null

    I can't create a view with a column not null. Using this script, you can see that the resulting table is a constraint not null for the first column, even if the two columns of the source of this line are not null. Is anyway to force the view on the occasion of this first column as not null? (I need to ODP.NET if I get an error here)

    DROP TABLE MYTABLE;

    CREATE the table MYTABLE
    (COL1 NUMBER (2) NOT NULL,)
    col2 number (2));

    drop table mytable2;

    CREATE the MYTABLE2 table
    (THE NUMBER (2) COLA NOT NULL,)
    colB number (2));

    create or replace view MYVIEW as select col1, col2 from mytable union select cola, colb from mytable2;

    Bird DESC;

    >
    Is anyway to force the view on the occasion of this first column as not null?
    >
    No--and there's a related problem if you create a table with a view. For example, the table emp has empno as NOT NULL. I have a copy of the named emp1 emp where empno is also NOT NULL.

    create or replace view v_emp as select empno from emp
    

    A view on the highest describe statement shows empno as NOT NULL. But, as you've discovered if you ask another Union column will become NULLABLE in the view described.

    The question is that if I use the view (on the single table of emp - no union or the second query) to create a table

    create table t_emp as select * from v_emp
    

    A describe on this table statement will show empno as NULLABLE.

  • ADD A NEW COLUMN NOT NULL

    Hello
    I try to add a new column not null in the emp default table exist. Initially, I created the column (like BONUS) and then I try to apply the constraint in this amended by order. But it does not happen I mean forced is not added to the column as already the column will have NULL values for records existing (or lines). Can someone help me how to solve the problem?

    Thank you and best regards,
    Vishnu.

    first disable constraint...

    ALTER table dept change the ur_constraint_name disable constraint;

    then insert the data can

    ALTER table dept change the ur_constraint_name novalidate constraint;

    then

    ALTER table dept change enable NOVALIDATE constraint ur_constraint_name;

    Try this we can help

  • Melody oracle spatial index

    Hello world

    How to give a spatial index in oracle? Pls advice


    Thanks in advance

    It is a very open ended question. When you post questions on this forum you will get better results if you have very specific questions. If you have a specific spatial query is not performing well? If so, then as much information as you can about it.
    -Exactly which version of the Oracle database?
    -What is the SQL query that you run - whether you can include the plan of the explain command
    -What is your expected for the query response time?
    -The amount of data is in the table, and what kind of data is
    -Is it possible to provide information on the use cases behind the query that you run.

    There are different techniques available to make spatial queries perform as you would expect, but I'm not going to waste my time to go through them here until that provide useful information.

    I recommend having a look at this presentation for some tips:
    http://download.Oracle.com/otndocs/products/spatial/PDF/ow_2009/spatial_oow09_tuning_and_best_practices2.PDF
    Also take a look at this:
    http://download.Oracle.com/otndocs/products/spatial/PDF/spatial_wp09_bestprac.PDF

  • Update on nulls in the column vs add column not null default 11 g

    Hello

    Let's take a scenario following 1. *

    We have a large partitioned table LARGE_TABLE1 (say: NUM_ROWS 5 904 977 029, size GB 326) in the Oracle 11 database.

    We want to add a new column NEW_COLUMN (NUMBER) and give a value of-999 to NEW_COLUMN each record in this table.
    ALTER TABLE LARGE_TABLE1 ADD (NEW_COLUMN NUMBER DEFAULT -999 NOT NULL);
    In Oracle 11 it would probably a second since the value of default -999 would be permanently added in metadata without updating each and every record 6 bln.

    Take a scenario 2 *

    We have another large partitioned table LARGE_TABLE2 (of similar size as LARGE_TABLE1) in the Oracle 11 database.

    We have an existing EXISTING_COLUMN (NUMBER) column that contains nulls 90% (90% of scores only contain null values in the field, and 10% of the scores only contain non-null values in this field)

    I would like to replace null values in EXISTING_COLUMN with number - 999.

    Update the column full Ascension not going :-) and doing so in a loop (the partition partition) would take a few days.

    Question:
    Do you know a way somehow write this -999 "overall" in the metadata as in scenario 1 instead of updating a null value in all the records to-999? No clever workaround solution would be appreciated...

    Edited by: SwPiotr 2012-04-24 07:26
    ALTER TABLE LARGE_TABLE1 ADD NEW_COLUMN NUMBER GENERATED ALWAYS AS nvl(col1, -999);
    
  • Virtual column NOT NULL

    Hello dear colleagues,

    Anyone able to replicate this?
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Create a small table:
    SQL> create table t(x number not null);
    
    Table created.
    Now, add a virtual column, using decode:
    SQL> alter table t add (y varchar2(1) as (decode(x, 1, 'A', 'B')) not null);
    
    Table altered.
    'The same', using case column
    SQL> alter table t add (z varchar2(1) as (case x when 1 then 'A' else 'B' end));
    
    Table altered.
    Only it wasn't the same, I wanted to NOT NULL.
    If I do, I get:
    SQL> alter table t add (w varchar2(1) as (case x when 2 then 'A' else 'B' end) not null);
    alter table t add (w varchar2(1) as (case x when 2 then 'A' else 'B' end) not null)
                                                                     *
    ERROR at line 1:
    ORA-03113: EOF pÕ kommunikationskanal
    Process ID: 3400
    Session ID: 140 Serial number: 213
    This is consistent with this database on my laptop.


    Concerning
    Peter

    Looks like you have perhaps hit Bug Bug 9277263: ORA-07445 [ATBNUL () + 299] WHEN ADDING a CONSTRAINT INLINE ON a VIRTUAL COLUMN

  • ALTER Table Add column not null, no default

    I want to add two columns in a table with not null, and the default value 0 for two columns
    Can I write everything in a single statement or do I have to divide the declaration
    I tried, but didn't work

    ALTER table DWSODS01. DWT00301_ORD_DTL_OMS add)
    COMB_ORD_FLG NUMBER (5.0) default null, 0
    COMB_ORD_NO NUMBER (12.0)
    by default, 0 not null);

    How can I change the code?

    user10390682 wrote:
    OK, so if it is NOT NULL, while there should be a value.

    Yes.

    So, when I set these two columns as NOT NULL will only future data must be NON NULL.
    What of the old and present data if I defined as NOT NULL

    NOT NULL mean value of eachcolumn + line (current or future) _ must not be null. That's why always adding NOT NULL column to a non-empty table fails - the column value for existing lines will be NULL which does NOT violate the constraint nullability. If you add the NON NULL column with a default value, the column will be added and all lines existing column value will be defined by specified default (0 in your case). As a result Oracle will be able to settle forced to null for this newly added column from the value of this column in all the existing lines will be not not null (0 in your case).

    SY.

  • Quick question: alter table, alter column NOT NULL...

    Hey all,.

    If I change 3 populated (they have data) columns in a table with about 300 million of NULL lines that is NOT NULL:

    alter table blah
    change (col1, col2, col3 NOT NULL NOT NULL, NOT NULL);

    ... about cela "will take a long time?

    I know that it is a question REALLY of high level, but I wonder how long it should consume (a few minutes or several minutes - looking for an approximate answer as well). The table has 10 columns, if that helps.

    Hardware specifications are not relevant... I am looking for a basic response.

    Hello

    Plug material is relevant here.
    It depends on the material/Oracle parameters/IO etc..
    You can also view v$ session_longops to track progress.

    Concerning
    Anurag Tibrewal

  • Column not null in rows in SQL query

    I have the below query,

    WITH t

    Did YOU (SELECT NULL col_1, col_2, 'C' FROM DUAL col_3 NULL

    UNION ALL

    SELECT 'A' col_1, col_2 NULL, NULL FROM DUAL col_3

    UNION ALL

    NULL SELECT col_1, col_2 "B", NULL FROM DUAL col_3)

    SELECT *.

    T;

    who will pick up three rows, on which single column will have a value for each row.
    And the other columns are left out as below.

    COL_1 COL_2 COL_3
    C
    A
    B

    I don't need that values should be extracted in the column name that is not null.

    as

    COL_1 COL_2 COL_3
    ABC


    Please advise me

    You can use the MAX aggregate function. But do not know what you are trying to reach.

  • Constraint CHECK on a column not null

    Is this OK

    create table tab
    check the col1 varchar2 (10) not null (col1 in (' has ',' b '),)
    col2 varchar2 (10) check (col2 in ('c' ' d ' "))
    );

    Hello

    The syntax was that not good use

     CREATE TABLE tab
    (
       col1   VARCHAR2 (10) NOT NULL CHECK (col1 IN ('a', 'b')),
       col2   VARCHAR2 (10) CHECK (col2 IN ('c', 'd'))
    );
    

    Concerning

  • The doc is correct on the constraint not null and scan limited index full?

    Gave birth to the large [url http://forums.oracle.com/forums/thread.jspa?messageID=9313643] another thread:
    Jonathan Lewis wrote:
    >
    I wasn't expecting to see because the doc said about scan limited index full "...". and at least one column in the index key has the NOT NULL constraint,"which would be foolish to say if the rowid was what filled that. There are currently only 2 factory codes and code 1 company (not nulls - Oracle does know that?), so I was kind of expected Oracle to reorder the predicates with an index skip scan. Take a fresh look on the doc, I wonder if I should not specify the company code in the query and maybe spend employee and job_number in the index. I hope it's obvious that this index has been added for other queries. This request could be taken out a change in the requirements of anyway, but I don't know when.
    If you wear it as a separate thread, I'll take a look.
    Can you give a reference to the manual - the comment you quoted may not be correct.
    Just below where Hemant pointed to in the other thread, http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/indexiot.htm#sthref314

    (Somehow I have the feeling that we had this conversation before, perhaps in a forum that no longer exists. "(Or was it all just a dream)."

    Edit: Also seen in
    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28274/optimops.htm#i52044
    http://download.Oracle.com/docs/CD/B14117_01/server.101/b10752/optimops.htm#51111
    http://download.Oracle.com/docs/CD/F49540_01/doc/server.815/a67781/c20b_ops.htm#11004
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14211/optimops.htm#i52044

    and everything on the net.

    Edited by: jgarry 26 January 2011 17:41
    2nd edition: link fix that edit may 1 have ransacked.

    Edited by: jgarry January 27, 2011 10:40

    Joel,

    I just had this 'already seen' (new) sense to speak of it.

    Mentioning the reference 11.1 gave you:


      + "Index full scans are an alternative to a full table scan when the index contains all the columns needed for the query, and at least in the index key column has the constraint NOT NULL. A full scan can access the data of the index itself, without access to the table ' + '.

    This so obviously must be bad that I couldn't decide if I was proven wrong or was amazed to find that I couldn't he show the falsity. (Just because something is obvious, it does not mean it is true – Terry Pratchett.)

    However, here is the obvious counter-example - that I came across 8.1.7.4 because it's the oldest version of Oracle that I have now:

    create table t1
    as
    select
         rownum               id1,
         rownum               id2,
         rownum               id3,
         lpad(rownum,10,'0')     small_vc,
         rpad('x',100)          padding
    from
         all_objects
    where
         rownum <= 10000
    ;
    
    create index t1_i1 on t1(id1, id2, id3);
    
    begin
         dbms_stats.gather_table_stats(
              ownname           => user,
              tabname           =>'T1',
              cascade           => true
    
         );
    end;
    /
    
    set autotrace traceonly explain
    
    select
         /*+ index_ffs(t1) */
         id1, id3
    from
         t1
    where
         id2 = 99
    ;
    

    No 'NOT NULL columns". But any line I will have a (non-null) value for id2, then it should be in the index - then Oracle should be able to do a full scan and get the right answer. Here is the map (I have no need of Council - but your configuration may be different):

    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=1 Bytes=12)
       1    0   INDEX (FAST FULL SCAN) OF 'T1_I1' (NON-UNIQUE) (Cost=4 Card=1 Bytes=12)
    

    If you change the predicate to: "id2 is zero", then the only legal path is an analysis.

    Concerning
    Jonathan Lewis
    http://jonathanlewis.WordPress.com
    http://www.jlcomp.demon.co.UK

    + "I believe in the evidence. I believe in observation, measurement and reasoning, confirmed by independent observers. I'll believe anything, no matter how wild and ridiculous, if there is evidence for it. The wildest and most ridiculous something is, however, the firmer and more solid, the evidence should be. » +
    Isaac Asimov

  • Index BITMAP and NOT NULL

    Hi all
    Is it possible to use the Index BITMAP for a NOT NULL condition?


    >

    CREATE a BITMAP of INDEX x_ix FOR tab (x);

    SELECT *.
    TAB
    WHERE x IS NOT NULL

    >

    Thank you!

    user3646231 wrote:
    You say that :) to hope

    Here it is:

    Your test is a good effort - but it needs a little more.

    Your question is "is it possible...". «, not "If Oracle always...» »

    Your demonstration showed an example where the choice of plan Oracle has surprised you (and me). Now, you need run the query with index indicator (because if the indexed access path is legal, must be taken an indexed correctly suggested path).

    I just ran a similar test (1 line of 100,000), with the following results:

    SQL> select * from table(dbms_xplan.display_cursor);
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------
    SQL_ID  52q6gxkscvg9v, child number 0
    -------------------------------------
     select /*+ index(t1(n1)) */ * from t1 where n1 is not null
    
    Plan hash value: 2828957992
    
    ----------------------------------------------------------------------
    | Id  | Operation                    | Name  | Rows  | Bytes | Cost  |
    ----------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |       |       |       |  1859 |
    |   1 |  TABLE ACCESS BY INDEX ROWID | T1    |     1 |   118 |  1859 |
    |   2 |   BITMAP CONVERSION TO ROWIDS|       |       |       |       |
    |*  3 |    BITMAP INDEX FULL SCAN    | T1_N1 |       |       |       |
    ----------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("N1" IS NOT NULL)
    

    You will notice that the cost of the query is unreasonable - and without the suspicion my test showed Oracle taking the full analysis at a much lower cost.
    If your test has actually demonstrated a bug in the costing, explaining why Oracle does not automatically take a path that seems reasonable.

    The above output comes from 11.2.0.3, but I had the same thing with 11.1.0.7

    Concerning
    Jonathan Lewis
    http://jonathanlewis.WordPress.com
    Author: core Oracle

Maybe you are looking for

  • Equium A200 1v0 - DVD Volume very low

    Hello! I noticed DVD playback volume is very low (even when the cursor of the volume on the drive and windows is max had). MP3 playback is very good and volume is much stronger, he just seems to be a problem with playback of the DVD. I tried a Toshib

  • EL CAPITAN-change hard drive in GUID Partition

    I read the previous posts and utility assistance from disk on the evolution of the GUID to load El Capitan. To this day he used the Apple Partition map and trying to update I received the message GUID. Unfortunately, the solutions do not work for me.

  • Xbox 360 Driver does not

    I have a gamepad XBOX 360 Madcatz.  It worked fine with Windows Vista Home Premium 32 - bit, but since I updated to Windfows 7 Ultimate 64 - bit, it has serious problems. A summary of the questions is as follows: The buttons are always involved, A is

  • does win xp no sound no sound

    my desktop pc continues to lose audio after awhile... (win Xp-labs creative SB X - Fi Surround 5.1 pro)

  • On the road to Windows 10

    I'll try to post this question in chronological order - which is a hilly track, given my severe loss of memory.  I had Windows 7 installed (of a 3 computer license) on my desktop, my laptop and my wife's office.  I downloaded and installed Win 10 on