Home » RDBMS Server » Server Administration » VARCHAR2 Stored in DB in Terms of Bytes (Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit)
VARCHAR2 Stored in DB in Terms of Bytes [message #684311] Sat, 08 May 2021 00:09 Go to next message
robh0502
Messages: 5
Registered: January 2015
Location: Phoenix, AZ
Junior Member
Hi,
Our database uses the following character set.

US7ASCII

If I've got a table with one column and the datatype is varchar2(10 byte), how many bytes get stored in the database if the following only record is inserted into the database?

insert into testtable values ('test');

The dba_segment table shows 8 blocks and 65536 bytes.
Re: VARCHAR2 Stored in DB in Terms of Bytes [message #684312 is a reply to message #684311] Sat, 08 May 2021 00:45 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

There are many "bytes": data bytes, column bytes, row bytes, segment bytes.
In your example:
  • data bytes are 4: 1 byte per character
  • column bytes are 5: data + 1 byte for the length
  • row bytes is the sum of column bytes + row header
  • but rows are stored in blocks not alone, so a row alone in a table will take a block
  • but table blocks are not alone they are aggregate in extents (see dba_extents) which sizes depend on the tablespace properties
  • tables are made of one or more segments which are stored in one or more extents
...


Previous Topic: Grant Select rights
Next Topic: db_32k_cache_size RHEL
Goto Forum:
  


Current Time: Sun Nov 24 08:40:51 CST 2024