Size of a table [message #63943] |
Sun, 28 November 2004 19:01 |
Brayan
Messages: 315 Registered: June 2002
|
Senior Member |
|
|
Hi,
Can anybody give me a SQL script to find the size of a table in terms of KB/MB.
Regards,
Brayan.
|
|
|
|
Re: Size of a table [message #63961 is a reply to message #63945] |
Tue, 30 November 2004 03:50 |
Brayan
Messages: 315 Registered: June 2002
|
Senior Member |
|
|
This show the total byes in the extents allocated. How can I know the totalextents - free size ?
i.e Actual datasize in a table?
Regards,
Brayan
|
|
|
Re: Size of a table [message #63962 is a reply to message #63961] |
Tue, 30 November 2004 05:01 |
|
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
Daljit Singh is right.
It is the actual size of the table..NOT allocated.
Please have a look here
-- lets create some junk table and throw some data and check the size of table
-- when there are no records, the size is just initally allocated
-- after throwing records, it will grow.
-- when deleted, space is not released. When truncated space is released.
mag@mutation_mutation > create table myTable (id number, name char(30))
2 ;
Table created.
mag@mutation_mutation > truncate table mytable;
Table truncated.
mag@mutation_mutation > @/tmp/checksize
size_in_megs
------------
.0625
mag@mutation_mutation > @/tmp/insert
PL/SQL procedure successfully completed.
mag@mutation_mutation > @/tmp/checksize
size_in_megs
------------
.125
mag@mutation_mutation > @/tmp/insert
PL/SQL procedure successfully completed.
mag@mutation_mutation > @/tmp/checksize
size_in_megs
------------
.1875
mag@mutation_mutation > delete from mytable;
2666 rows deleted.
mag@mutation_mutation > commit;
Commit complete.
mag@mutation_mutation > @/tmp/checksize
size_in_megs
------------
.1875
mag@mutation_mutation > truncate table mytable;
Table truncated.
mag@mutation_mutation > @/tmp/checksize
size_in_megs
------------
.0625
mag@mutation_mutation > get /tmp/insert
1 begin
2 for mag in ( select rownum,segment_name from dba_segments) loop
3 insert into mytable values (mag.rownum,mag.segment_name);
4 end loop;
5 commit;
6* end;
mag@mutation_mutation > get /tmp/checksize
1* select bytes / (1024*1024) as "size_in_megs" from user_segments where segment_name = 'MYTABLE'
mag@mutation_mutation >
|
|
|