size of table or index…all the objects in oracle

you can query the size of an object,such as table,index….from user_extents or dba_extents

because,a segment maybe cross muti extents,look at “TEST”,you need to sum all the bytes of each extent_id to get the total size of table “TEST”

SQL> select segment_name,segment_type,tablespace_name,extent_id,bytes from user_extents;

SEGMENT_NAME                   SEGMENT_TYPE       TABLESPACE_NAME                 EXTENT_ID      BYTES
—————————— —————— —————————— ———- ———-
DEPT                           TABLE              USERS                                   0      65536
EMP                            TABLE              USERS                                   0      65536
BONUS                          TABLE              USERS                                   0      65536
SALGRADE                       TABLE              USERS                                   0      65536
TEST                           TABLE              USERS                                   0      65536
TEST                           TABLE              USERS                                   1      65536
TEST                           TABLE              USERS                                   2      65536
TEST                           TABLE              USERS                                   3      65536
TEST                           TABLE              USERS                                   4      65536
TEST                           TABLE              USERS                                   5      65536
TEST                           TABLE              USERS                                   6      65536
TEST                           TABLE              USERS                                   7      65536
TEST                           TABLE              USERS                                   8      65536
TEST                           TABLE              USERS                                   9      65536
TEST                           TABLE              USERS                                  10      65536
TEST                           TABLE              USERS                                  11      65536
TEST                           TABLE              USERS                                  12      65536
TEST                           TABLE              USERS                                  13      65536
TEST                           TABLE              USERS                                  14      65536
TEST                           TABLE              USERS                                  15      65536
TEST                           TABLE              USERS                                  16    1048576
TEST                           TABLE              USERS                                  17    1048576
TEST                           TABLE              USERS                                  18    1048576
TEST                           TABLE              USERS                                  19    1048576
TEST                           TABLE              USERS                                  20    1048576
USERS                          TABLE              USERS                                   0      65536
PK_DEPT                        INDEX              USERS                                   0      65536
PK_EMP                         INDEX              USERS                                   0      65536

28 rows selected.

SQL> select sum(bytes) from user_extents where segment_name=’TEST’;

SUM(BYTES)
———-
6291456

it’s the same as INDEX…..