Preamble
In Oracle PL/SQL, the MULTISET UNION collection operation returns the merging of two collections
MULTISET UNION syntax in Oracle PL/SQL
nt1 MULTISET UNION nt2
Collection parameters and arguments
- nt1, nt2 – collections to combine
Note:
- Operations are possible only with nested tables collections. Both collections that participate in an operation must be of the same type. The result of the operation is also a collection of nested tables.
Consider some examples of operations on the MULTISET UNION collections to understand how to use MULTISET UNION in Oracle PL/SQL
For example:
DECLARE
reslt varchar2(100);
TYPE nested_typ IS TABLE OF NUMBER;
nt1 nested_typ := nested_typ(1,2,3);
nt2 nested_typ := nested_typ(3,2,1);
nt3 nested_typ := nested_typ(2,3,1,3);
answer nested_typ;
BEGIN
answer := nt1 MULTISET UNION nt2;
for iter in answer.first ... answer.last
loop
if iter = 1 then
reslt:=answer(iter);
else
reslt := reslt ||', '||to_char(answer(iter));
end if;
end loop;
dbms_output.put_line('nt1 MULTISET UNION nt2 = '||reslt);
--Output: nt1 MULTISET UNION nt2 = 1, 2, 3, 3, 2, 1
answer := nt1 MULTISET UNION nt3;
for iter in answer.first ... answer.last
loop
if iter = 1 then
reslt:=answer(iter);
else
reslt := reslt ||', '||to_char(answer(iter));
end if;
end loop;
dbms_output.put_line('nt1 MULTISET UNION nt3 = '||reslt);
--Output: nt1 MULTISET UNION nt3 = 1, 2, 3, 2, 3, 1, 3.
END;
Another example of MULTISET UNION with line collections
DECLARE
reslt varchar2(100);
TYPE nested_typ IS TABLE OF varchar2(20);
nt1 nested_typ := nested_typ('alpha', 'beta', 'gamma');
nt2 nested_typ := nested_typ('beta', 'gamma', 'alpha');
nt3 nested_typ := nested_typ('beta', 'alpha', 'gamma', 'delta');
answer nested_typ;
BEGIN
answer := nt1 MULTISET UNION nt2;
for iter in answer.first ... answer.last
loop
if iter = 1 then
reslt:=answer(iter);
else
reslt := reslt ||', '||answer(iter);
end if;
end loop;
dbms_output.put_line('nt1 MULTISET UNION nt2 = '||reslt);
--Output: nt1 MULTISET UNION nt2 = alpha, beta, gamma, gamma, alpha
answer := nt1 MULTISET UNION nt3;
for iter in answer.first ... answer.last
loop
if iter = 1 then
reslt:=answer(iter);
else
reslt := reslt ||', '||answer(iter);
end if;
end loop;
dbms_output.put_line('nt1 MULTISET UNION nt3 = '||reslt);
--Output: nt1 MULTISET UNION nt3 = alpha, beta, gamma, alpha, gamma, delta
END;
Set-Level Manipulation of Nested Tables (MULTISET)
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
Optimizing Digital Learning Infrastructure with AIOps, FinOps, and Intelligent Database Analytics
- 14 August 2026
- Software Engineering
Introduction Digital learning has evolved from a supplementary educational channel into a core component of modern education. Learning management systems (LMS), virtual classrooms, online assessments, student information systems, digital libraries, video platforms, collaboration tools, and AI-powered learning applications now operate as interconnected technology ecosystems. As institutions expand online and hybrid learning, the infrastructure supporting these … Continue reading “Optimizing Digital Learning Infrastructure with AIOps, FinOps, and Intelligent Database Analytics”
How AIOps and FinOps Transform Cloud Cost Management for Higher Education Platforms
Higher education is undergoing a rapid digital transformation. Universities and colleges increasingly depend on cloud-based Learning Management Systems (LMS), student information systems, virtual classrooms, digital libraries, research platforms, campus applications, analytics environments, and administrative systems. These platforms enable institutions to deliver better digital experiences, but they also introduce a growing challenge: how to control cloud … Continue reading “How AIOps and FinOps Transform Cloud Cost Management for Higher Education Platforms”
How to Optimize Energy and Utilities Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability
- 13 August 2026
- Database Performance Management
Introduction Energy and utility companies operate highly complex digital infrastructures supporting electricity generation, transmission, distribution, water services, natural gas, renewable energy, and customer operations. Every smart meter reading, grid event, outage record, customer payment, asset maintenance activity, and energy transaction generates data that must be processed efficiently. Enteros helps energy and utility organizations optimize database … Continue reading “How to Optimize Energy and Utilities Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability”
How to Optimize Real Estate Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability
Introduction Real estate organizations increasingly depend on digital platforms to manage property portfolios, transactions, leasing, facilities, tenants, financial operations, and customer experiences. Every property listing, lease transaction, maintenance request, payment, tenant interaction, and financial report depends on enterprise databases. Enteros helps real estate organizations optimize database performance through Database Observability, AI-powered Analytics, SQL Performance Intelligence, … Continue reading “How to Optimize Real Estate Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability”