Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I know the size in memory of some user-defined type variable

BEDEJul 23 2021

I know that for the Oracle defined primary data type (like number, varchar2, date, timestamp) I can use select vsize(variable_name) from dual.
But how do I do for a variable of some user-defined type.
I can do something like the following:
declare
type tab_ch is table of varchar2(4000);
tb_ch tab_ch;
v_size number;
begin
tb_ch:=tab_ch('cuckoo', 'bau-wau','wysiswyg 8894983984983498jjsn');
v_size:=0;
for i in tb_ch.first..tb_ch.last loop
select v_size+vsize(tb_ch(i)) into v_size
from dual;
end loop;
dbms_output.put_line(v_size);
end;
/
But the above only gives the total size in memory of the components of a variable, while I think the variable itself takes more space in memory.
How to find the exact size in memory?

This post has been answered by User_H3J7U on Jul 23 2021
Jump to Answer
Comments
Post Details
Added on Jul 23 2021
7 comments
517 views