Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, rd.

Asked: August 09, 2001 - 4:25 pm UTC

Last updated: March 12, 2004 - 5:23 pm UTC

Version: 8.1.5

Viewed 1000+ times

You Asked

Tom

is there any difference between using <> and !=,if so which one is better.

what is the difference between using 'yyyy' and 'rrrr' in the date format for years?


instead of

AND (a.cc_cd IN ('aus','eng','ind') OR b.sec_cc_cd IN ('aus','eng','ind'))

can I do

AND a.cc_cd or b.sec_cc_cd in ('aus','eng','ind')

can you discuss a similar example for me, and illustrate


If the optimizer is set to choose, will the optmizer automatically choose cbo when we use full or first_rows hint, what are the hints which are valid for rbo.



and Tom said...

they are the same <> and !=

one defaults the century, the other does not:


1 select 'yyyy 99', to_char( to_date( '99', 'yyyy' ), 'yyyy' ) from dual
2 union all
3 select 'rrrr 99', to_char( to_date( '99', 'rrrr' ), 'yyyy' ) from dual
4 union all
5 select 'yyyy 01', to_char( to_date( '1', 'yyyy' ), 'yyyy' ) from dual
6 union all
7* select 'rrrr 01', to_char( to_date( '1', 'rrrr' ), 'yyyy' ) from dual
ops$tkyte@ORA817.US.ORACLE.COM> /

'YYYY99 TO_C
------- ----
yyyy 99 0099
rrrr 99 1999
yyyy 01 0001
rrrr 01 2001

ops$tkyte@ORA817.US.ORACLE.COM>

No, you cannot do "a or b in (x,y,z)" instead of "a in (x,y,z) or b in (x,y,z)"

Regardless of the optimizer goal set, if you use a HINT you will be using the CBO -- period.

The only valid "hint" for RBO is /*+ RULE */ -- telling the optimizer to use RBO. There are no hints available for RBO.



Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

But still some confusion

Jon, March 12, 2004 - 1:01 pm UTC

I was having a discussion with someone about "rounded years" and so I came to the expert. I guess I don't understand the purpose of RRRR. The documentation say, "Accepts either 4-digit or 2-digit input (apparently 1-digit also from your example). If 2-digit, provides the same return as RR. If you don't want this functionality, then simply enter the 4-digit year." Since 2-digit input gives you the same functionality as 4-digit, why not just enter RR (since the whole purpose of this seems to be to accommodate lazy people who don't want to enter a 4-digit year. And if you're going to do it right (IMHO) and enter the full four digits, who needs RRRR since we have YYYY.

This RRRR thing looks like a Y2.05K problem in the making. I say enter the 4 digits and use YYYY. Am I missing something?

Tom Kyte
March 12, 2004 - 5:23 pm UTC

I say enter 4 digits period. whether you use rrrr or yyyy at that point is no longer relevant.

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.