I'm curious about the theory of ORACLE INDEX.

Asked 1 years ago, Updated 1 years ago, 85 views

I'm studying about indexes. It's a source that compares indexes with those using DML I have a few questions.

create table emp3(
  no number,
  name varchar2(10),
  salary number
 );

 insert into emp3 values (1, 'Seo Geonchang', 200);
 insert into emp3 values (2, 'Ko Jongwook', 100);
 insert into emp3 values (3, 'Lee Taek-geun', 150);
 insert into emp3 values (4, 'Danidon', 150);
 insert into emp3 values (5, 'Kim Min-sung', 200);
 insert into emp3 values (6, 'Chataein', 250);
 insert into emp3 values (7, 'Kim Ha-sung', 150);
 insert into emp3 values (8, 'Park Dong-won', 200);
 insert into emp3 values (9, 'Lim Byung-wook', 100);

--  Create index 
 create index idx_name
 on emp3(name);

 -- Name output without index
 select name from emp3;

 -- Index post-use name
 select name from emp3
 where name > '0';

 -- Name output without index -- sort occurred. More processing speed on a large number of data
 select min(name) from emp3; -- Output value: Jongwook Ko

-- Index x
select max(name) from emp3; -- Output value: Chae Tae-in

-- Index o, hint
select /*+ index_desc(emp3 idx_name)*/ name
from emp3
where name > '0'
and growum = 1;-- Output value: Seo Geon-chang
-- This method can produce incorrect output results if there is a change in the index column.

-- It can be processed by the first_row max method.
select /*+ index_desc(emp3 idx_name)*/ max(name)
from emp3
where name > '0';-- Output value: Chae Tae-in

1 I have a question about where clause. Where name > '0'. I'm not sure what zero means here. In my opinion, the letter '0' is ASCII number 48, so I'm asking you to choose a value that is more than 48 but there is a question about this.

1-1 In addition, I have a question about the output value using min() and max(). I have a question about the output value. Is it correct to print it out as an ASCII value because this is also an ASCII value?

How do I handle Oracle in 2inx hint? I remember that the program skips from the beginning to the end when it meets an annotation. Even if I search on Google, it only says, "Write it like this, it's this function." <

I don't know why you use the 2-1 index hint and first_row max method. I can't tell the difference between the two because it's just how to use it

Be careful of the heat~

oracle index

2022-09-22 21:38

1 Answers

1. As far as I know, even if there is an index, if there is no conditional statement or the range of conditional results is large, the index is not used. That's why I think in this example, we put the where statement to find a case that is greater than the first ASCII code value of the regular character, '0'.

1-1. The min(), max() functions are output as strings. http://www.java2s.com/Tutorial/Oracle/0240__Aggregate-Functions/UseMAXwithstrings.htm

2. Are you sure you asked about how to use the tin? The question is a little unclear, but as you said, I skip the letters between /* and */ without interpreting them. Note that using -- will annotate the entire line after that line.

2-1. -- The paragraph that says index o, hint is the correct way to use max(name) as shown in the last paragraph because if the index column is changed, it may not be sorted based on name.


2022-09-22 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.