Oracle 집합

3574 단어 OacleOacle 집합
Oacle 의 집합 은 모두 세 가지 가 있 습 니 다. 1. 관련 배열;2. 내장 배열;3. VARRAY (가 변 길이 배열)
1. 연관 배열
그 정의 문법 은 type 배열 이름 is table of 요소 형식 index by 색인 형식 입 니 다.
색인 형식 은 varchar 2 형식 과 pls 일 수 있 습 니 다.integer 형식 입 니 다. 예 를 들 어:

declare
   --          
   type student_list is table of student%rowtype index by pls_integer;
   --        
   student_list_var student_list;
   --      
   cursor student_cursor is 
     select * from student;
begin
   --    ,  student_index          
   for student_index in student_cursor
   loop
     --  id  student  number  ,          .         java    map  
     student_list_var(student_index.id) := student_index;
   end loop;

2. 내장 배열
문법: type 배열 이름 is table of 원소 형식
예 를 들 면:

--        
type list_of_name is table of varchar2(100);
--        ,  student  
type list_of_student is table of student%rowtype;

사용 예시:

--        
create type student_table is table of student%rowtype;
--                   
create or replace of function list_studect(student_name in student.name%type) return student_table is
  --              
  cursor student_cursor(student_name in student.name%type) is
    select * from student where name like student_name||'%';
  --          
  student_var student%rowtype;
  --          
  student_table_var student_table;
  --           
  index_var pls_integer := 0;
begin
  --       
  student_table_var =: student_table();
  --    
  for cur_index in student_cursor(student_name)
  loop
    --      
    student_table_var.extend;
    --   1  , ,         
    index_var := index_var + 1;
    --  
    student_table_var(index_var) := cur_index;
  end loop;
  return student_table_var;
end;

3. VARRAY (가 변 길이 배열)
문법: type 배열 이름 is varray (배열 길이) of 요소 유형
예 를 들 면:

--            
type list_of_name is varray(100) of varchar2(100);
--            ,  student  
type list_of_student is varray(500) of student%rowtype;

VARRAY 의 사용 과 끼 워 넣 는 표 의 차이 가 많 지 않 습 니 다. 유일한 차이 점 은 VARRAY 가 길이 제한 이 있다 는 것 입 니 다.
그들의 차 이 는 다음 그림 과 같다.
속성
연관 배열
상감 표
varray
위도
일차 원
일차 원
일차 원
SQL 에 사용 할 지 여부
사용 할 수 없다
사용 가능
사용 가능
표 에 열 거 된 데이터 형식 으로 사용 할 수 있 는 지 여부
사용 할 수 없다
사용 가능
사용 가능
초기 화 된 상태
빈 (NULL 일 수 없 음) 요 소 는 정의 되 지 않 았 습 니 다.
자동 으로 NULL 입 니 다. 요소 에 대한 인용 은 불법 입 니 다.
자동 으로 NULL 입 니 다. 요소 에 대한 인용 은 불법 입 니 다.
초기 화
성명 시 자동 완성
구조 함수 또는 할당 또는 fetch 작업 을 통 해 완료 합 니 다.
구조 함수 또는 할당 또는 fetch 작업 을 통 해 완료 합 니 다.
드문드문
예.
시작은 아니 었 다.지우 면 돼 요.
아니다
경계 가 있 는 지 없 는 지
무한 하 다
확장 가능
아니다
임의의 원소 에 수시로 값 을 부여 할 수 있다
되다
안 됩 니 다. extend 로 확장 해 야 합 니 다.
안 됩 니 다.먼저 extend 로 확장 할 수 있 으 며, extend 확장 시 상 경 계 를 초과 할 수 없습니다.
확장 방법
새 아래 표 시 된 요소 에 값 을 부여 합 니 다.
extend 프로 세 스 (또는 trim 압축) 를 사용 하여 미리 정 의 된 최대 값 이 없습니다.
extend (또는 trim), 하지만 최대 성명 의 최대 크기 까지 만 가능 합 니 다.
여부
안 된다
네, Oacle10g 또는 이후 버 전 으로 요청 합 니 다.
안 된다
집합 연산 자 를 통 해 조작 할 지 여부
안 된다
네, Oacle10g 또는 이후 버 전 으로 요청 합 니 다.
안 된다
데 이 터 를 액세스 할 때 순서 나 아래 표 시 를 유지 할 지 여부 입 니 다.
N/A
보류 하지 않 음
보류 하 다.
다음 편 은 Spring 을 쓰 겠 습 니 다.

좋은 웹페이지 즐겨찾기