Home » RDBMS Server » Server Administration » Data Block, Extents, and Segments
() 2 Votes
Data Block, Extents, and Segments [message #129773] |
Tue, 26 July 2005 11:39 |
wtolentino
Messages: 421 Registered: March 2005
|
Senior Member |
|
|
Oracle datafiles are comprised of data blocks, extents, and segments. Data blocks stores the oracle database data. Extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information. What are those specific type of informations that are stored in extents? And segment is a set of extents allocated for a certain logical structure. What are those logical structures that are in the segment?
[Updated on: Wed, 27 July 2005 10:51] Report message to a moderator
|
|
|
Re: Data Block, Extents, and Segments [message #129786 is a reply to message #129773] |
Tue, 26 July 2005 12:44 |
|
Alien
Messages: 292 Registered: June 1999
|
Senior Member |
|
|
Hi,
Maybe the easiest way is to take a table and an index. I assume you're familiar with the scott/tiger tables.
emp is a table, we can create an index emp_idx on the empno.
We'll have one or more data-blocks, holding the rows from emp.
We'll have one or more data-blocks for the index, holding the empno and the rowid. (Bit more complex. But for a start).
The extents for the table emp will consist of data-blocks containing the data from emp.
The extents for the index emp_idx will consist of blocks containing the empno/rowid references.
We then have 2 segments. One is the table emp. Which consists of all extents for table emp.
The other is index emp_idx,which consists of all extents for index emp_idx.
So segments, think of the objects (table, index, and so on). Extents, are parts of these segments, containing the segments data or contents. I/O can be minimized down to block level.
Regards,
Arian
|
|
|
|
Re: Data Block, Extents, and Segments [message #129791 is a reply to message #129773] |
Tue, 26 July 2005 13:22 |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
In addition to the earlier comments/example, I would change your line that reads:
"Extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information."
To:
An extent is a specific number of logically contiguous data blocks, obtained in a single logical allocation from an existing physically allocated datafile. A segment is a set of extents used to store a specific type of information, such as table data, index data, clob data, and table partition data.
Also, good for you for working to understand the concepts. Very helpful in the long run.
|
|
|
|
Re: Data Block, Extents, and Segments [message #129992 is a reply to message #129801] |
Wed, 27 July 2005 10:50 |
wtolentino
Messages: 421 Registered: March 2005
|
Senior Member |
|
|
Thanks to both of you. This is very helpfull.
Correct me if I am wrong with this understanding. Suppose I had created a table:
MyOwnTable
==========
MyColumn1 Varchar2(5)
MyColumn2 Varchar2(5)
MyColumn3 Varchar2(5)
MyColumn4 Number
The table refers to the segment. Now I had SQL to create a data:
INSERT INTO MyOwnTable
(MyColumn1, MyColumn2, MyColumn3, MyColumn4)
VALUES
('Data1-A','Data1-B','Data1-C',1);
The values are now stored in the 1st row of the data blocks
block1: Data1-A
block2: Data1-B
block3: Data1-C
block4: 1
I had another SQL to create a second data:
INSERT INTO MyOwnTable
(MyColumn1, MyColumn2, MyColumn3, MyColumn4)
VALUES
('Data2-A','Data2-B','Data2-C',2);
The values are now stored in the 2nd row of the data blocks
block1: Data2-A
block2: Data2-B
block3: Data2-C
block4: 2
The 1st row of the data block refers to the 1st extent then the 2nd row of the data block is the 2nd extent. Those two extent is now the segment.
|
|
|
Re: Data Block, Extents, and Segments [message #129996 is a reply to message #129992] |
Wed, 27 July 2005 11:09 |
JSI2001
Messages: 1016 Registered: March 2005 Location: Scotland
|
Senior Member |
|
|
Hi
Think about this in the physical world. This may slightly over simplify matters, but it gives the general idea:
Consider a building, this building has multiple rooms, in each room are 1 or more filing cabinets, each of thos cabinets have - let's say - 5 drawers each.
Each drawer is a block. Each file in that drawer is a row (some of the files may be bigger than others) Each Filing cabinet is an extent, each room is a segment.
Let's say we are in room 1. This represents segment1 in our db. (which equates to tableA)
When we start, the table is empty, the room has 1 filing cabinet with no info in it.
We put a row in. That row (or file now) goes into the first available drawer. We add another row and so long as our new (file) can fit into the first drawer, it is filed away there. This is repeated until the drawer in the filing cabinet is full, the next row goes into the 2nd drawer (Block) in the same filing cabinet (extent) Once all the drawers have been filled, a new filing cabinet is brought in (new extent is requested) and the process of filling this set of drawers (blocks) is repeated.
So to clarify,
The room represents a segment (Table1)
The filing cabinet represents an extent
The drawers in the Filing Cabinet represent Blocks.
Rows are put into blocks until the block is full, blocks are filled until the extent is full, and extents are allocated indefinitely or until a pre-set limit has been reached (max_extents)
[Updated on: Wed, 27 July 2005 11:10] Report message to a moderator
|
|
|
|
|
Re: Data Block, Extents, and Segments [message #130394 is a reply to message #130393] |
Fri, 29 July 2005 14:19 |
wtolentino
Messages: 421 Registered: March 2005
|
Senior Member |
|
|
It is now clear to me that data is physically stored at the datafiles. Suppose I had created a stored packages, procedures, and functions where does this object is physically stored at? Is these objects are also physically stored in the datafiles?
|
|
|
|
|
Re: Data Block, Extents, and Segments [message #131392 is a reply to message #129773] |
Fri, 05 August 2005 13:56 |
wtolentino
Messages: 421 Registered: March 2005
|
Senior Member |
|
|
There are 3 type of segments:
- Data Segments
- Rollback Segments
- Temporary Segments
Suppose there are 10 rows in table employee. Now I issue a "DELETE FROM employee;" command. Does the data transferred temporarily into the rollback segment and is removed from data segment? I issue a ROLLBACK command. Does the rollback statement releases the data from the rollback segment and send it back to the data segment? Thanks.
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Jan 10 08:49:34 CST 2025
|