As a DBA, one of the common scenarios is:
Create a tablespace:
create tablespace Think datafile '/u01/app/oracle/oradata/orcl/think.dbf' size 100M autoextend on next 10M maxsize 4096M extent management local uniform size 256K segment space management auto;
Create a user:
create user bin default tablespace Think temporary tablespace temp;
Grant permissions:
grant connect,resource to bin; revoke unlimited tablespace from bin; alter user bin quota unlimited on Think;
In this scenario, there are two statements:
① Extent management local uniform size 256 K
② Segment space management auto
The former is zone management, and the latter is segment space management.
(I) Zone Management
Zone management is actually the management of tablespaces.
Before 8i, The tablespace is managed in a dictionary. when an object is created or deleted, Oracle's space allocation or recycling is recorded and managed in a data dictionary.
In high-concurrency systems, this will lead to performance degradation, space fragmentation, and other problems
This is already an old technology. I will not go into details here.
Starting from 8i, Oracle introduced local tablespace Management
Adds a bitmap area to the header of the data file in each tablespace.
The first block in the first partition of a segment is the first level bitmap block.
The second block is the second level bitmap block.
The third block is the segment header block.
These two blocks are used to manage free blocks.
Syntax:
Extent management local {autoallocate | uniform size n k/m}
Automatic allocation or uniform size
For automatic allocation, Oracle allocates space according to the incremental algorithm.
If you select a uniform size, you can also specify the size of each interval in detail.
Dba_extents this view shows which objects are allocated with how many intervals
(Ii) segment space management
Oracle allocates space to object segments in units of segments, while segments use and manage space in units of blocks.
We use several parameters to understand section space management.
sys@ORCL> select extent_management,segment_space_management from dba_tablespaces;EXTENT_MAN SEGMEN---------- ------LOCAL MANUALLOCAL MANUALLOCAL AUTOLOCAL MANUALLOCAL MANUAL
From 9i, there are two types of segment space management:
① Mssm: You can set freelists, freelist groups, pctused, pctfree, initrans, and other parameters to control how to allocate and use space in segments.
② Assm: you only need to control the pctfree parameter. Other parameters will be ignored even if they are created.
(1) freelist
When using mssm tablespace management, Oracle will maintain blocks below hwm for objects with free space in freelist
Freelist and freelist group do not exist in the assm tablespace. This technology is used only in the mssm tablespace.
(2) pctfree and pctused
Pctfree tells Oracle how much space should be reserved on the block to complete future updates.
For mssm, she controls when the block is put into freelist and when it is retrieved from freelist.
If it is greater than pctfree, the block will remain on freelist.
For assm, assm does not use freelist at all. In assm, pctused is also ignored.
However, she will still limit whether a new row can be inserted into a block.
Setting pctfree appropriately helps reduce row migration
(3) initrans
Whether assm or mssm, this parameter is still valid.
The initialization size of the transaction slot in the block header is specified by the initrans of the object.