Home Database Mysql Tutorial ORACLE空间管理实验2:区的管理与分配

ORACLE空间管理实验2:区的管理与分配

Jun 07, 2016 pm 04:21 PM
oracle distribute experiment space manage

内容基于LMT管理的表空间,字典管理已经不用了。 本篇主要验证了这些问题: 1.LMT管理的表空间,区的分配有两种方法: 系统分配和UNIFORM固定大小--见实验 2.验证Oracle找寻可用区的方式: 从数据文件开头的位图块中获得可用区的信息,DUMP时可见FIRST:3这种

  内容基于LMT管理的表空间,字典管理已经不用了。

本篇主要验证了这些问题:

1.LMT管理的表空间,区的分配有两种方法:
系统分配和UNIFORM固定大小-->见实验

2.验证Oracle找寻可用区的方式:
从数据文件开头的位图块中获得可用区的信息,DUMP时可见FIRST:3这种,表示已经使用3个区。详见:点击打开链接

3.在表空间中建第一个表(注意,第一个),这个表从数据文件的第几个块开始使用
11G下,LMT管理的表空间,数据文件中0-127号块做位图区域用,第128个块才开始存放表的数据。详见:

4.最小的表-最小的区多大?
5个BLOCK,如果BLOCK大小是8K,则最小的表是40K。--见下面实验

5.表空间中多个数据文件如何分配空间?
多个数据文件上平均分配--见下面实验
#####################################################################

实验一:系统管理区大小和统一区大小的区别是什么,如何验证这个区别?

系统管理区大小由系统自动分配扩展的区大小,
在段的前1M空间:区大小8个块=64K,前16个区是这样。
在段1M---64M之间:区大小1M,128个块
在段64M之后,区大小8M。
可以在系统管理区的表空间内创建表,,然后手动分配1个extent,然后依次扩展960K空间,1M空间,62M空间,然后再扩展一个extent的方式来测试。alter table a1 allocate extent (SIZE 1m);
统一区大小则由创建表空间时uniform size 40k;子句指定.
可以先创建两个不同管理方式的表空间,再分别在此两个表空间创建两个表,手动扩展区,再通过dba_segments来查看。

BYS@ bys3>select tablespace_name,block_size,INITIAL_EXTENT,next_extent,EXTENT_MANAGEMENT,ALLOCATION

_TYPE,SEGMENT_SPACE_MANAGEMENT from dba_tablespaces where tablespace_name like 'TEST_';
TABLESPACE_NAME BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT EXTENT_MAN ALLOCATIO SEGMEN
--------------- ---------- -------------- ----------- ---------- --------- ------
TEST1 8192 65536 LOCAL SYSTEM AUTO
TEST2 8192 40960 40960 LOCAL UNIFORM AUTO
TEST3 8192 65536 LOCAL SYSTEM AUTO
BYS@ bys3>select * from cat;
TABLE_NAME TABLE_TYPE
------------------------------ -----------
DEPT TABLE
BYS@ bys3>create table test1(aa int) tablespace test1;
Table created.
BYS@ bys3>create table test2(aa int) tablespace test2;
Table created.
BYS@ bys3>insert into test1 values(789);
BYS@ bys3>insert into test2 values(789);
BYS@ bys3>commit;
Commit complete.
BYS@ bys3>select segment_name,tablespace_name,bytes,blocks,extents,initial_extent,next_extent from dba_segments where owner='BYS' and segment_name like 'TEST_';
SEGMENT_NAME TABLESPACE_NAME BYTES BLOCKS EXTENTS INITIAL_EXTENT NEXT_EXTENT
--------------- --------------- ---------- ---------- ---------- -------------- -----------
TEST1 TEST1 65536 8 1 65536 1048576
TEST2 TEST2 40960 5 1 40960 40960
BYS@ bys3>alter table test1 allocate extent;
Table altered.
BYS@ bys3>alter table test2 allocate extent;
Table altered.
BYS@ bys3>select segment_name,tablespace_name,bytes,blocks,extents,initial_extent,next_extent from dba_segments where owner='BYS' and segment_name like 'TEST_';
SEGMENT_NAME TABLESPACE_NAME BYTES BLOCKS EXTENTS INITIAL_EXTENT NEXT_EXTENT
--------------- --------------- ---------- ---------- ---------- -------------- -----------
TEST1 TEST1 131072 16 2 65536 1048576
TEST2 TEST2 81920 10 2 40960 40960
BYS@ bys3>alter table test2 allocate extent (size 2m); --2M,系统自动扩展区,此时一个区大小是1M,所以此语句扩展两个区,此时4个区
Table altered.
BYS@ bys3>alter table test1 allocate extent (size 2m);-UNIFORM SIZE 40K,2048/40=51.2,分配51个区--四舍五入。此时是54个区。
Table altered.
BYS@ bys3>select segment_name,tablespace_name,bytes,blocks,extents,initial_extent,next_extent from dba_segments where owner='BYS' and segment_name like 'TEST_';

SEGMENT_NAME TABLESPACE_NAME BYTES BLOCKS EXTENTS INITIAL_EXTENT NEXT_EXTENT
--------------- --------------- ---------- ---------- ---------- -------------- -----------
TEST1 TEST1 2228224 272 4 65536 1048576
TEST2 TEST2 2170880 265 53 40960 40960

BYS@ bys3>alter table test2 allocate extent (size 110k); --这里的分配区间好像用的四舍五入,比如这里的110k/40K=2.75,分配了三个区
Table altered.
BYS@ bys3>select segment_name,tablespace_name,bytes,blocks,extents,initial_extent,next_extent from dba_segments where owner='BYS' and segment_name like 'TEST_';
SEGMENT_NAME TABLESPACE_NAME BYTES BLOCKS EXTENTS INITIAL_EXTENT NEXT_EXTENT
--------------- --------------- ---------- ---------- ---------- -------------- -----------
TEST1 TEST1 2228224 272 4 65536 1048576
TEST2 TEST2 2293760 280 56 40960 40960

实验二:一个表至少多大?

在ASSM下,一个区最少5个块。
而一个普通堆表是一个段,一个段最少包含一个区,一个区最少包含5个块,所以当表空间block是8K时,表至少40K。
实验如下:
BYS@ bys3>create tablespace test2 datafile '/u01/oradata/bys3/test2.dbf' size 10m uniform size 32k;
create tablespace test2 datafile '/u01/oradata/bys3/test2.dbf' size 10m uniform size 32k
*
ERROR at line 1:
ORA-03249: Uniform size for auto segment space managed tablespace should have atleast 5 blocks
这一句报错信息可以看到,一个区需要至少5个数据块。
BYS@ bys3>create tablespace test2 datafile '/u01/oradata/bys3/test2.dbf' size 10m uniform size 40k;
Tablespace created.
BYS@ bys3>create table test16(bb int) tablespace test2 storage (initial 1k maxextents 1);
Table created.
BYS@ bys3>insert into test16 values(999);
1 row created.
BYS@ bys3>commit;
Commit complete.
BYS@ bys3>select a.SEGMENT_NAME,a.bytes/1024 segment_byte,a.TABLESPACE_NAME,b.INITIAL_EXTENT,b.BLOCK_SIZE,b.ALLOCATION_TYPE from dba_segments a,dba_tablespaces b where a.owner='BYS' and a.segment_name like 'TEST1_' and a.tablespace_name=b.tablespace_name;
SEGMENT_NA SEGMENT_BYTE TABLESPACE_NAME INITIAL_EXTENT BLOCK_SIZE ALLOCATIO
---------- ------------ ------------------------------ -------------- ---------- ---------
TEST15 64 USERS 65536 8192 SYSTEM
TEST16 40 TEST2 40960 8192 UNIFORM
####################################################################

实验三:一个表空间有10个数据文件,在此表空间中创建一个大小100M的表,表的空间将如何分配到10个数据文件
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What to do if the oracle can't be opened What to do if the oracle can't be opened Apr 11, 2025 pm 10:06 PM

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

How to paginate oracle database How to paginate oracle database Apr 11, 2025 pm 08:42 PM

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

How to stop oracle database How to stop oracle database Apr 12, 2025 am 06:12 AM

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

How to create oracle dynamic sql How to create oracle dynamic sql Apr 12, 2025 am 06:06 AM

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values ​​to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

What to do if the oracle log is full What to do if the oracle log is full Apr 12, 2025 am 06:09 AM

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

See all articles