Home Database Mysql Tutorial 表空间数据文件详解(一)

表空间数据文件详解(一)

Jun 07, 2016 pm 03:54 PM
create create data document space Detailed explanation

一.表空间的创建 创建表空间: Create tablespace felix Datafile/u01/app/oracle/oradata/felix/felixtbs.dbf Size100m autoextendonnext10m maxsize1024m Extentmanagementlocaluniformsize128k Segmentspacemanagementauto; 这个很重要,如何查看创建的

一.表空间的创建

创建表空间:

Create tablespace felix

Datafile'/u01/app/oracle/oradata/felix/felixtbs.dbf'

Size100m autoextendonnext10m maxsize1024m

Extentmanagementlocaluniformsize128k

Segmentspacemanagementauto; 

这个很重要,如何查看创建的表空间属性,就用如下的语句:

selecttablespace_name,block_size,contents,extent_management,allocation_type,segment_space_management

from dba_tablespaces

where tablespace_name='FELIX'; 

如果需要查看表空间的扩展属性,需要通过dba_data_files进行查看:

selecttablespace_name,autoextensible,increment_by,maxbytes

fromdba_data_files

where tablespace_name='FELIX';

--为应用创建用户

createuser felix identifiedby felix

defaulttablespace felix

temporarytablespace temp;

#创建用户的相关信息则可以通过DBA_USERS 视图查询得到:

selectusername,user_id,password,default_tablespace,temporary_tablespace

fromdba_users

whereusername='FELIX'

#进行相应的权限的授予:

grantconnect,resourceto felix;

revokeunnlimited tablesapce from felix;

alteruser felix quotaunlimitedon felix;

二.表空间管理技术

(1)数据字典表空间管理技术(DMT):所谓的数据字典管理表空间是指,当创建或者删除对象时,oracle的表空间分配或回收是通过数据库中的数据字典来记录和管理的,用于管理的两个数据字典分别是:UET$ (used extents,已使用的空间)和FET$ (free extents,空闲表空间)。

SQL> DESC UET$;

Name Type Nullable Default Comments

--------- ------ -------- ------- --------

SEGFILE# NUMBER

SEGBLOCK# NUMBER

EXT# NUMBER

TS# NUMBER

FILE# NUMBER

BLOCK# NUMBER

LENGTH NUMBER

SQL> DESC FET$;

Name Type Nullable Default Comments

------ ------ -------- ------- --------

TS# NUMBER

FILE# NUMBER

BLOCK# NUMBER

LENGTH NUMBER

可以清晰的看到文件号(FILE#),数据块号(BLOCK#)等信息来管理空间的分配和回收;

数据字典管理表空间的工作方式;当一个新的段或者段在表空间中请求新的空间时,oracle通过执行一系列的sql语句来完成这个工作,这些工作包括从FET$找到可用的自由空间移动或增减相应的行到UET$中,并在FET$中删除相应的记录;当删除一个段的时候,oracle则移动UET$中相应的行到FET$;这个过程是连续的、串行的,在繁忙的数据库中,这类操作极可能导致竞争和等待,产生数据字典的争用;另一方面,当数据字典的表的信息被修改时,系统同样要记录undo和redo信息,频繁的修改又不可避免的对整个数据库的性能产生影响;

然而,数据字典管理表空间面临的另外一个问题就是:空间碎片

(2)本地管理表空间技术(LMT):oracle不再使用数据字典管理而是在每个表空间的数据文件头加了一个位图区域,在其中记录每个extent的使用情况,每当一个extent被使用,或者被释放以供重新使用时oracle都会跟新数据文件头的这个记录,反应这个变化;

创建语法如下:

CREATE TABLESPACEtablespace_name

DATAFILE ‘datafile_path_name’

[EXTENT MANASGEMENT { LOCAL| AUTOALLOCATION | UNIFORM [SIZEINTER [K|M]]}];

由于区间(extent)是oracle创建对象时的最小分配单元,所以表空间的管理实际上就是针对区间的管理;

--通过DBA_TABLESPACES视图查询表空间的类型:

select tablespace_name,extent_management,allocation_type

from dba_tablespaces;

DBA_EXTENTS记录了每个对象分配的区间(EXTENT),哪些对象分配了多少空间以及区间具体位于的文件等信息:

SQL> SELECTEXTENT_ID,BLOCK_ID,BLOCKS FROM DBA_EXTENTS WHERE SEGMENT_NAME='TS_TEST';

EXTENT_ID BLOCK_ID BLOCKS

---------- ---------- ----------

0 536 8

1 544 8

2 552 8

3 560 8

4 568 8

5 576 8

6 584 8

7 592 8

8 600 8

9 608 8

... …

11 624 8

12 632 8

13 640 8

14 1800 8

15 1808 8

16 768 128

17 896 128

18 1024 128

19 1152 128

20 1280 128

21 1408 128

56 7040 128

57 7168 128

58 rowsselected

转储数据块信息:

select object_id,

dbms_rowid.rowid_relative_fno(rowid) file#,

dbms_rowid.rowid_block_number(rowid) block#

from ts_test

where rownum

进行dump查看:

#alter systemdumpdatafile3blockmax 1blockmin 6;

selectvaluefrom v$diag_info;

[oracle@felix ~]$ vi /u01/app/oracle/diag/rdbms/felix/felix/trace/felix_ora_3219.trc

*** 2014-03-25 00:53:38.498

Block 1 (file header) not dumped:use dump file header command

Block dump from cache:

Dump of buffer cache at level 4 for tsn=2rdba=12582914

BH (0x6dbf97a8) file#: 3 rdba: 0x00c00002(3/2) class: 13 ba: 0x6db88000

set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,25

dbwrid: 0 obj: -1 objn: -1 tsn: 2 afn: 3 hint: f

hash: [0x77fb7be0,0x77fb7be0] lru: [0x6dbf9e80,0x6dbf9760]

lru-flags: hot_buffer

obj-flags: object_ckpt_list

ckptq: [0x6a3ed9a8,0x6a3e4eb8] fileq: [0x6c7e74c8,0x6bfe75f8] objq:[0x6d3e5e08,0x6dbf9788] objaq: [0x6dbf9eb8,0x6dbf9798]

st:XCURRENT md: NULL tch: 13

flags: buffer_dirty block_written_once redo_since_read

LRBA: [0x14.4b5f.0] LSCN: [0x0.14de1c] HSCN: [0x0.14de27] HSUB: [1]

Block dump from disk:

buffer tsn: 2 rdba: 0x00c00002 (3/2)

scn: 0x0000.00145380 seq: 0x02 flg: 0x04tail: 0x53801d02

frmt: 0x02 chkval: 0x1352 type: 0x1d=KTFB Bitmapped FileSpace Header

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x00007FAD09B98200 to0x00007FAD09B9A200

7FAD09B98200 0000A21D 00C00002 0014538004020000 [.........S......]

7FAD09B98210 00001352 00000003 0000000800003700 [R............7..]

7FAD09B98220 00000009 00000280 003FFFFE0000007E [..........?.~...]

7FAD09B98230 000036FF 00000060 000004DA00145375 [.6..`.......uS..]

7FAD09B98240 00000000 00000000 0000000000000000 [................]

alter session set events 'immediate trace name file_hdrs level 10';

1 select file_id,extent_id,block_id,blocks

2 from dba_extents

3*where segment_name='TS_TEST'

FILE_ID EXTENT_ID BLOCK_ID BLOCKS

---------- ---------- ---------- ----------

4 0 536 8

4 1 544 8

4 2 552 8

4 13 640 8

4 14 1800 8

4 15 1808 8

4 16 768 128

4 17 896 128

4 18 1024 128

4 19 1152 128

4 20 1280 128

4 21 1408 128

4 22 1536 128

4 23 1664 128

4 24 2944 128

4 25 3072 128

4 26 3200 128

4 56 7040 128

4 57 7168 128

4 58 7296 128

59 rows selected.

SQL> select block_size,tablespace_name,min_extents,max_extents fromdba_tablespaces;

BLOCK_SIZE TABLESPACE_NAME MIN_EXTENTS MAX_EXTENTS

---------- ------------------------------ ----------- -----------

8192 SYSTEM 1 2147483645

8192 SYSAUX 1 2147483645

8192 UNDOTBS1 1 2147483645

8192 TEMP 1

8192 USERS 1 2147483645

8192 EXAMPLE 1 2147483645

8192 STATSPACK 1 2147483645

8192 STATSPACKTEMP 1

8192 FELIX 1 2147483645

9 rows selected

段空间管理技术:

段内则是以block为单位进行空间使用和管理的;

主要段的类型有:

SQL>select distinct(segment_type) fromdba_segments;

SEGMENT_TYPE

------------------------------------

LOBINDEX

INDEX PARTITION

TABLE SUBPARTITION

TABLE PARTITION

NESTED TABLE

ROLLBACK

LOB PARTITION

LOBSEGMENT

INDEX

TABLE

CLUSTER

TYPE2 UNDO

12 rows selected.

(1) 手工段空间管理(manual Segment space management):这种技术(9i之前的做法)是室通过段头分配的自由列表(pctlist)来管理block的使用,简单一点就是把自由列表想象成一个数据表,oracle依赖一系列的算法通过自由列表中加入或移出block来管理段空间;

(2) 自动断管理方式(autosegment space management):通过位图实现管理

ASSM的巨大优势是位图组能够减轻缓冲区忙等待(Bufferbusy wait)的负担,在9i以前的版本里曾是一个严重的问题;并且显著提高了并发性,因为位图数组的不同部分可以被同时使用,这样就消除了寻找剩余空间的串行化。

ASSM的管理机制,首先前2个数据块为数据文件头,3~8个数据块为位图区,接下来的第9个块和第10个块就是ASSM位图块;

进行dump第9个块:

Alter database dump datafile 3 block 9;

SQL>alter systemdump datafile 3 block 9;

System altered.

SQL>select value from v$diag_info;

VALUE

------------------------------------------------------------------------------------

TRUE

/u01/app/oracle

/u01/app/oracle/diag/rdbms/felix/felix

/u01/app/oracle/diag/rdbms/felix/felix/trace

/u01/app/oracle/diag/rdbms/felix/felix/alert

/u01/app/oracle/diag/rdbms/felix/felix/incident

/u01/app/oracle/diag/rdbms/felix/felix/cdump

/u01/app/oracle/diag/rdbms/felix/felix/hm

/u01/app/oracle/diag/rdbms/felix/felix/trace/felix_ora_3050.trc

0

0

11 rows selected.

tail -300 /u01/app/oracle/diag/rdbms/felix/felix/trace/felix_ora_3050.trc

*** 2014-03-25 02:07:30.355

Block dump from cache:

Dump of buffer cache at level 4 for tsn=2rdba=12582921

Block dump from disk:

buffer tsn: 2 rdba: 0x00c00009 (3/9)

scn: 0x0000.000f2557 seq: 0x01 flg: 0x04tail: 0x25571e01

frmt: 0x02 chkval: 0xc075 type: 0x1e=KTFBBitmapped File Space Bitmap

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x00007FAD0893C600 to0x00007FAD0893E600

7FAD0893C600 0000A21E 00C00009 000F255704010000 [........W%......]

7FAD0893C610 0000C075 00000003 002E808000000000 [u...............]

7FAD0893C620 00000000 0000F800 0000000000000000 [................]

7FAD0893C630 00000000 00000000 0000000000000000 [................]

Repeat 507 times

7FAD0893E5F0 00000000 00000000 0000000025571E01 [..............W%]

File Space Bitmap Block:

BitMap Control:

RelFno: 3, BeginBlock: 3047552, Flag: 0,First: 0, Free: 63488

0000000000000000 0000000000000000 00000000000000000000000000000000

0000000000000000 00000000000000000000000000000000 0000000000000000

0000000000000000 00000000000000000000000000000000 0000000000000000

查询segment header,可以使用dba_segment视图:

SQL> selectsegment_name,header_file,header_file,header_block from dba_segments

2 where segment_NAME='TS_TEST';

SEGMENT_NAME HEADER_FILE HEADER_FILE HEADER_BLOCK

------------------- ----------- -----------------------

TS_TEST 4 4 538

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)

Use ddrescue to recover data on Linux Use ddrescue to recover data on Linux Mar 20, 2024 pm 01:37 PM

DDREASE is a tool for recovering data from file or block devices such as hard drives, SSDs, RAM disks, CDs, DVDs and USB storage devices. It copies data from one block device to another, leaving corrupted data blocks behind and moving only good data blocks. ddreasue is a powerful recovery tool that is fully automated as it does not require any interference during recovery operations. Additionally, thanks to the ddasue map file, it can be stopped and resumed at any time. Other key features of DDREASE are as follows: It does not overwrite recovered data but fills the gaps in case of iterative recovery. However, it can be truncated if the tool is instructed to do so explicitly. Recover data from multiple files or blocks to a single

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

How to create a folder on Realme Phone? How to create a folder on Realme Phone? Mar 23, 2024 pm 02:30 PM

Title: Realme Phone Beginner’s Guide: How to Create Folders on Realme Phone? In today's society, mobile phones have become an indispensable tool in people's lives. As a popular smartphone brand, Realme Phone is loved by users for its simple and practical operating system. In the process of using Realme phones, many people may encounter situations where they need to organize files and applications on their phones, and creating folders is an effective way. This article will introduce how to create folders on Realme phones to help users better manage their phone content. No.

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

See all articles