English 中文(简体)
意想不到的问答
原标题:unexpected query success
SELECT COUNT (*)
  FROM rps2_workflow
 WHERE     workflow_added > TO_DATE ( 01.09.2011 ,  dd.mm.yyyy )
       AND workflow_finished < TO_DATE ( wtf ,  dd.mm.yyyy )
       AND workflow_status IN (7, 12, 17)
       AND workflow_worker = 159

由于日期无效,我预计这一询问会失败,但结果为零。

查询计划显示,第8步,无效条款is。 处理:

8 TABLE ACCESS BY INDEX ROWID TABLE RPS2.RPS2_WORKFLOW Object Instance: 1  Filter Predicates: ("WORKFLOW_STATUS"=7 OR "WORKFLOW_STATUS"=12 OR "WORKFLOW_STATUS"=17) AND SYS_EXTRACT_UTC("WORKFLOW_FINISHED")<SYS_EXTRACT_UTC(TO_DATE( wtf , dd.mm.yyyy ))  Cost: 11  Bytes: 33  Cardinality: 1  CPU Cost: 8 M  IO Cost: 10  Time: 1                     

如果我们在<代码>AND workflow_status IN(7、12、17)的条件下发表评论,那么预期我们会收到ORA-01858:发现非数字性质,届时会发现有数字

If we comment out AND workflow_finished < TO_DATE ( wtf , dd.mm.yyyy ) then we get amount of records that fit that conditions (> 0)

如何做到这一点?

www.un.org/Depts/DGACM/index_spanish.htm

The hint /*+no_index(rps2_workflow) */ doesn t change anything (whereas in the plan we see that fullscan is performed)

SELECT STATEMENT  ALL_ROWSCost: 254  Bytes: 31  Cardinality: 1  CPU Cost: 34 M  IO Cost: 248  Time: 4       
2 SORT AGGREGATE  Bytes: 31  Cardinality: 1     
    1 TABLE ACCESS FULL TABLE RPS2.RPS2_WORKFLOW Object Instance: 1  Filter Predicates: "WORKFLOW_WORKER"=159 AND ("WORKFLOW_STATUS"=7 OR "WORKFLOW_STATUS"=12 OR "WORKFLOW_STATUS"=17) AND SYS_EXTRACT_UTC("WORKFLOW_ADDED")>SYS_EXTRACT_UTC(TIMESTAMP  2011-09-01 00:00:00 ) AND SYS_EXTRACT_UTC("WORKFLOW_FINISHED")<SYS_EXTRACT_UTC(TO_DATE( wtf , dd.mm.yyyy ))  Cost: 254  Bytes: 31  Cardinality: 1  CPU Cost: 34 M  IO Cost: 248  Time: 4  
最佳回答

可能发现,符合所有其他条件的所有记录都有<条码>NUL>><条码>的工作流程领域。

与<代码>NUL相比的任何东西都不为人所知,因此没有必要评价其他操作。

问题回答

如果最优化者决定它不需要评价某项职能,那么它就取得了一定成绩,因此这一职能永远不会成为例外:

select 1 from dual where 1 = 1 OR to_date( asdasdasd , asdasdasdas ) > sysdate ;

         1
----------
         1

该职能只有在实际得到评估时才产生例外:

SQL> select 1 from dual where 1 = 1 AND to_date( asdasd , asdas ) > sysdate ;
select 1 from dual where 1 = 1 AND to_date( asdasd , asdas ) > sysdate
                                                    *
ERROR at line 1:
ORA-01821: date format not recognized

但是,如果教区可以决定法定<>查询/em>,查询无效――因为该职务有错误的争论类型或查询无效的类型,则教区会提出例外,然后由最优化者在其上调:

SQL> select 1 from dual where 1 = 1 or to_date( asdasdasd ,0) > sysdate ;
select 1 from dual where 1 = 1 or to_date( asdasdasd ,0) > sysdate
                                                         *
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected DATE got NUMBER


SQL> select 1 from dual where 1 = 1 or to_date( asdasdasd , asdasdasdas ) > 42 ;
select 1 from dual where 1 = 1 or to_date( asdasdasd , asdasdasdas ) > 42
                                                                        *
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected DATE got NUMBER




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签