Detailed data segment oracle

TABLESPACE (tablespace): tablespace is a logical division of the database, a table space belongs to only one database. All database objects are placed in the specified table space, but the object is stored in the main table, so called table spaces.

The default system table space: system, sysaux, temp, undo, user

segments(段)

The organization is an important segment table space, space segment refers to collectively take up file space, or the use of a set of data objects; segment can have the table segment, index segment, rollback segments, temporary segments and caching section.

Section type:

Cluster cluster

Table table

Table partition table partition

Index index

Index partition index partition

Partition lob lob partition (lob subpartition lobsub partition, lob index lob index, lob segment lob segment)

Nested tables nested table

Roll back rollback

Table :

For a few hundred thousands of pieces of data, a school's student achievement table, a table is a segments.

Table partition: If a table is very large, which stores tens of millions, hundreds of millions of records, then this one table to operate, efficiency is very low. Partition table is many small subset of a large data table is divided into partitions called. If a table is located hundreds of millions of pieces of data, so that a plurality of records is regular, a field may be based on a separate them. According to a field you can type partitions, each is actually a separate table, but on the logical partitions they belong to a table.

If a table is a common table, only a segments; if a table is a partition table may occupy multiple segments.

Cluster :

Oracle tables as ordinary table heap (heap table), the data is disordered heap table stored, often in use for some time, the data becomes very disordered. For example: the same index key corresponding to the data stored in different block in this case, if you want to query data through the index of a key, you need access to a lot of different block, the cost is very high. We found a lot of tables and table, their data is relevant, because we have access to a table of data, often want to access other data table. We can put in a physical store these data.

Index

Index is a structure associated with the selected table and gathered on when a book in our catalog, pages can be quickly quickly locate a section of a chapter. Index can be based on one or more columns of a table, it can greatly improve query to the table. Then the index may also account for a more than a segments.

Index-organized table :

Index Organized Tables (IOT), is stored in a table index results. Table is stored on the heap is unorganized (that is, as long as there is space available, data can be placed anywhere). For your applications, IOT table and a "regular" table and non-discriminatory. When using the heap organized tables, and we must make room for the index on the table and the table's primary key. The IOT space overhead primary key does not exist, because the index is the data, the data is indexed.

IOT brings benefits not only saves disk space occupied, more importantly, a significant reduction in I / O, reducing the access buffer cache (although to get data from the buffer cache is much faster than hard drives, but the buffer cache and not free, but by no means cheap. each buffer cache needs to get more latches buffer cache (shuān), while the latch is the serial device will limit the scalability of the application)

Index partition

For the table there is partition, then there is also a large partition of the index.

Partition cited can be divided into local and global partitioned index partitioned index, which local index can be divided into local and non-local prefix index prefix index. Local index table is equal to the number of partitions and their corresponding partitions, each partition table index corresponds to a respective partition. Use local index, because the index does not need to specify the partition range for the table is local, when local index is created, Oracle will automatically create a separate index for the partition table in each partition. Global index indexing data objects of the whole table, the index entry in the index partition may either be based on the same key, but from a different partition may comprise a combination of a plurality of different keys. Allows both the same global index key index partitions and table partitioning key, may not be the same. There is no direct link between global indexes and tables, and this is different from the local index.

Undo segment rollback to the previous value stored modification data (including the position data and the value before modification). Rollback transaction rollback segment header contains information that is being used. A transaction can only use it to store a rollback rollback information, and a rollback rollback information can be stored in multiple transactions.

Temporary segment

When processing a query Oracle often need temporary space for the intermediate results and the Execution of SQL statements (intermediate stage). Oracle will automatically allocate is called a temporary segment (temporary segment) of disk space. For example, Oracle during the period of the sort you need to use temporary operation. When the sorting operation can be performed in memory, or trying to use Oracle indexes do not have to create a temporary segment.

LOB segment

Large object (LOB) big objects, we know that not only can the data stored in the database, you can store video and some sound pictures and other documents, for this type of file a size of several MB, dozens of MB normal. Of course, some database does not support LOB data blocks can be stored in a pointer table to point to video sound files in a file.

Nested table

Nested table, table tables, and LOB idea is similar to that stored in a table pointer, a pointer to another table.

Create a segment:

During tables, indexes, created (in 11gR2, creating a section to wait until the first data is inserted), i.e., in fact, create a segment, you can see from user_segment segment has been created

 
Create a basic table, see section allocated
SQL> create table test(id number,name varchar2(20));

Then query

SQL> select segment_name,segment_type,tablespace_name,bytes,blocks,extents from user_segments;

You'll find no data, insert a piece of data to try

SQL> insert into test(id,name) values(1,'test');

Then in the query

SQL> select segment_name,segment_type,tablespace_name,bytes,blocks,extents from user_segments;

 

This time, you will be found in the data.

In 11gR2, the data will be allocated only after the insertion space segment, or simply insert the data in a specified 11g to create a table or segment creation immediate same effect can be obtained.

And 10g, create a table space will be assigned a segment.

Create a table with a primary key to view the section allocated

SQL> create table test(id number primary key) segment creation immediate;

Then query segment

SQL> select segment_name,segment_type,tablespace_name,bytes,blocks,extents from user_segments;
 
Creating a table lob field of view segment allocated

SQL> create table test3(id number primary key, describe clob, comment blob) segment creation immediate;

Then query segment

SQL> select segment_name,segment_type,tablespace_name,bytes,blocks,extents from user_segments;
 

Thus, test1 create only a segment table, test2 creates a segment table and an index segment, test3 create a table segment, a segment index, two lobindex, two lobsegment.

Conclusion: When creating a table, the table information and data may be dispersed into a plurality of segments each holds part of the information, and a region composed of segments, regions of blocks oracle, oracle by the operating system.

When creating a new segment, the default zone 1, 8 blocks, a total of 8K * 8 space, the default block size oracle case of 8k.

Guess you like

Origin www.cnblogs.com/black-start/p/10985899.html