데이터 베이스 MySQL 튜토리얼 Oracle复合数据类型示例

Oracle复合数据类型示例

Jun 07, 2016 pm 05:13 PM

--Recode数据类型 declare v_deptinfo scott.dept%rowtype; type dept_record is RECORD( v1 scott.dept.deptno%type, v2 sc

--Recode数据类型

declare

v_deptinfo scott.dept%rowtype;

type dept_record is RECORD(

  v1 scott.dept.deptno%type,

  v2 scott.dept.dname%type,

  v3 scott.dept%rowtype--可以声明ROWTYPE类型

);

v_deptrecord dept_record;

begin

--一下的赋值方式错误:因为V3是ROWTYPE类型,而查询的一行记录有五列,给v3赋值时会发生类型不匹配

select deptno,dname,t.* into v_deptrecord from dept t where deptno=10;

--解决方法:可以对v1,v2赋值后,,再写另外一条语句对v3赋值。

dbms_output.put_line(v_deptrecord.v3.dname||' '||v_deptrecord.v3.deptno);

end;


--索引表1

declare

type my_index_table1 is table of scott.dept.dname%type--可以使任意数据类型,代表此索引表所存储数据的类型。

index by binary_integer;

my1 my_index_table1;

c number(2);

begin

select count(*) into c from dept;

for i in 1..c loop

  select dname into my1(i) from

   (select rownum rn,t.* from dept t) x

     where x.rn=i;

end loop;

--每个集合都有COUNT属性,代表此集合存储的有效元素总个数。

for i in 1..my1.count loop

  dbms_output.put_line(my1(i));

end loop;

end;


--索引表2

declare

type my_index_table1 is table of scott.dept.dname%type

index by varchar2(20);--Oracle 9i以上的版本,索引表的下表可以为3中数据类型(BINARY_INTEGER、PLS_INTEGER、VVARCHAR2(length));

my1 my_index_table1;

begin

select loc into my1('南昌') from dept where deptno=10;

dbms_output.put_line(my1('南昌'));

end;


--嵌套表1

declare

type my_index_table1 is table of scott.dept.dname%type;

my1 my_index_table1:=my_index_table1(null,null,null,null);--初始化可以使用null值

begin

select dname into my1(1) from dept where deptno=10;

select dname into my1(2) from dept where deptno=20;

select dname into my1(3) from dept where deptno=30;

select dname into my1(4) from dept where deptno=40;

--嵌套表删除元素后,下标依然存在,依然可以重新进行赋值.

my1.delete(3);

dbms_output.put_line(my1.count);

select dname into my1(3) from dept where deptno=30;

dbms_output.put_line(my1.count);

for i in 1..my1.count loop

  dbms_output.put_line(my1(i));

end loop;

end;


--嵌套表2

create type phone_type is table of varchar2(20);

create table employee (

   eid number(4),

   ename varchar2(10),

   phone phone_type

) nested table phone store as phone_table;


insert into employee

values(1,'xx',phone_type('0791-111','123454545'));


insert into employee

values(2,'xx',phone_type('0791-111','123454545','saaasf'));

--变长数组

declare

type my_index_table1 is varray(3) of scott.dept.dname%type;

my1 my_index_table1:=my_index_table1('a','b','c');--初始化

begin

select dname into my1(1) from dept where deptno=10;

select dname into my1(3) from dept where deptno=20;

for i in 1..my1.count loop

  dbms_output.put_line(my1(i));

end loop;

end;


--记录表2

declare

--自定义RECORD可以存放自己想要的列,脱离了ROWTYPE的死板,可以灵活的自定义存放哪些列。

type dept_record is RECORD(

  v1 scott.dept.deptno%type,

  v2 scott.dept.dname%type,

  v3 scott.dept.loc%type

);

type my_index_table1 is table of dept_record

index by binary_integer;

my1 my_index_table1;

c number(2);

--查询出dept表中的所有数据并放进自定义的数据类型

begin

-先查询出表中的记录总数,以记录总数作为循环条件对dept表、以rownum作为WHERE条件对dept表进行逐条查询并存贮进自定义数据类型

select count(*) into c from dept;

for i in 1..c loop

  select x.deptno,x.dname,x.loc into my1(i) from

   (select rownum rn,t.* from dept t) x

     where x.rn=i;

end loop;

--循环输出my1类型中的v2字段在DEPT表中代表的数据;

for i in 1..my1.count loop

  dbms_output.put_line(my1(i).v2);

end loop;

end;

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

숫자의 가장 큰 소인수를 찾는 C 프로그램 숫자의 가장 큰 소인수를 찾는 C 프로그램 Aug 27, 2023 am 10:09 AM

소인수−수론에서 양의 정수의 소인수는 정확히 소수로 나누어지는 소수입니다. 이 숫자를 찾는 과정을 정수 인수분해 또는 소인수분해라고 합니다. 예−288의 소인수는 다음과 같습니다: 288=2x2x2x2x2

상위 10 개 글로벌 디지털 가상 통화 거래 플랫폼 순위 (2025 권위있는 순위) 상위 10 개 글로벌 디지털 가상 통화 거래 플랫폼 순위 (2025 권위있는 순위) Mar 06, 2025 pm 04:36 PM

2025 년에 Global Digital Virtual Currency Trading Platform은 2025 년에 트랜잭션 볼륨, 보안 및 사용자 경험과 같은 지표를 기반으로 전 세계 10 대 디지털 가상 통화 거래 플랫폼을 권위있게 발표합니다. OKX는 강력한 기술 강점과 글로벌 운영 전략으로 1 위를 차지했으며 Binance는 높은 유동성과 낮은 수수료와 밀접한 관련이 있습니다. Gate.io, Coinbase 및 Kraken과 같은 플랫폼은 각각의 장점과 함께 최전선에 있습니다. 이 목록에는 Huobi, Kucoin, Bitfinex, Crypto.com 및 Gemini와 같은 거래 플랫폼이 각각 고유 한 특성을 지니고 있지만 투자는 신중해야합니다. 플랫폼을 선택하려면 보안, 유동성, 수수료, 사용자 경험, 통화 선택 및 규제 준수와 같은 요소를 고려해야합니다.

2025 년 통화 서클의 10 대 교환 최신 디지털 통화 앱 순위 2025 년 통화 서클의 10 대 교환 최신 디지털 통화 앱 순위 Feb 27, 2025 pm 06:33 PM

상위 10 개의 가상 통화 거래 플랫폼 순위 (2025 년 최신) : BINANCE : 글로벌 리더, 높은 유동성 및 규제가 주목을 끌었습니다. OKX : 대규모 사용자 기반, 여러 통화를 지원하며 레버리지 거래를 제공합니다. Gate.io : 다양한 화폐 통화 지불 방법을 갖춘 선임 교환으로 다양한 거래 쌍 및 투자 제품을 제공합니다. BITGET : 파생 상품 교환, 높은 유동성, 낮은 수수료. HUOBI : 다양한 통화 및 거래 쌍을 지원하는 오래된 교환. 코인베이스 : 잘 알려진 미국 교환으로 엄격하게 규제되었습니다. Phemex 등.

상위 10 개 디지털 통화 거래 플랫폼 상위 10 개 디지털 통화 거래 플랫폼의 최신 목록 상위 10 개 디지털 통화 거래 플랫폼 상위 10 개 디지털 통화 거래 플랫폼의 최신 목록 Mar 17, 2025 pm 05:57 PM

상위 10 개 디지털 통화 거래 플랫폼 : 1. OKX, 2. BINANCE, 3. GATE.IO, 4. HUOBI GLOBAL, 5. KRAKEN, 6. COINBASE, 7. KUCOIN, 8. BITFINEX, 9. CRYPTO.COM, 10. GEMINI, 자체 특성을 보유하고 있으며,이 교환은 보안, 요소, 보안, 사용자를 기반으로하는 플랫폼을 선택할 수 있습니다.

디지털 통화 앱을위한 상위 10 개 트레이딩 플랫폼, 정기 통화 추측 플랫폼 앱 권장 사항 디지털 통화 앱을위한 상위 10 개 트레이딩 플랫폼, 정기 통화 추측 플랫폼 앱 권장 사항 Mar 07, 2025 pm 06:51 PM

이 기사는 10 개의 디지털 거래 앱을 권장한다. 플랫폼을 선택할 때 보안, 유동성, 거래 수수료, 통화 선택, 사용자 인터페이스, 고객 서비스 지원 및 규제 준수와 같은 요소를 고려하고 위험을 신중하게 평가하고 맹목적으로 추세를 따르지 않아야합니다.

신뢰할 수있는 디지털 통화 플랫폼은 무엇입니까? 신뢰할 수있는 디지털 통화 플랫폼은 무엇입니까? Mar 17, 2025 pm 05:45 PM

신뢰할 수있는 디지털 통화 플랫폼은 다음과 같습니다. 1. OKX, 2. BINANCE, 3. GATE.IO, 4. HUOBI GLOBAL, 5. COINBASE, 7. BITFINEX, 9. CRYPTO.com, GEMINI는 이들 교환을 기반으로하는 플랫폼을 선택할 수 있습니다.

세계 10 대 10 가상 통화 거래 플랫폼 앱 진짜 다운로드 및 설치 자습서 세계 10 대 10 가상 통화 거래 플랫폼 앱 진짜 다운로드 및 설치 자습서 Mar 12, 2025 pm 05:33 PM

이 기사는 Binance, Okx, Gate.io, Huobi Global, Coinbase, Kucoin, Kraken 및 Bitfinex와 같은 주류 디지털 통화 거래 플랫폼에 대한 Android 및 Apple Mobile 앱 다운로드 방법을 제공합니다. Android 사용자이든 Apple 사용자이든 상관없이 해당 플랫폼의 공식 앱 다운로드 링크를 쉽게 찾아 단계에 따라 설치를 완료 할 수 있습니다. 이 기사는 해당 공식 웹 사이트 또는 앱 스토어에서 검색 및 다운로드에 대한 자세한 지침을 제공하며 Android에 APK 파일을 설치하는 특별 단계에 대한 지침을 제공하여 사용자가 빠르고 쉽게 다운로드하여 사용할 수 있습니다.

상위 10 개 디지털 통화 앱 거래 플랫폼 Top10 가상 통화 앱 2025 순위 상위 10 개 디지털 통화 앱 거래 플랫폼 Top10 가상 통화 앱 2025 순위 Mar 13, 2025 pm 07:00 PM

상위 10 개는 다음과 같습니다. 순위는 플랫폼 유동성, 통화 선택, 보안, 사용자 경험, 수수료 및 규정 준수와 같은 포괄적 인 고려 사항을 기반으로하지만 투자는 신중하고 자신의 위험에 처해 있어야합니다.

See all articles