表空间、段、区、块的相关总结

总结
1、建立表空间后,并不会对表空间中的segments马上进行初始分配多个extents的空间,只有当真正的数据写入时才会按区的分配方式慢慢产生一个个extents,当数据文件没有可用空间了才会使用autoextend增长,当数据文件没有autoextend时则数据文件不再增长

2、段的ASSM方式下,建表时pctfree默认是10,putused默认是0即这个参数无效(个人理解的是不管PCTUSED是多少都是由ASSM自己来管理块是否可以继续insert重用,以此理解为这个参数无效),段的手工管理方式下,pctfree默认是10,putused默认是40
个人的实验经历:ASSM时pctused为0,固定表对应的数据文件的大小,往表中不停插入数据后dba_segments.bytes增大,再删除刚刚插入的数据后dba_segments.bytes不变,没有因为删除后变小,按理解这时候应该不再可以插入了因为PCTUSED不再有效,就算刚刚执行了删除操作空出了一些块,但是实验发现可以继续插入,所以个人认为不管PCTUSED是多少都是由ASSM自己来管理块是否可以继续insert重用,以此理解为这个参数无效。当然再插入后dba_segments.bytes依然不变,除非手工降低高水位线。

3、默认情况下,表空间的管理方式是local即本地管理(针对区而言,对立的就是字典管理),段的管理方式是auto(针对块而已,对立的就是manual),区的分配方式autoallocate(即表空间字段allocation_type显示system,对立的就是uniform)

4、create tablespace test6 datafile size 30M autoextend on next 10M uniform size 3M说明数据文件的自增长和区的分配方式没有关系(以前一直以为只要加了uniform字段就认为数据文件会按uniform的大小进行自增长)

5、一般表空间最多含有1024个数据文件,8kb块时,每个数据文件最大32G,16kb块时64G,32kb块时128G,64kb块时256G,4kb块时16G

6、非ASM环境下创建表空间一定要注明数据文件和大小,否则会报如下错误
ORA-17610: file '/u01/app/oracle/oradata/testdb/test1.dbf' does not exist and no size specified

7、11g默认初始分配为64K,之后每次都是一次性分配1M的大小,即autoallocate时表storeage的INITIAL为64K,NEXT为1M

8、如果uniform size 5M,则初始分配为5M,之后每次都是一次性分配5M大小,即表storeage的INITIAL为5M,NEXT为5M

9、区分配方式而言,TEMP表空间不能为AUTOALLOCATE,UNDO表空间不能UNIFORM

10、不指定AUTOALLOCATE或UNIFORM,则默认值临时表空间为UNIFORM,所有其他类型表空间为AUTOALLOCATE

11、数据文件自动扩展autoextend on不加next表示每次增加1个块





DBA_DATA_FILES.INCREMENT_BY:Number of Oracle blocks used as autoextension increment
数据文件自动扩展autoextend on不加next表示每次增加1个块

当使用extent management local uniform size 2M时,
select INITIAL_EXTENT,NEXT_EXTENT from dba_tablespaces;两者值一致


实验验证
create tablespace test1 datafile '/db/oracle/oradata/TESTDB/test1.dbf' size 10M autoextend on next 1M maxsize 1G extent management local uniform size 6M segment space management auto;
create tablespace test2 datafile '/db/oracle/oradata/TESTDB/test2.dbf' size 10M autoextend on next 1M maxsize 1G extent management local uniform size 7M segment space management manual;
create tablespace test3 datafile '/db/oracle/oradata/TESTDB/test3.dbf' size 10M autoextend on next 1M  maxsize 1G extent management local autoallocate segment space management manual ;
create tablespace test4 datafile '/db/oracle/oradata/TESTDB/test4.dbf' size 10M autoextend on next 1M maxsize 1G extent management local autoallocate segment space management auto;

create table test1 (hid number) tablespace test1;
create table test2 (hid number) tablespace test2;
create table test3 (hid number) tablespace test3;
create table test4 (hid number) tablespace test4;

test1
INITIAL    6M
NEXT       6M
PCTUSED    0
PCTFREE    10

test2
INITIAL    7M
NEXT       7M
PCTUSED    40
PCTFREE    10

test3
INITIAL    64K
NEXT       1M
PCTUSED    40
PCTFREE    10

test4
INITIAL    64K
NEXT       1M
PCTUSED    0
PCTFREE    10


select tablespace_name,INITIAL_EXTENT,NEXT_EXTENT,MAX_SIZE,ALLOCATION_TYPE,extent_management,SEGMENT_SPACE_MANAGEMENT from dba_tablespaces where tablespace_name like 'TEST%';
TABLESPACE_NAME INITIAL_EXTENT NEXT_EXTENT MAX_SIZE ALLOCATION_TYPE EXTENT_MANAGEMENT SEGMENT_SPACE_MANAGEMENT
TEST1 6291456 6291456 2147483645 UNIFORM LOCAL AUTO
TEST2 7340032 7340032 2147483645 UNIFORM LOCAL MANUAL
TEST3 65536 2147483645 SYSTEM LOCAL MANUAL
TEST4 65536 2147483645 SYSTEM LOCAL AUTO


select segment_name,segment_subtype from dba_segments where segment_name like 'TEST%' order by 1
SEGMENT_NAME SEGMENT_SUBTYPE
TEST1 ASSM
TEST2 MSSM
TEST3 MSSM
TEST4 ASSM




extent_management_clause 
The extent_management_clause lets you specify how the extents of the tablespace will be managed.
AUTOALLOCATE specifies that the tablespace is system managed. Users cannot specify an extent size. You cannot specify AUTOALLOCATE for a temporary tablespace.
UNIFORM specifies that the tablespace is managed with uniform extents of SIZE bytes.The default SIZE is 1 megabyte. All extents of temporary tablespaces are of uniform size, so this keyword is optional for a temporary tablespace. However, you must specify UNIFORM in order to specify SIZE. You cannot specify UNIFORM for an undo tablespace.
If you do not specify AUTOALLOCATE or UNIFORM, then the default is UNIFORM for temporary tablespaces and AUTOALLOCATE for all other types of tablespaces.
If you do not specify the extent_management_clause, then Oracle Database interprets the MINIMUM EXTENT clause and the DEFAULT storage_clause to determine extent management.
The DICTIONARY keyword is deprecated. It is still supported for backward compatibility. However, Oracle recommends that you create locally managed tablespaces. Locally managed tablespaces are much more efficiently managed than dictionary-managed tablespaces. The creation of new dictionary-managed tablespaces is scheduled for desupport.
extent_management_clause可以指定如何管理表空间的extents。
AUTOALLOCATE指定表空间是系统管理的。用户无法指定extent大小。您不能为临时表空间指定AUTOALLOCATE。
UNIFORM指定表空间以SIZE字节的uniform extents进行管理。默认SIZE为1兆字节。临时表空间的所有extents 都是uniform size,所以这个关键字对于临时表空间是可选的。但是,为了指定SIZE,您必须指定UNIFORM。您不能为UNDO表空间指定UNIFORM。
如果不指定AUTOALLOCATE或UNIFORM,则默认值临时表空间为UNIFORM,所有其他类型表空间为AUTOALLOCATE。
如果没有指定extent_management_clause,则Oracle数据库会解释MINIMUM EXTENT子句和DEFAULT storage_clause以确定扩展级别管理。
不推荐使用DICTIONARY关键字。它仍然支持向后兼容性。但是,Oracle建议您创建本地管理的表空间。本地管理的表空间比字典管理的表空间更有效地进行管理。新的字典管理的表空间的创建计划不受支持。


segment_management_clause 
The segment_management_clause is relevant only for permanent, locally managed tablespaces 
Specify AUTO if you want the database to manage the free space of segments in the tablespace using a bitmap. If you specify AUTO, then the database ignores any specification for PCTUSED, FREELIST, and FREELIST GROUPS in subsequent storage specifications for objects in this tablespace. This setting is called automatic segment-space management and is the default.
Specify MANUAL if you want the database to manage the free space of segments in the tablespace using free lists. Oracle strongly recommends that you do not use this setting and that you create tablespaces with automatic segment-space management.
If you specify AUTO segment management, then: 
If you set extent management to LOCAL UNIFORM, then you must ensure that each extent contains at least 5 database blocks.
If you set extent management to LOCAL AUTOALLOCATE, and if the database block size is 16K or greater, then Oracle manages segment space by creating extents with a minimum size of 5 blocks rounded up to 64K
segment_management_clause仅适用于永久的本地管理表空间
如果希望数据库使用位图管理表空间中的段的可用空间,请指定AUTO。 如果指定AUTO,则数据库将在此表空间中的对象的后续存储规范中忽略PCTUSED,FREELIST和FREELIST GROUPS的任何规范。 此设置称为自动段空间管理,是默认设置。
如果希望数据库使用免费列表管理表空间中的段的可用空间,请指定MANUAL。 Oracle强烈建议您不要使用此设置,并创建具有自动分段空间管理的表空间。
如果指定AUTO段管理,则:
如果将区域管理设置为LOCAL UNIFORM,则必须确保每个区段至少包含5个数据库块。
如果将范围管理设置为LOCAL AUTOALLOCATE,并且如果数据库块大小为16K或更大,则Oracle将通过创建扩展数据块来管理段空间,最小大小为5个块,最大为64K



storage_clause

INITIAL 
Specify the size of the first extent of the object. Oracle allocates space for this extent when you create the schema object. Refer to size_clause for information on that clause.
In locally managed tablespaces, Oracle uses the value of INITIAL, in conjunction with the type of local management—AUTOALLOCATE or UNIFORM—and the values of MINEXTENTS, NEXT and PCTINCREASE, to determine the initial size of the segment.
With AUTOALLOCATE extent management, Oracle uses the INITIAL setting to optimize the number of extents allocated. Extents of 64K, 1M, 8M, and 64M can be allocated. During segment creation, the system chooses the greatest of these four sizes that is equal to or smaller than INITIAL, and allocates as many extents of that size as are needed to reach the INITIAL setting. For example, if you set INITIAL to 4M, then the database creates four 1M extents.
For UNIFORM extent management, the number of extents is determined from initial segment size and the uniform extent size specified at tablespace creation time. For example, in a uniform locally managed tablespace with 1M extents, if you specify an INITIAL value of 5M, then Oracle creates five 1M extents.
Consider this comparison: With AUTOALLOCATE, if you set INITAL to 72K, then the initial segment size will be 128K (greater than INITIAL). The database cannot allocate an extent smaller than 64K, so it must allocate two 64K extents. If you set INITIAL to 72K with a UNIFORM extent size of 24K, then the database will allocate three 24K extents to equal 72K.
In dictionary managed tablespaces, the default initial extent size is 5 blocks, and all subsequent extents are rounded to 5 blocks. If MINIMUM EXTENT was specified at tablespace creation time, then the extent sizes are rounded to the value of MINIMUM EXTENT.
指定对象的第一个范围的大小。当您创建模式对象时,Oracle会为此扩展区分配空间。有关该条款的信息,请参阅size_clause。
在本地管理的表空间中,Oracle使用INITIAL的值与本地管理的类型AUTOALLOCATE或UNIFORM以及MINEXTENTS,NEXT和PCTINCREASE的值来确定段的初始大小。
使用AUTOALLOCATE扩展管理,Oracle使用INITIAL设置来优化分配的扩展数量。可以分配64K,1M,8M和64M的范围。在段创建期间,系统选择这四个大小中最大的等于或小于INITIAL,并分配与达到INITIAL设置所需的那样大小的区段。例如,如果将INITIAL设置为4M,则数据库将创建四个1M范围。
对于UNIFORM范围管理,扩展区的数量由初始段大小和在表空间创建时指定的统一区段大小确定。例如,在具有1M范围的统一本地管理的表空间中,如果指定INITIAL值为5M,则Oracle将创建5个1M范围。
— — 除了红色字体外,以下这些描述inital的内容都是垃圾,还会误导人,见个人下面test5、test6的实验验证
考虑这个比较:使用AUTOALLOCATE,如果将INITAL设置为72K,则初始段大小将为128K(大于INITIAL)。数据库不能分配小于64K的盘区,所以它必须分配两个64K盘区。如果将INITIAL设置为72K,UNIFORM扩展大小为24K,那么数据库将分配三个24K的区域,等于72K。
在字典管理的表空间中,默认的初始扩展区大小为5个块,所有后续扩展区四舍五入为5个块。如果在表空间创建时指定了MINIMUM EXTENT,则扩展区大小将舍入为MINIMUM EXTENT的值。
create tablespace test5 datafile '/db/oracle/oradata/TESTDB/test5.dbf' size 10M autoextend on next 1M maxsize 1G extent management local uniform size 72K segment space management auto;
create tablespace test6 datafile '/db/oracle/oradata/TESTDB/test6.dbf' size 10M autoextend on next 1M maxsize 1G extent management local uniform size 48K segment space management auto;
create table test5 (hid number) tablespace test5;
create table test6 (hid number) tablespace test6;
test5
INITIAL    72K
NEXT       72K

test6
INITIAL    48K
NEXT       48K


NEXT 
Specify in bytes the size of the next extent to be allocated to the object. Refer to size_clause for information on that clause.
In locally managed tablespaces, any user-supplied value for NEXT is ignored and the size of NEXT is determined by Oracle if the tablespace is set for autoallocate extent management. In UNIFORM tablespaces, the size of NEXT is the uniform extent size specified at tablespace creation time.
In dictionary-managed tablespaces, the default value is the size of 5 data blocks. The minimum value is the size of 1 data block. The maximum value depends on your operating system. Oracle rounds values up to the next multiple of the data block size for values less than 5 data blocks. For values greater than 5 data blocks, Oracle rounds up to a value that minimizes fragmentation.
以字节指定要分配给对象的下一个区段的大小。 有关该条款的信息,请参阅size_clause。
在本地管理的表空间中,如果将表空间设置为自动分配盘区管理,则NEXT的任何用户提供的值将被忽略,并且由Oracle确定NEXT的大小。 在UNIFORM表空间中,NEXT的大小是在表空间创建时指定的uniform extent size大小。
在字典管理的表空间中,默认值是5个数据块的大小。 最小值是1个数据块的大小。 最大值取决于您的操作系统。 Oracle将数值舍入到数据块大小的下一个倍数,数值小于5个数据块。 对于大于5个数据块的值,Oracle将舍入到最小化碎片的值。



CREATE TABLE TEST6
(
  HID  NUMBER
)
TABLESPACE TEST6
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          48K
            NEXT             48K
            MAXSIZE          UNLIMITED
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2145044/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30126024/viewspace-2145044/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习是一种人工智能(AI)的子领域,致力于研究如何利用数据和算法让计算机系统具备学习能力,从而能够自动地完成特定任务或者改进自身性能。机器学习的核心思想是让计算机系统通过学习数据中的模式和规律来实现目标,而不需要显式地编程。 机器学习应用非常广泛,包括但不限于以下领域: 图像识别和计算机视觉: 机器学习在图像识别、目标检测、人脸识别、图像分割等方面有着广泛的应用。例如,通过深度学习技术,可以训练神经网络来识别图像中的对象、人脸或者场景,用于智能监控、自动驾驶、医学影像分析等领域。 自然语言处理: 机器学习在自然语言处理领域有着重要的应用,包括文本分类、情感分析、机器翻译、语音识别等。例如,通过深度学习模型,可以训练神经网络来理解和生成自然语言,用于智能客服、智能助手、机器翻译等场景。 推荐系统: 推荐系统利用机器学习算法分析用户的行为和偏好,为用户推荐个性化的产品或服务。例如,电商网站可以利用机器学习算法分析用户的购买历史和浏览行为,向用户推荐感兴趣的商品。 预测和预测分析: 机器学习可以用于预测未来事件的发生概率或者趋势。例如,金融领域可以利用机器学习算法进行股票价格预测、信用评分、欺诈检测等。 医疗诊断和生物信息学: 机器学习在医疗诊断、药物研发、基因组学等领域有着重要的应用。例如,可以利用机器学习算法分析医学影像数据进行疾病诊断,或者利用机器学习算法分析基因数据进行疾病风险预测。 智能交通和物联网: 机器学习可以应用于智能交通系统、智能城市管理和物联网等领域。例如,可以利用机器学习算法分析交通数据优化交通流量,或者利用机器学习算法分析传感器数据监测设备状态。 以上仅是机器学习应用的一部分,随着机器学习技术的不断发展和应用场景的不断拓展,机器学习在各个领域都有着重要的应用价值,并且正在改变我们的生活和工作方式。
表空间(Tablespace)是 Oracle 数据库中用于存储表、索引、视图以及其他数据库对象的逻辑容器。它是由一个或多个数据文件组成的逻辑存储单元。每个表空间都有一个唯一的名称,并且可以分配给多个用户。 数据文件(Data File)是物理存储在磁盘上的文件,用于存储表空间中的数据。一个表空间可以由一个或多个数据文件组成。每个数据文件都有一个唯一的路径和文件名,并且属于一个特定的表空间。 数据(Data Block)是 Oracle 数据库中最小的存储单位。它是在数据文件中分配给表空间的一连续的物理空间。每个数据都有固定大小(通常为8KB),用于存储表、索引和其他数据库对象的数据。 Segment)是逻辑上相关的数据的集合。一个可以包含一个表、索引、分或者其他数据库对象。是由一组连续的数据组成,它们被分配给一个特定的表空间。 范围(Extent)是一组连续的数据,用于存储一个的数据。当一个需要更多的存储空间时,Oracle 数据库会分配额外的范围给该。范围是以数据为单位进行分配和管理的。 总结:在 Oracle 数据库中,表空间是逻辑的存储容器,由数据文件组成;数据文件是物理存储在磁盘上的文件,存储表空间中的数据;数据是最小的存储单位,用于存储数据;是一组连续的数据,用于存储一个数据库对象的数据;范围是一组连续的数据,用于存储一个的数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值