Oracle复合数据类型示例
--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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











In 2025, global digital virtual currency trading platforms are fiercely competitive. This article authoritatively releases the top ten digital virtual currency trading platforms in the world in 2025 based on indicators such as transaction volume, security, and user experience. OKX ranks first with its strong technical strength and global operation strategy, and Binance follows closely with high liquidity and low fees. Platforms such as Gate.io, Coinbase, and Kraken are at the forefront with their respective advantages. The list covers trading platforms such as Huobi, KuCoin, Bitfinex, Crypto.com and Gemini, each with its own characteristics, but investment should be cautious. To choose a platform, you need to consider factors such as security, liquidity, fees, user experience, currency selection and regulatory compliance, and invest rationally

PrimeFactor−Innumbertheory,theprimefactorsofapositiveintegeraretheprimenumbersthatdividethatintegerexactly.Theprocessoffindingthesenumbersiscalledintegerfactorization,orprimefactorization.Example−Primefactorsof288are:288=2x2x2x2x2

Ranking of the top ten virtual currency trading platforms (latest in 2025): Binance: Global leader, high liquidity, and regulation has attracted attention. OKX: Large user base, supports multiple currencies, and provides leveraged trading. Gate.io: A senior exchange, with a variety of fiat currency payment methods, providing a variety of trading pairs and investment products. Bitget: Derivatives Exchange, high liquidity, low fees. Huobi: An old exchange that supports a variety of currencies and trading pairs. Coinbase: A well-known American exchange, strictly regulated. Phemex and so on.

This article recommends ten digital currency trading apps: 1. OKX; 2. Binance; 3. Gate.io; 4. Huobi Global; 5. Kraken; 6. Coinbase; 7. KuCoin; 8. Crypto.com; 9. Bitfinex; 10. Poloniex. When choosing a platform, you need to consider factors such as security, liquidity, transaction fees, currency selection, user interface, customer service support and regulatory compliance, and carefully evaluate risks and never blindly follow the trend.

Top 10 digital currency trading platforms: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi Global, 5. Kraken, 6. Coinbase, 7. KuCoin, 8. Bitfinex, 9. Crypto.com, 10. Gemini, these exchanges have their own characteristics, and users can choose the platform that suits them based on factors such as security, fees, currency selection, user interface and customer support.

This article provides Android and Apple mobile APP download methods for mainstream digital currency trading platforms such as Binance, OKX, Gate.io, Huobi Global, Coinbase, KuCoin, Kraken and Bitfinex. Whether it is an Android user or an Apple user, you can easily find the official APP download link for the corresponding platform and complete the installation according to the steps. The article provides detailed guidance on searching and downloading on their respective official websites or app stores, and provides instructions on the special steps for installing APK files on Android, so that users can download and use them quickly and easily.

Reliable digital currency platforms include: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi Global, 5. Kraken, 6. Coinbase, 7. KuCoin, 8. Bitfinex, 9. Crypto.com, 10. Gemini. These exchanges have their own characteristics. Users can choose the platform that suits them based on factors such as security, fees, currency selection, user interface and customer support.

The best cryptocurrency trading and analysis platforms include: 1. OKX: the world's number one in trading volume, supports multiple transactions, provides AI market analysis and on-chain data monitoring. 2. Binance: The world's largest exchange, providing in-depth market conditions and new currency first-time offerings. 3. Sesame Open Door: Known for spot trading and OTC channels, it provides automated trading strategies. 4. CoinMarketCap: an authoritative market data platform, covering 20,000 currencies. 5. CoinGecko: Known for community sentiment analysis, it provides DeFi and NFT trend monitoring. 6. Non-small account: a domestic market platform, providing analysis of linkage between A-shares and currency markets. 7. On-chain Finance: Focus on blockchain news and update in-depth reports every day. 8. Golden Finance: 24 small
